update filters
This commit is contained in:
@@ -92,6 +92,9 @@ const ViewIOTable = () => {
|
||||
size: pageSize,
|
||||
ioStatus_xid: statusFilter,
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
|
||||
@@ -77,8 +77,17 @@ const InvestorDetails = () => {
|
||||
error,
|
||||
} = useGetInvestorsQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search userStatus KYCStatus investorType_xid
|
||||
search: debouncedSearchTerm,
|
||||
userStatus: status,
|
||||
KYCStatus: kyc,
|
||||
country_xid: country
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
@@ -108,56 +117,12 @@ const InvestorDetails = () => {
|
||||
"E-mail ID",
|
||||
"Type",
|
||||
"KYC Status",
|
||||
// "Status",
|
||||
"Status",
|
||||
"Action",
|
||||
];
|
||||
|
||||
const handleUpdateStatus = debounce((id) => {
|
||||
setInvestorDetails((prevData) =>
|
||||
prevData.map((InvestorDetails) =>
|
||||
InvestorDetails.id === id ? { ...InvestorDetails } : InvestorDetails
|
||||
)
|
||||
);
|
||||
toast({
|
||||
render: () => <ToastBox message={"Status changed succesfully.!"} />,
|
||||
});
|
||||
}, 300);
|
||||
|
||||
// ====================================================[Table Filter]================================================================
|
||||
const filteredData = investorDetails?.data?.rows?.filter((item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = [item?.principal?.firstName, item?.principal?.lastName, item?.country?.countryName, item?.principal?.mobileNumber, item?.principal?.emailAddress].filter(Boolean).join(' ');
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
|
||||
// Filter by status
|
||||
// const status = item.status;
|
||||
// const statusLower = status ? "active" : "inactive";
|
||||
|
||||
// const statusMatches =
|
||||
// statusFilter === "all" ||
|
||||
// (statusFilter === "active" && status === true) ||
|
||||
// (statusFilter === "inactive" && status === false);
|
||||
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
|
||||
|
||||
const customHeaders = [
|
||||
{ label: "ID", key: "id" },
|
||||
{ label: "Client ID", key: "clientReference_id" },
|
||||
{ label: "First Name", key: "principal.firstName" }, // Nested property
|
||||
{ label: "Last Name", key: "principal.lastName" }, // Nested property
|
||||
{ label: "Country", key: "country.countryName" }, // Nested property
|
||||
{ label: "Phone Number", key: "principal.mobileNumber" }, // Nested property
|
||||
{ label: "E-mail ID", key: "principal.emailAddress" }, // Nested property
|
||||
{ label: "Type", key: "investor_type.investorTypeName" }, // Nested property
|
||||
{ label: "Status", key: "ioStatus" }, // Simple property
|
||||
{ label: "KYC Status", key: "KYCStatus" }, // Simple property
|
||||
];
|
||||
|
||||
|
||||
const exportInvestor = investorDetails?.data?.rows?.map((item, idx) => ({
|
||||
"Id": parseInt(item?.id, 10) || item?.id, // Convert to integer, fallback to string if conversion fails
|
||||
"Client ID": item?.clientReference_id, // This is likely a string
|
||||
@@ -171,10 +136,6 @@ const InvestorDetails = () => {
|
||||
"KYC Status": item.KYCStatus ? "Completed" : "Not complete"
|
||||
}));
|
||||
|
||||
console.log(exportInvestor);
|
||||
|
||||
|
||||
|
||||
const extractedArray = investorDetails?.data?.rows?.map((item, idx) => ({
|
||||
id: item?.id,
|
||||
"Sr No": (
|
||||
@@ -312,14 +273,6 @@ const InvestorDetails = () => {
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const handleEdit = (id) => {
|
||||
setActionId(id);
|
||||
onEditOpen();
|
||||
};
|
||||
|
||||
console.log(investorDetails?.data?.totalItems);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
@@ -351,14 +304,16 @@ const InvestorDetails = () => {
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
value={status}
|
||||
>
|
||||
<option value="all" defaultValue={"all"} disabled hidden>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Status
|
||||
</option>
|
||||
|
||||
<option value="all">Status</option>
|
||||
<option value="ban">Ban</option>
|
||||
<option value="unban">UnBan</option>
|
||||
<option value="">Status</option>
|
||||
<option value="0">Ban</option>
|
||||
<option value="1">UnBan</option>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
@@ -366,13 +321,15 @@ const InvestorDetails = () => {
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setKyc(e.target.value)}
|
||||
value={kyc}
|
||||
>
|
||||
<option value="all" defaultValue={"all"} disabled hidden>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="all">KYC Status</option>
|
||||
<option value="completed">Completed</option>
|
||||
<option value="incompleted">Incompleted</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Incompleted</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
@@ -380,16 +337,19 @@ const InvestorDetails = () => {
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setCountry(e.target.value)}
|
||||
value={country}
|
||||
>
|
||||
<option value="all" defaultValue={"all"} disabled hidden>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Country
|
||||
</option>
|
||||
<option value="all">All</option>
|
||||
<option value="behrain">Behrain</option>
|
||||
<option value="kuwait">Kuwait</option>
|
||||
<option value="oman">Oman</option>
|
||||
<option value="saudi arabia">Saudi arabia</option>
|
||||
<option value="united arab emirates">United arab emirates</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>
|
||||
|
||||
<Pagination
|
||||
|
||||
@@ -13,9 +13,9 @@ export const investorDetails = createApi({
|
||||
endpoints: (builder) => ({
|
||||
|
||||
getInvestors: builder.query({
|
||||
query: ({ page, size, search }) => {
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/investorDetails/admin/?search=${search || ""}`;
|
||||
let baseURL = `/investorDetails/admin/?search=${search || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
|
||||
|
||||
// Conditionally append page and size parameters if they are defined
|
||||
if (page !== undefined && size !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user