diff --git a/src/Pages/Admin/Notification.jsx b/src/Pages/Admin/Notification.jsx index 3645bed..0d84595 100644 --- a/src/Pages/Admin/Notification.jsx +++ b/src/Pages/Admin/Notification.jsx @@ -15,6 +15,7 @@ import { OPACITY_ON_LOAD } from "../../Layout/animations"; import FormInputMain from "../../Components/FormInputMain"; import { useGetContactQuery, + useSendNotificationMutation, useUpdateContactMutation, } from "../../Services/contact.service"; import FullscreenLoaders from "../../Components/Loaders/FullscreenLoaders"; @@ -23,8 +24,9 @@ import NormalTable from "../../Components/DataTable/NormalTable"; import GlobalStateContext from "../../Contexts/GlobalStateContext"; import { useGetInvestorsQuery } from "../../Services/investor.details.service"; import { TABLE_PAGINATION } from "../../Constants/Paginations"; -import { generateSerialNumber } from "../../Constants/Constants"; +import { formatDate, generateSerialNumber } from "../../Constants/Constants"; import { ViewIcon } from "@chakra-ui/icons"; +import { useGetUnbanInvestorQuery } from "../../Services/ban.investor.service"; export const notification = yup.object().shape({ investmentNameEnglish: yup @@ -79,26 +81,26 @@ const Notification = () => { const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size); const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page); + + + // const { + // data: investorDetails, + // isLoading: investorDetailsLoading, + // // error, + // } = useGetInvestorsQuery({ page: currentPage, size: pageSize }); + + const { - data: investorDetails, + data : investorDetails, isLoading: investorDetailsLoading, - // error, - } = useGetInvestorsQuery({ page: currentPage, size: pageSize }); + refetch, + } = useGetUnbanInvestorQuery(); console.log(investorDetails); - const [updateContact] = useUpdateContactMutation(); - - useEffect(() => { - if (contact) { - reset({ - phoneNumber: contact?.data[0]?.phoneNumber, - emailAddress: contact?.data[0]?.emailAddress, - websiteUrl: contact?.data[0]?.websiteUrl, - }); - } - }, [contact, reset]); + const [sendNotification] = useSendNotificationMutation(); + if (contactLoading) { return ; } @@ -152,6 +154,7 @@ const Notification = () => { }, {}); const onSubmit = async (data) => { + console.log(data); const dataToPass = { ...data, @@ -165,132 +168,131 @@ const Notification = () => { setIsLoading(true); try { - const res = await updateContact(dataToPass); - if (res?.data?.statusCode === 200) { + const res = await sendNotification(dataToPass); + console.log(res); + + if (res?.error) { toast({ - render: () => , + render: () => ( + + ), }); - setIsLoading(false); + setIsLoading(false) + }else if(res?.data){ + toast({ + render: () => ( + + ), + }); + setIsLoading(false) + // reset() + }else{ + toast({ + render: () => ( + + ), + }); + setIsLoading(false) } } catch (error) { console.log(error); setIsLoading(false); } + + }; - console.log(selectedRadio); - // ====================================================[Table Setup]================================================================ const tableHeadRow = [ - "Sr No", + "Sr N/O", + "Date", "Client ID", "First Name", "Last Name", - "Country", + "Country", "Phone Number", "E-mail ID", - "Type", "KYC Status", - // "Status", ]; + const extractedArray = investorDetails?.data?.rows?.map((item, idx) => ({ - id: item?.id, - "Sr No": ( + id: item?.principal_xid, + "Sr N/O": ( - {/* {item.id} */} - {generateSerialNumber(idx,currentPage, pageSize )} - + {item?.id} ), + Date: ( + + + {formatDate(item?.date)} + + + ), "Client ID": ( - {item.clientReference_id} + {item?.clientReference_id} - + ), "First Name": ( - {item?.principal?.firstName} + {item?.firstName} ), "Last Name": ( - + - {item?.principal?.lastName} + {item?.lastName} ), Country: ( - {item?.country?.countryName} + {item?.country} ), "Phone Number": ( - {item?.principal?.mobileNumber} + {item?.phoneNumber} ), "E-mail ID": ( - {item?.principal?.emailAddress} + {item?.emailAddress} ), - "Type": ( - - - - {item?.investor_type?.investorTypeName} - - - - ), - Status: ( - - - {item.ioStatus ? "Ban" : "Unban"} - - - ), "KYC Status": ( - - + - {item.KYCStatus ? "Completed" : "Not complete"} - + {item?.KYCStatus === true ? "Completed" : "Incompleted"} + ), })); diff --git a/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx b/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx index b6d5ba2..c28e970 100644 --- a/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx +++ b/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx @@ -12,7 +12,7 @@ const Kyc = () => { ); const [value, setValue] = useState('2') - console.log(data?.data?.KYC?.questions[0]?.question_text); + console.log(data?.data?.KYC?.questions); return ( @@ -53,6 +53,8 @@ const Kyc = () => { Investor Eligibilty Notice Please note that Tanami is currently only available to qualifield or accredited investors. Please confirm your status + + {data?.data?.KYC?.questions.map((question, index) => ( @@ -72,6 +74,11 @@ const Kyc = () => { )} + + + + + ) ); diff --git a/src/Services/contact.service.js b/src/Services/contact.service.js index 241c657..465a780 100644 --- a/src/Services/contact.service.js +++ b/src/Services/contact.service.js @@ -29,9 +29,22 @@ export const contact = createApi({ }), invalidatesTags: ["getContact"], }), + + + + + // ========[Update Investment]======= + + sendNotification: builder.mutation({ + query: (data) => ({ + url: `/notification/admin/create`, + method: "POST", + body: data, + }), + }), }), }); // Export hooks for usage in functional components -export const { useGetContactQuery, useUpdateContactMutation } = contact; +export const { useGetContactQuery, useUpdateContactMutation, useSendNotificationMutation } = contact;