From 6cebe90d0dd0dfd6b7ef264524f74c9dc3bf0404 Mon Sep 17 00:00:00 2001 From: "Siddhesh.More" Date: Thu, 1 Aug 2024 13:52:03 +0530 Subject: [PATCH] table update --- src/Components/DataTable/NormalTable.jsx | 51 +++++++++++++++++++ .../Master/ExchangeRate/EditExchangeRate.jsx | 8 +-- .../Master/ExchangeRate/ExchangeRate.jsx | 17 ++----- 3 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 src/Components/DataTable/NormalTable.jsx diff --git a/src/Components/DataTable/NormalTable.jsx b/src/Components/DataTable/NormalTable.jsx new file mode 100644 index 0000000..83a9b4e --- /dev/null +++ b/src/Components/DataTable/NormalTable.jsx @@ -0,0 +1,51 @@ +import React from "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"; + return ( + + {data?.length === 0 ? ( + + ) : ( + + Rubix v1.0.0 + + + {tableHeadRow.map((heading, index) => ( + + ))} + + + + {isLoading + ? Array.from({ length: 12 }).map((_, index) => ( + + {tableHeadRow.map((_, i) => ( + + ))} + + )) + : data?.map((item, index) => ( + + {tableHeadRow.map((heading, i) => ( + + ))} + + ))} + +
+ {isLoading ? : heading} + {/* {heading} */} +
+ +
+ {item[heading]} +
+ )} +
+ ); +}; + +export default DataTable; diff --git a/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx b/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx index f78979c..17a47ac 100644 --- a/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx +++ b/src/Pages/Master/ExchangeRate/EditExchangeRate.jsx @@ -41,7 +41,7 @@ const formatDateValue = (date) => { return [year, month, day].join("-"); }; -const EditExchangeRate = ({ id, setIsLoading, updateHistory }) => { +const EditExchangeRate = ({ id, setIsLoading, updateHistory }) => { const btnRef = useRef(); const toast = useToast(); const { isOpen, onOpen, onClose } = useDisclosure(); @@ -136,13 +136,15 @@ const EditExchangeRate = ({ id, setIsLoading, updateHistory }) => { From - {foundObject?.fromCurrency_xid} + + {foundObject?.fromCurrency?.currencyCode} To - {foundObject?.toCurrency_xid} + + {foundObject?.toCurrency?.currencyCode} diff --git a/src/Pages/Master/ExchangeRate/ExchangeRate.jsx b/src/Pages/Master/ExchangeRate/ExchangeRate.jsx index a8b0aba..979f012 100644 --- a/src/Pages/Master/ExchangeRate/ExchangeRate.jsx +++ b/src/Pages/Master/ExchangeRate/ExchangeRate.jsx @@ -32,6 +32,7 @@ import EditExchangeRate from "./EditExchangeRate"; import ExchangeHistory from "./ExchangeHistroy"; import { useGetAllExchangeRatesQuery } from "../../../Services/exchange.rate.service"; import { TABLE_PAGINATION } from "../../../Constants/Paginations"; +import NormalTable from "../../../Components/DataTable/NormalTable"; const ExchangeRate = () => { const toast = useToast(); @@ -57,15 +58,7 @@ const ExchangeRate = () => { console.log(data?.data); - useEffect(() => { - // Simulate loading - const timer = setTimeout(() => { - setIsLoading(false); - }, 1500); - // Cleanup the timer on component unmount - return () => clearTimeout(timer); - }, []); const updateHistory = (id, previousRate, newRate, effectFrom) => { setHistory((prevHistory) => [ @@ -123,7 +116,7 @@ const ExchangeRate = () => { fontWeight={"600"} className="d-flex align-items-center fw- web-text-small" > - {item.fromCurrency_xid} + {item?.fromCurrency?.currencyCode} ), "To currency": ( @@ -134,7 +127,7 @@ const ExchangeRate = () => { fontWeight={"600"} className="d-flex align-items-center fw- web-text-small" > - {item.toCurrency_xid} + {item?.toCurrency?.currencyCode} ), "Effective from": ( @@ -221,11 +214,11 @@ const ExchangeRate = () => { -