diff --git a/src/Components/DataTable/NormalTable.jsx b/src/Components/DataTable/NormalTable.jsx index 83a9b4e..883df72 100644 --- a/src/Components/DataTable/NormalTable.jsx +++ b/src/Components/DataTable/NormalTable.jsx @@ -1,20 +1,50 @@ import React from "react"; -import { Table, TableContainer, Tbody, Td, Th, Thead, Tr, Skeleton, TableCaption, Tfoot } from "@chakra-ui/react"; +import { + Table, + TableContainer, + Tbody, + Td, + Th, + Thead, + Tr, + Skeleton, + TableCaption, + Tfoot, +} from "@chakra-ui/react"; import EmptySearchList from "../EmptySearchList"; -const DataTable = ({ data, isLoading, tableHeadRow, emptyMessage }) => { - const columnWidth = data && data[0] ? `${(100 / Object.keys(data[0]).length).toFixed(2)}%` : "auto"; +const DataTable = ({ + data, + isLoading, + tableHeadRow, + emptyMessage, + centered, +}) => { + const columnWidth = + data && data[0] + ? `${(100 / Object.keys(data[0]).length).toFixed(2)}%` + : "auto"; return ( {data?.length === 0 ? ( ) : ( - - Rubix v1.0.0 - +
+ Tanami v1.0.0 + {tableHeadRow.map((heading, index) => ( - @@ -26,7 +56,16 @@ const DataTable = ({ data, isLoading, tableHeadRow, emptyMessage }) => { ? Array.from({ length: 12 }).map((_, index) => ( {tableHeadRow.map((_, i) => ( - ))} @@ -35,7 +74,20 @@ const DataTable = ({ data, isLoading, tableHeadRow, emptyMessage }) => { : data?.map((item, index) => ( {tableHeadRow.map((heading, i) => ( - ))} diff --git a/src/Components/Pagination.jsx b/src/Components/Pagination.jsx index 3c388b6..6532b1f 100644 --- a/src/Components/Pagination.jsx +++ b/src/Components/Pagination.jsx @@ -2,9 +2,9 @@ import React, { useState } from 'react'; import { Select, HStack, Text, Box, IconButton } from '@chakra-ui/react'; import { ChevronLeftIcon, ChevronRightIcon } from '@chakra-ui/icons'; -const Pagination = ({ totalItems, itemsPerPageOptions = [ 10, 15] }) => { - const [pageSize, setPageSize] = useState(itemsPerPageOptions[0]); - const [currentPage, setCurrentPage] = useState(1); +const Pagination = ({ pageSize, setPageSize, totalItems,isLoading, setCurrentPage, currentPage }) => { + // const [] = useState(itemsPerPageOptions[0]); + const totalPages = Math.ceil(totalItems / pageSize); @@ -34,8 +34,8 @@ const Pagination = ({ totalItems, itemsPerPageOptions = [ 10, 15] }) => { {/* Tanami v0.1 */} - - {/* { value={pageSize} onChange={handlePageSizeChange} > - {itemsPerPageOptions.map((size) => ( + {[ 15, 20, 30]?.map((size) => ( ))} - */} + { className="link pointer" isDisabled={currentPage === 1} /> - - {displayRange.start} - {displayRange.end} of {totalItems} + + {isLoading ? "0": displayRange?.start} - {isLoading ? "00" :displayRange?.end} of {isLoading ? "00":totalItems} { const [mouseEntered, setMouseEntered] = useState(false); const [mouseEnteredId, setMouseEnteredId] = useState(""); - // ===============================[ Paginations ] + // ===============================[ Paginations ] const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size); - const [currentPage, setCurrentPage] = useState(1); + const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page); // ===============================[ RTK Api calls ] const { @@ -288,7 +288,10 @@ const ViewIOTable = () => { - + + + + {/* @@ -246,7 +266,7 @@ const InvestmentType = () => { {/* ======================== [Data Table] ======================= */} - { const navigate = useNavigate(); const toast = useToast(); - // =========================== [Use State] ============================= + + - const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size); const [searchTerm, setSearchTerm] = useState(""); + + + const [isLoading, setIsLoading] = useState(false); const [deleteAlert, setDeleteAlert] = useState(false); const [actionId, setActionId] = useState(false); @@ -40,30 +43,12 @@ const Sponser = () => { const [deleteSponser] = useDeleteSponserMutation(); const { sponser, setSponser, slideFromRight } = useContext(GlobalStateContext); - const {data: sponsors,error,isLoading: isSponserLoading,} = useGetSponserMasterQuery({ page: 1, size: 20 }); + // =========================== [Use State] ============================= + const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size); + const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page); + const {data: sponsors,error,isLoading: isSponserLoading,} = useGetSponserMasterQuery({ page: currentPage, size: pageSize }); - console.log(sponsors?.data?.rows); - - // ========================= [Toggle ToastBox] ========================== - - // const handleUpdateStatus = debounce(async (id) => { - // try { - // await toggleStatus({ id }).then((response) => { - // console.log(response); - // if (response?.data?.statusCode) { - // toast({ - // render: () => , - // }); - // } else { - // toast({ - // render: () => ( - // - // ), - // }); - // } - // }); - // } catch (error) {} - // }, 300); + // console.log(sponsors?.data?.rows); // ==============================[Table Filter]======================== @@ -71,7 +56,6 @@ const Sponser = () => { const name = item.sponsorName; const searchLower = searchTerm?.toLowerCase(); const nameMatches = name?.toLowerCase().includes(searchLower); - return nameMatches; }); @@ -176,6 +160,8 @@ const Sponser = () => { } catch (error) {} }; + console.log(isSponserLoading); + return ( @@ -206,7 +192,7 @@ const Sponser = () => { {/* ====================[Pagination]===================== */} - + {/* =====================[Add Button]===================== */} @@ -218,7 +204,7 @@ const Sponser = () => { fontSize={'xs'} size={"sm"} > - Add + Add Sponsor @@ -227,7 +213,7 @@ const Sponser = () => { {/* =================== [Data Table] ===================== */} - `/investorDetails/admin/${id}`, + providesTags: ["getInvestors"], + }), + }), }); // Export hooks for usage in functional components -export const { useGetInvestorsQuery } = investorDetails; +export const { useGetInvestorsQuery, useGetInvestorsDetailsByIdQuery } = investorDetails; diff --git a/src/Services/io.service.js b/src/Services/io.service.js index 6170c2a..ca28d2b 100644 --- a/src/Services/io.service.js +++ b/src/Services/io.service.js @@ -205,7 +205,7 @@ export const ioService = createApi({ method: "PATCH", body: data, }), - invalidatesTags: ["getIOById"], + invalidatesTags: ["getIOById", 'getIO'], }),
+ {isLoading ? : heading} {/* {heading} */}
+
+ {item[heading]}