diff --git a/src/components/FamilyAcc/FamilyTable.jsx b/src/components/FamilyAcc/FamilyTable.jsx index a3d6dec..d514c0c 100644 --- a/src/components/FamilyAcc/FamilyTable.jsx +++ b/src/components/FamilyAcc/FamilyTable.jsx @@ -2,19 +2,32 @@ import React, { useState } from "react"; import dataImage1 from "../../assets/images/data-table-user-1.png"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import { useNavigate, useLocation, Link } from "react-router-dom"; +import { handlePagingFunc } from "../Pagination/HandlePagination"; +import PaginatedList from "../Pagination/PaginatedList"; export default function FamilyTable({ className, familyList, loader }) { const filterCategories = ["All Categories", "Explore", "Featured"]; const [selectedCategory, setCategory] = useState(filterCategories[0]); const navigate = useNavigate(); // let location = useLocation(); + + const [currentPage, setCurrentPage] = useState(0); + const indexOfFirstItem = Number(currentPage); + const indexOfLastItem = + Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE); + const currentFamilyList = familyList?.slice(indexOfFirstItem, indexOfLastItem); + + const handlePagination = (e) => { + handlePagingFunc(e, setCurrentPage); + }; + return (
-
+
{loader ? (
@@ -30,10 +43,10 @@ export default function FamilyTable({ className, familyList, loader }) { - + <> {familyList?.length > 0 ? ( - familyList?.map((props, idx) => { + currentFamilyList?.map((props, idx) => { let { firstname, lastname, @@ -115,6 +128,21 @@ export default function FamilyTable({ className, familyList, loader }) { )}
+ {/* PAGINATION BUTTON */} + = + familyList?.length + ? true + : false + } + data={familyList} + start={indexOfFirstItem} + stop={indexOfLastItem} + /> + {/* END OF PAGINATION BUTTON */}
); } diff --git a/src/store/UserDetails.js b/src/store/UserDetails.js index 477f2a3..2738fab 100644 --- a/src/store/UserDetails.js +++ b/src/store/UserDetails.js @@ -8,8 +8,8 @@ export const userSlice = createSlice({ name: "userDetails", initialState, reducers: { - updateUserDetails: (state,payload) => { - state.userDetails = {...payload.payload} + updateUserDetails: (state,action) => { + state.userDetails = {...action.payload} }, }, }); diff --git a/src/store/jobLists.js b/src/store/jobLists.js index 6c07347..282edaa 100644 --- a/src/store/jobLists.js +++ b/src/store/jobLists.js @@ -8,8 +8,8 @@ export const jobSlice = createSlice({ name: "jobLists", initialState, reducers: { - updateJobs: (state, payload) => { - state.jobLists = { ...payload.payload }; + updateJobs: (state, action) => { + state.jobLists = { ...action.payload }; }, }, });