commit
This commit is contained in:
@@ -130,9 +130,11 @@ const Investors = ({ data }) => {
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.investors?.filter((item) => {
|
||||
const clientId = item?.clientReference_id;
|
||||
const name = item.firstName;
|
||||
const lastName = item?.lastName
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
const nameMatches = name.toLowerCase().includes(searchLower) || lastName.toLowerCase().includes(searchLower) || clientId.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
|
||||
@@ -61,8 +61,6 @@ const ViewIOTable = () => {
|
||||
const toast = useToast();
|
||||
const { IODetails, setIODetails, slideFromRight } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [statusFilter, setStatusFilter] = useState("all");
|
||||
// const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
@@ -74,11 +72,26 @@ const ViewIOTable = () => {
|
||||
// ===============================[ Paginations ]
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [statusFilter, setStatusFilter] = 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]);
|
||||
|
||||
// ===============================[ RTK Api calls ] =============================================
|
||||
const { data, isLoading, error } = useGetIOsQuery({
|
||||
page: currentPage,
|
||||
size: pageSize,
|
||||
ioStatus_xid: statusFilter,
|
||||
search: debouncedSearchTerm,
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
@@ -114,7 +127,7 @@ const ViewIOTable = () => {
|
||||
return nameMatches && statusMatches;
|
||||
});
|
||||
|
||||
const extractedArray = filteredData?.map((item, idx) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, idx) => ({
|
||||
"Sr No.": (
|
||||
<Text
|
||||
w={"24px"}
|
||||
@@ -377,17 +390,17 @@ const ViewIOTable = () => {
|
||||
cursor={"pointer"}
|
||||
value={statusFilter} // Use the value prop here
|
||||
>
|
||||
<option value="all" selected disabled hidden defaultChecked>
|
||||
<option value="" selected disabled hidden defaultChecked>
|
||||
Status
|
||||
</option>
|
||||
|
||||
<option value="all">All</option>
|
||||
<option value="Draft">Draft</option>
|
||||
<option value="Cancelled">Cancelled</option>
|
||||
<option value="Processing">Processing</option>
|
||||
<option value="Open">Open</option>
|
||||
<option value="Exited">Exited</option>
|
||||
<option value="Closed">Closed</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Draft</option>
|
||||
<option value="6">Cancelled</option>
|
||||
<option value="3">Processing</option>
|
||||
<option value="2">Open</option>
|
||||
<option value="5">Exited</option>
|
||||
<option value="4">Closed</option>
|
||||
</Select>
|
||||
|
||||
<Pagination
|
||||
|
||||
@@ -58,6 +58,10 @@ const InvestorDetails = () => {
|
||||
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(() => {
|
||||
|
||||
@@ -28,7 +28,7 @@ export const ioService = createApi({
|
||||
|
||||
// =====[get]
|
||||
getIOs: builder.query({
|
||||
query: ({ page, size }) => `/io/admin?page=${page}&size=${size}`,
|
||||
query: ({ page, size, ioStatus_xid, search }) => `/io/admin?page=${page}&size=${size}&ioStatus_xid=${ioStatus_xid}&search=${search}`,
|
||||
providesTags: ["getIO"],
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user