notification fix
This commit is contained in:
@@ -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 <FullscreenLoaders />;
|
||||
}
|
||||
@@ -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: () => <ToastBox message={res?.data?.message} />,
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
setIsLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false)
|
||||
// reset()
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
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": (
|
||||
<Text
|
||||
w={'24px'}
|
||||
justifyContent={"left"}
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
className="d-flex align-items-center fw-bold web-text-small"
|
||||
>
|
||||
{/* {item.id} */}
|
||||
{generateSerialNumber(idx,currentPage, pageSize )}
|
||||
|
||||
{item?.id}
|
||||
</Text>
|
||||
),
|
||||
Date: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{formatDate(item?.date)}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Client ID": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item.clientReference_id}
|
||||
{item?.clientReference_id}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
"First Name": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.principal?.firstName}
|
||||
{item?.firstName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Last Name": (
|
||||
<Box w={"70px"} isTruncated={true}>
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.principal?.lastName}
|
||||
{item?.lastName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Country: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.country?.countryName}
|
||||
{item?.country}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Phone Number": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.principal?.mobileNumber}
|
||||
{item?.phoneNumber}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"E-mail ID": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.principal?.emailAddress}
|
||||
{item?.emailAddress}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Type": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} >
|
||||
<Badge color={"forestGreen.500"} variant={'ghost'} fontWeight={"700"} px={2} py={0.5}>
|
||||
{item?.investor_type?.investorTypeName}
|
||||
</Badge>
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Status: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Badge
|
||||
fontWeight={"700"}
|
||||
textTransform={"none"}
|
||||
colorScheme={item.ioStatus ? "red" : "green"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
>
|
||||
{item.ioStatus ? "Ban" : "Unban"}
|
||||
</Badge>
|
||||
</Box>
|
||||
),
|
||||
"KYC Status": (
|
||||
<Box w={"auto"} display={'flex'} alignItems={'center'} isTruncated={true}>
|
||||
<Text
|
||||
as={'span'}
|
||||
fontWeight={"700"}
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Badge
|
||||
fontWeight={"500"}
|
||||
textTransform={"none"}
|
||||
color={item.ioStatus ? "gray.500":item.kycStatus ? "blue.500" : "red.500"}
|
||||
color={item?.KYCStatus === false ? "red" : "blue"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
variant={'solid'}
|
||||
|
||||
variant={'ghost'}
|
||||
>
|
||||
{item.KYCStatus ? "Completed" : "Not complete"}
|
||||
</Text>
|
||||
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
|
||||
</Badge>
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -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 = () => {
|
||||
<Heading fontSize={"md"} fontWeight={500}>Investor Eligibilty Notice</Heading>
|
||||
<Text fontSize={"sm"}>Please note that Tanami is currently only available to qualifield or accredited investors. Please confirm your status</Text>
|
||||
|
||||
|
||||
|
||||
<RadioGroup value={value}>
|
||||
{data?.data?.KYC?.questions.map((question, index) => (
|
||||
<Radio value={String(index + 1)} isChecked={question?.answers} colorScheme='forestGreen' key={index}>
|
||||
@@ -72,6 +74,11 @@ const Kyc = () => {
|
||||
</Stack>
|
||||
</CheckboxGroup>
|
||||
)}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</Box>
|
||||
</Box>)
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user