Merge pull request 'added checklist in Activity master' (#18) from pramod_Tas#53_Activity into Feature_Task_Management
Reviewed-on: #18
This commit is contained in:
commit
a243119396
@ -7,28 +7,48 @@ 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 indexOfLastItem = currentPage * itemsPerPage;
|
||||
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
|
||||
const currentItems = safeData.slice( indexOfFirstItem, indexOfLastItem );
|
||||
const hiddenColumns = [ "id", "featurePermission", "tenant", "tenantId", "checkLists" ];
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPage(1);
|
||||
}, [ safeData ] )
|
||||
|
||||
const paginate = (pageNumber) => setCurrentPage(pageNumber);
|
||||
const totalPages = Math.ceil(safeData.length / itemsPerPage);
|
||||
const safeData = Array.isArray(data) ? data : [];
|
||||
|
||||
const updatedColumns = columns
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [itemsPerPage] = useState(10);
|
||||
|
||||
const sortKeys = {
|
||||
"Application Role": "role",
|
||||
Activity: "activityName",
|
||||
"Job Role": "name",
|
||||
};
|
||||
|
||||
|
||||
const sortKey = sortKeys[selectedMaster];
|
||||
const sortedData = [...safeData].sort((a, b) => {
|
||||
if (!sortKey) return 0;
|
||||
const aValue = a[sortKey] || "";
|
||||
const bValue = b[sortKey] || "";
|
||||
return aValue.localeCompare(bValue);
|
||||
});
|
||||
|
||||
// Pagination logic
|
||||
const indexOfLastItem = currentPage * itemsPerPage;
|
||||
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
|
||||
const currentItems = sortedData.slice(indexOfFirstItem, indexOfLastItem);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPage(1);
|
||||
}, [safeData]);
|
||||
|
||||
const paginate = (pageNumber) => setCurrentPage(pageNumber);
|
||||
const totalPages = Math.ceil(safeData.length / itemsPerPage);
|
||||
|
||||
const updatedColumns = columns
|
||||
.filter((col) => !hiddenColumns.includes(col.key))
|
||||
.map((col) => ({
|
||||
...col,
|
||||
label:
|
||||
col.key === "role" || col.key === "activityName" || col.key === "status" ? "Name" : col.label,
|
||||
col.key === "role" || col.key === "activityName" || col.key === "name"
|
||||
? "Name"
|
||||
: col.label,
|
||||
}));
|
||||
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user