From 2d75ccdb39a1d6654d1b5863d5a7ff64c35e7143 Mon Sep 17 00:00:00 2001 From: Hemant Vishwakarma Date: Fri, 27 Sep 2024 13:23:25 +0530 Subject: [PATCH] table add --- src/Components/DataTable/NormalTable.jsx | 68 +++++--- .../OptiFiiExpense/AdvanceExpenseRequest.jsx | 157 +++++++++++++++++- 2 files changed, 196 insertions(+), 29 deletions(-) diff --git a/src/Components/DataTable/NormalTable.jsx b/src/Components/DataTable/NormalTable.jsx index 4456794..86c90aa 100644 --- a/src/Components/DataTable/NormalTable.jsx +++ b/src/Components/DataTable/NormalTable.jsx @@ -9,30 +9,36 @@ import { Tr, Skeleton, TableCaption, - Tfoot, + Radio, + RadioGroup, + CheckboxGroup, + Checkbox, } from "@chakra-ui/react"; import EmptySearchList from "../EmptySearchList"; import { TABLE_PAGINATION } from "../../Constants/Paginations"; -const DataTable = ({ +const NormalTable = ({ data, isLoading, tableHeadRow, emptyMessage, centered, total, + showRadioButton, // New prop for showing the radio button + selectedRadio, + setSelectedRadio, // State for managing radio button selection }) => { - console.log(data); - const columnWidth = data && data[0] ? `${(100 / Object.keys(data[0]).length).toFixed(2)}%` : "auto"; + + const handleRadioChange = (value) => { + setSelectedRadio(value); + }; + return ( - + {data?.length === 0 ? ( ) : ( @@ -40,15 +46,11 @@ const DataTable = ({ {total ? total : "OptiFii v1.0.0"} - + {tableHeadRow.map((heading, index) => ( - {isLoading ? : heading} - {/* {heading} */} + {/* Conditionally render radio button in the heading */} + {showRadioButton && heading === "Select" ? ( + + {/* Disabled radio button in header */} + + ) : ( + isLoading ? : heading + )} ))} @@ -76,15 +82,12 @@ const DataTable = ({ {tableHeadRow.map((_, i) => ( @@ -93,7 +96,10 @@ const DataTable = ({ ) ) : data?.map((item, index) => ( - + {tableHeadRow.map((heading, i) => ( - {item[heading]} + {/* Conditionally render radio button in the table body */} + {showRadioButton && heading === "Select" ? ( + + {/* Dynamic radio buttons */} + + ) : ( + item[heading] + )} ))} @@ -122,4 +138,4 @@ const DataTable = ({ ); }; -export default DataTable; +export default NormalTable; \ No newline at end of file diff --git a/src/Pages/OptiFiiExpense/AdvanceExpenseRequest.jsx b/src/Pages/OptiFiiExpense/AdvanceExpenseRequest.jsx index b6bc504..29d456b 100644 --- a/src/Pages/OptiFiiExpense/AdvanceExpenseRequest.jsx +++ b/src/Pages/OptiFiiExpense/AdvanceExpenseRequest.jsx @@ -1,17 +1,168 @@ -import { Box } from "@chakra-ui/react"; import React from "react"; +import { + Table, + TableContainer, + Tbody, + Td, + Th, + Thead, + Tr, + Skeleton, + TableCaption, + Radio, + RadioGroup, + CheckboxGroup, + Checkbox, + Box, Text +} from "@chakra-ui/react"; +import { TABLE_PAGINATION } from "../../Constants/Paginations"; +import EmptySearchList from "../../Components/EmptySearchList"; import MiniHeader from "../../Components/MiniHeader"; -const AdvanceExpenseRequest = () => { + +const AdvanceExpenseRequest = ({ + data, + isLoading, + // tableHeadRow, + emptyMessage, + centered, + total, + showRadioButton, // New prop for showing the radio button + selectedRadio, + setSelectedRadio, // State for managing radio button selection +}) => { + const columnWidth = + data && data[0] + ? `${(100 / Object.keys(data[0]).length).toFixed(2)}%` + : "auto"; + + const handleRadioChange = (value) => { + setSelectedRadio(value); + }; + + // ===============================[ Table Header ] + const tableHeadRow = [ + "Sr. no", + "Report name", + "Report by", + "Report amount", + "Date & time", + "Order Status", + "Approver", + "Disburser", + ]; + + + return ( + + + + + {data?.length === 0 ? ( + + ) : ( + + + {total ? total : "OptiFii v1.0.0"} + + + + {tableHeadRow.map((heading, index) => ( + + ))} + + + + {isLoading + ? Array.from({ length: TABLE_PAGINATION?.size }).map( + (_, index) => ( + + {tableHeadRow.map((_, i) => ( + + ))} + + ) + ) + : data?.map((item, index) => ( + + {tableHeadRow.map((heading, i) => ( + + ))} + + ))} + +
+ {/* Conditionally render radio button in the heading */} + {showRadioButton && heading === "Select" ? ( + + {/* Disabled radio button in header */} + + ) : ( + isLoading ? : heading + )} +
+ +
+ {/* Conditionally render radio button in the table body */} + {showRadioButton && heading === "Select" ? ( + + {/* Dynamic radio buttons */} + + ) : ( + item[heading] + )} +
+ )} +
); }; -export default AdvanceExpenseRequest; +export default AdvanceExpenseRequest; \ No newline at end of file