import React, { useEffect,useState } from "react"; import { useSelector } from "react-redux"; const MasterTable = ({ data, columns, loading, handleModalData }) => { const selectedMaster = useSelector((store)=>store.localVariables.selectedMaster) const hiddenColumns = ["id", "featurePermission"]; const [currentPage, setCurrentPage] = useState(1); const [itemsPerPage] = useState(10); const indexOfLastItem = currentPage * itemsPerPage; const indexOfFirstItem = indexOfLastItem - itemsPerPage; const currentItems = data.slice(indexOfFirstItem, indexOfLastItem); const paginate = (pageNumber) => setCurrentPage(pageNumber); const totalPages = Math.ceil(data.length / itemsPerPage); const updatedColumns = columns .filter((col) => !hiddenColumns.includes(col.key)) .map((col) => ({ ...col, label: col.key === "role" || "module" || "status" ? "Name" : col.label, })); return (
{loading ? (

Loading...

) : ( {/* {updatedColumns.map((col) => ( ))} */} {currentItems.length > 0 ? ( currentItems.map((item, index) => ( {updatedColumns.map((col) => ( ))} )) ) : ( )}
{col.label} Name Description Actions
{item[col.key] || " --- "}
No results found.
)} {/* Pagination */} { !loading && ( ) }
); }; export default MasterTable;