Skip to content

Commit

Permalink
update: implemented functionality to see vendor documents in vendors …
Browse files Browse the repository at this point in the history
…applications
  • Loading branch information
kingsley-sunny committed Jan 8, 2025
1 parent 9dcaaf5 commit 709a702
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions pages/admin/vendors/vendor-application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const VendorApplications = () => {
}),
[getVendorsData]
);
console.log("🚀 ~~ VendorApplications ~~ data:", getVendorsData?.getUserType);

const rejected = useMemo(
() =>
Expand Down
58 changes: 56 additions & 2 deletions pages/admin/vendors/vendor-info/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CustomerDetail from "@/components/admin/customers/customer-detail";
import { FormHead } from "@/components/admin/form";
import { AdminLayout } from "@/layouts";
import { RootState } from "@/store/rootReducer";
import { Tabs } from "antd";
import { Image, Tabs } from "antd";
import { useRouter } from "next/router";
import { useState } from "react";
import { useSelector } from "react-redux";
Expand All @@ -16,7 +16,7 @@ import {
useGetCustomerTotalExpense,
} from "../../../../hooks/admin/dashboard";
import { userGetUserById } from "../../../../hooks/admin/user";
import { useFlagVendor } from "../../../../hooks/admin/vendors";
import { useCompleteSeller, useFlagVendor, useRejectSeller } from "../../../../hooks/admin/vendors";
import useSellerProducts from "../../../../hooks/useSellerProducts";

const Customer = () => {
Expand Down Expand Up @@ -54,13 +54,25 @@ const Customer = () => {
const { data: customerTotalExpense, isLoading: isTotalExpenseLoading } =
useGetCustomerTotalExpense({ id: customerId, token });

const { mutate: acceptVendor } = useCompleteSeller();
const { mutate: rejectVendor } = useRejectSeller();

const { mutate: flagVendor } = useFlagVendor();

const vendor = userData?.getUserById;
const totalOrders = customerTotalOrder?.getCustomerOrders;
const avgOrderValue = averageOrderValue?.getCustomerAverageOrder;
const totalExpense = customerTotalExpense?.getCustomerTotalExpense;

const isVendorPending =
Array.isArray(userData?.getUserById?.sellerProfile) &&
!userData?.getUserById?.sellerProfile[0]?.sellerIsVerified &&
!userData?.getUserById?.sellerProfile[0]?.sellerIsRejected;

const isVendorRejected =
Array.isArray(userData?.getUserById?.sellerProfile) &&
userData?.getUserById?.sellerProfile[0]?.sellerIsRejected;

return (
<AdminLayout>
<BreadCrumbs
Expand Down Expand Up @@ -100,6 +112,32 @@ const Customer = () => {
/>
) : null}

{isVendorPending && (
<div className='tw-flex tw-space-x-2'>
<button
className='tw-px-6 tw-py-2 tw-text-sm tw-rounded-md tw-mt-3 tw-text-white-100 tw-bg-green-success'
onClick={e => acceptVendor({ email: userData?.getUserById?.email })}
>
Accept
</button>
<button
className='tw-px-6 tw-py-2 tw-text-sm tw-rounded-md tw-mt-3 tw-text-white-100 tw-bg-error'
onClick={e => rejectVendor({ email: userData?.getUserById?.email })}
>
Reject
</button>
</div>
)}

{isVendorRejected && (
<button
className='tw-px-6 tw-py-2 tw-text-sm tw-rounded-md tw-mt-3 tw-text-white-100 tw-bg-green-success'
onClick={e => rejectVendor({ email: userData?.getUserById?.email })}
>
Re - Accept
</button>
)}

<div className=' tw-pt-6 xl:tw-w-[50vw] tw-grid xl:tw-grid-cols-3 tw-gap-4'>
{isLoadingCustomerTotalOrders ? <Load className='tw-h-32' /> : null}
{totalOrders ? (
Expand Down Expand Up @@ -181,6 +219,22 @@ const Customer = () => {
{new Date(vendor?.sellerProfile[0]?.date).toDateString()}
</p>
</div>

<div className=''>
<p className=' tw-mb-0 tw-font-medium tw-text-opacity-70 tw-pt-2'>
DOCUMENT:{" "}
<span className='tw-font-light tw-uppercase'>
{vendor?.sellerProfile[0]?.preferedId}
</span>
</p>
<div className=' tw-mb-0 tw-text-opacity-70 tw-pt-0.5'>
<Image
width={"100%"}
alt='Vendor document'
src={vendor?.sellerProfile[0]?.preferedIdUrl}
/>
</div>
</div>
</div>
</div>

Expand Down
6 changes: 6 additions & 0 deletions store/admin/admin.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ export const GET_SELLERS = /* GraphQL */ `
phoneNumber
date
sellerIsVerified
preferedId
preferedIdUrl
}
}
}
Expand Down Expand Up @@ -490,6 +492,10 @@ export const GET_USER_BY_ID = /* GraphQL */ `
city
lga
date
sellerIsVerified
sellerIsRejected
preferedId
preferedIdUrl
}
storedetail {
id
Expand Down

0 comments on commit 709a702

Please sign in to comment.