Risky Update ⚠️
This commit is contained in:
@@ -18,13 +18,13 @@ import CustomAlertDialog from "../../Components/CustomAlertDialog";
|
||||
import { formatDate } from "../../Components/Functions/UTCConvertor";
|
||||
import { CheckIcon, CloseIcon } from "@chakra-ui/icons";
|
||||
import { useGetDeleteHistoryQuery } from "../../Services/delete.request.service";
|
||||
import { TABLE_PAGINATION } from "../../Constants/Paginations";
|
||||
// import { formatDate } from "../../Components/Functions/UTCConvertor";
|
||||
|
||||
const DeletionHistory = () => {
|
||||
const toast = useToast();
|
||||
const { slideFromRight, setDeleteHistory } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
@@ -32,11 +32,35 @@ const DeletionHistory = () => {
|
||||
|
||||
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
|
||||
const {
|
||||
data: deleteHistory,
|
||||
isLoading,
|
||||
refetch
|
||||
} = useGetDeleteHistoryQuery()
|
||||
} = useGetDeleteHistoryQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
})
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString('en-GB', {
|
||||
@@ -51,19 +75,7 @@ const DeletionHistory = () => {
|
||||
refetch();
|
||||
}, [refetch]);
|
||||
|
||||
// console.log(deleteHistory?.data);
|
||||
|
||||
// ====================================================[Table Filter]================================================================
|
||||
const filteredData = deleteHistory?.data?.rows?.filter((item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item?.country;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
console.log(deleteHistory);
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
@@ -76,7 +88,7 @@ const DeletionHistory = () => {
|
||||
"Status"
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
const extractedArray = deleteHistory?.data?.rows?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text
|
||||
|
||||
@@ -21,6 +21,7 @@ import Pagination from "../../../../Components/Pagination";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import ReasonBanModal from "./ReasonBanModal";
|
||||
import { useGetbanInvestorQuery } from "../../../../Services/ban.investor.service";
|
||||
import { TABLE_PAGINATION } from "../../../../Constants/Paginations";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
@@ -30,18 +31,12 @@ const BankInvestor = () => {
|
||||
const thirdField = useRef();
|
||||
const { bankInvestor, setBankInvestor, slideFromRight } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const {
|
||||
isOpen: isOpen,
|
||||
onOpen: onOpen,
|
||||
onClose: onClose,
|
||||
} = useDisclosure();
|
||||
|
||||
const { isOpen: isOpen, onOpen: onOpen, onClose: onClose } = useDisclosure();
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
@@ -51,15 +46,43 @@ const BankInvestor = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
const [status, setStatus] = useState("");
|
||||
const [kyc, setKyc] = useState("");
|
||||
const [country, setCountry] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
console.log(localStorage.getItem("refreshToken"));
|
||||
const {
|
||||
data,
|
||||
isLoading: unbanLoading,
|
||||
error,
|
||||
refetch
|
||||
} = useGetbanInvestorQuery();
|
||||
|
||||
refetch,
|
||||
} = useGetbanInvestorQuery(
|
||||
{
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
KYCStatus: kyc,
|
||||
country_xid: country,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
@@ -115,10 +138,7 @@ const BankInvestor = () => {
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
|
||||
console.log(filteredData);
|
||||
|
||||
const extractedArray = filteredData?.map((item) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item) => ({
|
||||
id: item?.id,
|
||||
"Sr N/O": (
|
||||
<Text
|
||||
@@ -130,81 +150,82 @@ const BankInvestor = () => {
|
||||
{item.id}
|
||||
</Text>
|
||||
),
|
||||
"Date": (
|
||||
Date: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{formatDate(item?.date)}
|
||||
{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>
|
||||
),
|
||||
"First Name": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.firstName}
|
||||
{item?.firstName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Last Name": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.lastName}
|
||||
{item?.lastName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Country: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.country}
|
||||
{item?.country}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Phone Number": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.phoneNumber}
|
||||
{item?.phoneNumber}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"E-mail ID": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item?.emailAddress}
|
||||
{item?.emailAddress}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"KYC Status": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Badge
|
||||
fontWeight={"500"}
|
||||
textTransform={"none"}
|
||||
color={item?.KYCStatus === false ? "red" : "blue"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
variant={'ghost'}
|
||||
>
|
||||
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
|
||||
</Badge>
|
||||
<Badge
|
||||
fontWeight={"500"}
|
||||
textTransform={"none"}
|
||||
color={item?.KYCStatus === false ? "red" : "blue"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
variant={"ghost"}
|
||||
>
|
||||
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
|
||||
</Badge>
|
||||
</Box>
|
||||
),
|
||||
Action: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Badge
|
||||
cursor={"pointer"}
|
||||
cursor={"pointer"}
|
||||
fontWeight={"500"}
|
||||
textTransform={"none"}
|
||||
colorScheme={"red"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
onClick={()=>{
|
||||
setActionId(item?.id)
|
||||
onOpen()}}
|
||||
onClick={() => {
|
||||
setActionId(item?.id);
|
||||
onOpen();
|
||||
}}
|
||||
>
|
||||
Ban Investor
|
||||
</Badge>
|
||||
@@ -212,6 +233,8 @@ const BankInvestor = () => {
|
||||
),
|
||||
}));
|
||||
|
||||
console.log(extractedArray);
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedInvestorDetails = InvestorDetails.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
@@ -253,32 +276,59 @@ const BankInvestor = () => {
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
{/* <Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
value={status}
|
||||
>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Status
|
||||
</option>
|
||||
|
||||
<option value="">Status</option>
|
||||
<option value="0">Ban</option>
|
||||
<option value="1">UnBan</option>
|
||||
</Select> */}
|
||||
|
||||
<Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
placeholder='KYC Status'
|
||||
w={180}
|
||||
rounded={"md"}
|
||||
onChange={(e) => setKyc(e.target.value)}
|
||||
value={kyc}
|
||||
>
|
||||
<option value="all">All</option>
|
||||
<option value="ban">Ban</option>
|
||||
<option value="unban">UnBan</option>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Incompleted</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
placeholder='Country'
|
||||
w={180}
|
||||
rounded={"md"}
|
||||
onChange={(e) => setCountry(e.target.value)}
|
||||
value={country}
|
||||
>
|
||||
<option value="all">All</option>
|
||||
<option value="ban">Ban</option>
|
||||
<option value="unban">UnBan</option>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Country
|
||||
</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Behrain</option>
|
||||
<option value="2">Kuwait</option>
|
||||
<option value="3">Oman</option>
|
||||
<option value="4">Qatar</option>
|
||||
<option value="5">Saudi arabia</option>
|
||||
<option value="6">United arab emirates</option>
|
||||
</Select>
|
||||
</HStack>
|
||||
</HStack>
|
||||
@@ -302,11 +352,7 @@ const BankInvestor = () => {
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
<ReasonBanModal
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
id={actionId}
|
||||
/>
|
||||
<ReasonBanModal isOpen={isOpen} onClose={onClose} id={actionId} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -41,20 +41,6 @@ const UnbanInvestor = () => {
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const { isOpen: isOpen, onOpen: onOpen, onClose: onClose } = useDisclosure();
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
@@ -64,19 +50,43 @@ const UnbanInvestor = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
const [status, setStatus] = useState("");
|
||||
const [kyc, setKyc] = useState("");
|
||||
const [country, setCountry] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
const {
|
||||
data,
|
||||
isLoading: unbanLoading,
|
||||
error,
|
||||
refetch,
|
||||
} = useGetUnbanInvestorQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
} = useGetUnbanInvestorQuery(
|
||||
{
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
KYCStatus: kyc,
|
||||
country_xid: country,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
@@ -132,7 +142,7 @@ const UnbanInvestor = () => {
|
||||
color={"gray.600"}
|
||||
className="d-flex align-items-center fw-bold web-text-small"
|
||||
>
|
||||
{generateSerialNumber(index,currentPage, pageSize )}
|
||||
{generateSerialNumber(index, currentPage, pageSize)}
|
||||
</Text>
|
||||
),
|
||||
Date: (
|
||||
@@ -192,7 +202,7 @@ const UnbanInvestor = () => {
|
||||
color={item?.KYCStatus === false ? "red" : "blue"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
variant={'ghost'}
|
||||
variant={"ghost"}
|
||||
>
|
||||
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
|
||||
</Badge>
|
||||
@@ -207,9 +217,9 @@ const UnbanInvestor = () => {
|
||||
colorScheme={"red"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
onClick={()=>{
|
||||
setActionId(item?.id)
|
||||
onOpen()
|
||||
onClick={() => {
|
||||
setActionId(item?.id);
|
||||
onOpen();
|
||||
}}
|
||||
>
|
||||
Ban Investor
|
||||
@@ -260,31 +270,57 @@ const UnbanInvestor = () => {
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
{/* <Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
value={status}
|
||||
>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Status
|
||||
</option>
|
||||
|
||||
<option value="">Status</option>
|
||||
<option value="0">Ban</option>
|
||||
<option value="1">UnBan</option>
|
||||
</Select> */}
|
||||
|
||||
<Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
placeholder="KYC Status"
|
||||
w={180}
|
||||
rounded={"md"}
|
||||
onChange={(e) => setKyc(e.target.value)}
|
||||
value={kyc}
|
||||
>
|
||||
<option value="all">All</option>
|
||||
<option value="ban">Ban</option>
|
||||
<option value="unban">UnBan</option>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Incompleted</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
placeholder="Country"
|
||||
w={180}
|
||||
rounded={"md"}
|
||||
onChange={(e) => setCountry(e.target.value)}
|
||||
value={country}
|
||||
>
|
||||
<option value="all">All</option>
|
||||
<option value="ban">Ban</option>
|
||||
<option value="unban">UnBan</option>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Country
|
||||
</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Behrain</option>
|
||||
<option value="2">Kuwait</option>
|
||||
<option value="3">Oman</option>
|
||||
<option value="4">Qatar</option>
|
||||
<option value="5">Saudi arabia</option>
|
||||
<option value="6">United arab emirates</option>
|
||||
</Select>
|
||||
</HStack>
|
||||
</HStack>
|
||||
|
||||
@@ -47,7 +47,6 @@ const DepositRequest = () => {
|
||||
const toast = useToast();
|
||||
const { depositRequest, setDepositRequest, slideFromRight } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState("");
|
||||
@@ -63,9 +62,25 @@ const DepositRequest = () => {
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
@@ -80,7 +95,14 @@ const DepositRequest = () => {
|
||||
isLoading: depositRequestLoading,
|
||||
error,
|
||||
refetch,
|
||||
} = useGetDepositRequestQuery({ page: currentPage, size: pageSize });
|
||||
} = useGetDepositRequestQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
|
||||
// Use useEffect to refetch data when the component mounts
|
||||
useEffect(() => {
|
||||
@@ -135,7 +157,7 @@ const DepositRequest = () => {
|
||||
})
|
||||
.sort((b, a) => new Date(a.createdAt) - new Date(b.createdAt));
|
||||
|
||||
const extractedArray = filteredData?.map((item, idx) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, idx) => ({
|
||||
// id: item?.id,
|
||||
"Sr.no": (
|
||||
<Text
|
||||
|
||||
@@ -45,7 +45,6 @@ const DepositHistory = () => {
|
||||
const toast = useToast();
|
||||
const { depositHistory, setDepositHistory, slideFromRight } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
@@ -62,15 +61,36 @@ const DepositHistory = () => {
|
||||
// onClose: onRejectClose,
|
||||
// } = useDisclosure();
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
|
||||
const {
|
||||
data,
|
||||
error,
|
||||
refetch,
|
||||
isLoading: depositHistoryLoading,
|
||||
} = useGetDepositHistoryQuery({ page: currentPage, size: pageSize });
|
||||
} = useGetDepositHistoryQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
|
||||
// Use useEffect to refetch data when the component mounts
|
||||
useEffect(() => {
|
||||
@@ -131,7 +151,7 @@ const DepositHistory = () => {
|
||||
// onViewOpen();
|
||||
// };
|
||||
|
||||
const extractedArray = filteredData?.map((item, idx) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, idx) => ({
|
||||
"Sr.no": (
|
||||
<Text
|
||||
w={"10px"}
|
||||
|
||||
@@ -42,9 +42,6 @@ import { exportToExcel, generateSerialNumber } from "../../Constants/Constants";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const FawateerRequest = () => {
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
@@ -137,7 +137,7 @@ import {
|
||||
"Status",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, idx) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, idx) => ({
|
||||
|
||||
// id: item?.id,
|
||||
"Sr.no": (
|
||||
|
||||
@@ -29,15 +29,12 @@ const PendingRequest = () => {
|
||||
const toast = useToast();
|
||||
const { slideFromRight, pendingRequest, setPendingRequest } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString('en-GB', {
|
||||
@@ -58,12 +55,41 @@ const PendingRequest = () => {
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
|
||||
|
||||
const {
|
||||
data,
|
||||
isLoading: drawalRequestLoading,
|
||||
error,
|
||||
refetch
|
||||
} = useGetDrawalRequestQuery({ page: currentPage, size: pageSize });
|
||||
} = useGetDrawalRequestQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -122,7 +148,7 @@ const PendingRequest = () => {
|
||||
|
||||
|
||||
|
||||
const extractedArray = filteredData?.map((item, idx) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, idx) => ({
|
||||
// id: item?.id,
|
||||
"Sr.no": (
|
||||
<Text
|
||||
|
||||
@@ -30,7 +30,6 @@ const ViewHistory = () => {
|
||||
const toast = useToast();
|
||||
const { slideFromRight, viewHistory, setViewHistory } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
@@ -56,15 +55,39 @@ const ViewHistory = () => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm);
|
||||
}, 500); // Adjust delay as needed
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
}, [searchTerm]);
|
||||
|
||||
|
||||
const {
|
||||
data,
|
||||
error,
|
||||
isLoading: drawalHistoryLoading,
|
||||
refetch
|
||||
} = useGetDrawalHistoryQuery({ page: currentPage, size: pageSize });
|
||||
} = useGetDrawalHistoryQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
|
||||
|
||||
// Use useEffect to refetch data when the component mounts
|
||||
|
||||
@@ -20,18 +20,18 @@ export const banInvestorDetails = createApi({
|
||||
|
||||
|
||||
getUnbanInvestor: builder.query({
|
||||
query: ({ page, size, search, kycStatus, country }) => {
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/investorDetails/admin/getAllUnbanned?search=${search || ""}`;
|
||||
let baseURL = `/investorDetails/admin/getAllUnbanned?search=${search || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
|
||||
|
||||
// Conditionally append kycStatus if it's defined
|
||||
if (kycStatus) {
|
||||
baseURL += `&kycStatus=${kycStatus}`;
|
||||
if (KYCStatus) {
|
||||
baseURL += `&KYCStatus=${KYCStatus}`;
|
||||
}
|
||||
|
||||
// Conditionally append country if it's defined
|
||||
if (country) {
|
||||
baseURL += `&country=${country}`;
|
||||
if (country_xid) {
|
||||
baseURL += `&country_xid=${country_xid}`;
|
||||
}
|
||||
|
||||
// Conditionally append page and size parameters if they are defined
|
||||
@@ -41,13 +41,33 @@ export const banInvestorDetails = createApi({
|
||||
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getBanInvestor"],
|
||||
providesTags: ["getUnbanInvestor"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
getbanInvestor: builder.query({
|
||||
query: () => `/investorDetails/admin/getAllBanned`,
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/investorDetails/admin/getAllBanned?search=${search || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
|
||||
|
||||
// Conditionally append kycStatus if it's defined
|
||||
if (KYCStatus) {
|
||||
baseURL += `&KYCStatus=${KYCStatus}`;
|
||||
}
|
||||
|
||||
// Conditionally append country if it's defined
|
||||
if (country_xid) {
|
||||
baseURL += `&country_xid=${country_xid}`;
|
||||
}
|
||||
|
||||
// Conditionally append page and size parameters if they are defined
|
||||
if (page !== undefined && size !== undefined) {
|
||||
baseURL += `&page=${page}&size=${size}`;
|
||||
}
|
||||
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getBanInvestor"],
|
||||
}),
|
||||
|
||||
|
||||
@@ -41,8 +41,14 @@ export const deleteRequest = createApi({
|
||||
}),
|
||||
|
||||
getDeleteHistory: builder.query({
|
||||
query: () => `/account/admin/history`,
|
||||
providesTags: ["getDeleteHistory"],
|
||||
query: ({ page, size, search }) => {
|
||||
let baseURL = `/account/admin/history?search=${search || ""}`;
|
||||
if (page !== undefined && size !== undefined) {
|
||||
baseURL += `&page=${page}&size=${size}`; // Only add pagination if both are defined
|
||||
}
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getDrawalRequest"],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -11,10 +11,30 @@ export const depositRequest = createApi({
|
||||
baseQuery: baseQuery,
|
||||
tagTypes: ["getDepositRequest", "getDepositHistory"],
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
|
||||
|
||||
getDepositRequest: builder.query({
|
||||
query: ({page, size}) => `/deposit/admin/pending-requests?page=${page}&size=${size}`,
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/deposit/admin/pending-requests?search=${search || ""}`;
|
||||
|
||||
// Conditionally append page and size parameters if they are defined
|
||||
if (page !== undefined && size !== undefined) {
|
||||
baseURL += `&page=${page}&size=${size}`;
|
||||
}
|
||||
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getDepositRequest"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
getDepositRequestById: builder.query({
|
||||
query: (id) => `/deposit/admin/getById/${id}`,
|
||||
@@ -38,10 +58,30 @@ export const depositRequest = createApi({
|
||||
invalidatesTags: ["getDepositRequest", "getDepositHistory"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
getDepositHistory: builder.query({
|
||||
query: ({page, size}) => `/deposit/admin/history?page=${page}&size=${size}`,
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/deposit/admin/history?search=${search || ""}`;
|
||||
|
||||
// Conditionally append page and size parameters if they are defined
|
||||
if (page !== undefined && size !== undefined) {
|
||||
baseURL += `&page=${page}&size=${size}`;
|
||||
}
|
||||
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getDepositHistory"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,17 @@ export const drawalRequest = createApi({
|
||||
tagTypes: ["getDrawalRequest", "getDepositHistory"],
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
|
||||
|
||||
getDrawalRequest: builder.query({
|
||||
query: () => `/withdrawal/admin`,
|
||||
query: ({ page, size, search }) => {
|
||||
let baseURL = `/withdrawal/admin?search=${search || ""}`;
|
||||
if (page !== undefined && size !== undefined) {
|
||||
baseURL += `&page=${page}&size=${size}`; // Only add pagination if both are defined
|
||||
}
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getDrawalRequest"],
|
||||
}),
|
||||
|
||||
@@ -39,10 +48,23 @@ export const drawalRequest = createApi({
|
||||
invalidatesTags: ["getDepositRequest", "getDepositHistory"],
|
||||
}),
|
||||
|
||||
|
||||
getDrawalHistory: builder.query({
|
||||
query: () => `/withdrawal/admin/history`,
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/withdrawal/admin/history?search=${search || ""}`;
|
||||
|
||||
// Conditionally append page and size parameters if they are defined
|
||||
if (page !== undefined && size !== undefined) {
|
||||
baseURL += `&page=${page}&size=${size}`;
|
||||
}
|
||||
|
||||
return baseURL;
|
||||
},
|
||||
providesTags: ["getDepositHistory"],
|
||||
}),
|
||||
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ export const investorDetails = createApi({
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// =====[get investment details ]
|
||||
getInvestorsDetailsById: builder.query({
|
||||
query: (id) => `/investorDetails/admin/byId/${id}`,
|
||||
|
||||
Reference in New Issue
Block a user