diff --git a/src/pages/employee/EmployeeList.jsx b/src/pages/employee/EmployeeList.jsx index 2cdaa15a..b61abc05 100644 --- a/src/pages/employee/EmployeeList.jsx +++ b/src/pages/employee/EmployeeList.jsx @@ -31,7 +31,7 @@ const EmployeeList = () => { const [employeeList, setEmployeeList] = useState([]); const [modelConfig, setModelConfig] = useState(); const [currentPage, setCurrentPage] = useState(1); - const [itemsPerPage] = useState(10); + const [itemsPerPage] = useState(15); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [searchText, setSearchText] = useState(""); const [filteredData, setFilteredData] = useState([]); diff --git a/src/pages/master/MasterTable.jsx b/src/pages/master/MasterTable.jsx index 305700ef..2341656b 100644 --- a/src/pages/master/MasterTable.jsx +++ b/src/pages/master/MasterTable.jsx @@ -1,25 +1,31 @@ -import React, { useEffect,useState } from "react"; +import React, { useEffect, useState } from "react"; import { useSelector } from "react-redux"; import { useHasUserPermission } from "../../hooks/useHasUserPermission"; -import {MANAGE_MASTER} from "../../utils/constants"; +import { MANAGE_MASTER } from "../../utils/constants"; + +const MasterTable = ({ data, columns, loading, handleModalData }) => { + const hasMasterPermission = useHasUserPermission(MANAGE_MASTER); + const selectedMaster = useSelector( + (store) => store.localVariables.selectedMaster + ); + const hiddenColumns = [ + "id", + "featurePermission", + "tenant", + "tenantId", + "checkLists", + ]; -const MasterTable = ( {data, columns, loading, handleModalData} ) => -{ - const hasMasterPermission = useHasUserPermission(MANAGE_MASTER) - const selectedMaster = useSelector((store)=>store.localVariables.selectedMaster) - const hiddenColumns = [ "id", "featurePermission", "tenant", "tenantId", "checkLists" ]; - const safeData = Array.isArray(data) ? data : []; const [currentPage, setCurrentPage] = useState(1); - const [itemsPerPage] = useState(10); + const [itemsPerPage] = useState(20); const sortKeys = { "Application Role": "role", Activity: "activityName", "Job Role": "name", }; - const sortKey = sortKeys[selectedMaster]; const sortedData = [...safeData].sort((a, b) => { @@ -53,107 +59,132 @@ const MasterTable = ( {data, columns, loading, handleModalData} ) => return (
- {loading ? ( -

Loading...

- ) : ( - - - - - - - - - - - {currentItems.length > 0 ? ( - currentItems.map((item, index) => ( - - - {updatedColumns.map( ( col ) => ( - - ))} - - - )) - ) : ( + {loading ? ( +

Loading...

+ ) : ( +
{selectedMaster === "Activity" ? "Activity":"Name" } {selectedMaster === "Activity" ? "Unit":"Description" }Actions
- {col.key === "description" ? ( - item[col.key] !== undefined && item[col.key] !== null ? ( - item[col.key].length > 80 ? ( - <> - {item[col.key].slice(0, 80)}... - - ) : ( - item[col.key] - ) - ) : ( - " --- " - ) - ) : ( - item[col.key] !== undefined && item[col.key] !== null ? item[col.key] : " --- " - )} - - - - -
+ - + + + + - )} - -
No results found. {selectedMaster === "Activity" ? "Activity" : "Name"} {selectedMaster === "Activity" ? "Unit" : "Description"} + Actions +
- )} + + + {currentItems.length > 0 ? ( + currentItems.map((item, index) => ( + + + + + {updatedColumns.map((col) => ( + + {col.key === "description" ? ( + item[col.key] !== undefined && + item[col.key] !== null ? ( + item[col.key].length > 80 ? ( + <>{item[col.key].slice(0, 80)}... + ) : ( + item[col.key] + ) + ) : ( + " --- " + ) + ) : item[col.key] !== undefined && + item[col.key] !== null ? ( + item[col.key] + ) : ( + " --- " + )} + + ))} + + - {/* Pagination */} - {!loading && ( -
+ {[...Array(totalPages)].map((_, index) => ( +
  • + +
  • + ))} +
  • + +
  • + + + )} + ); };