From cc66ebbbde0cbb4104c5a22755fbbd05fdcaf405 Mon Sep 17 00:00:00 2001 From: Ebube Date: Wed, 5 Jul 2023 13:51:10 +0100 Subject: [PATCH] Family waitlist complete --- .../FamilyAcc/Tabs/FamilyWaitlist.jsx | 142 ++++++++---------- 1 file changed, 59 insertions(+), 83 deletions(-) diff --git a/src/components/FamilyAcc/Tabs/FamilyWaitlist.jsx b/src/components/FamilyAcc/Tabs/FamilyWaitlist.jsx index 6ba062d..e46f0af 100644 --- a/src/components/FamilyAcc/Tabs/FamilyWaitlist.jsx +++ b/src/components/FamilyAcc/Tabs/FamilyWaitlist.jsx @@ -4,22 +4,20 @@ import { handlePagingFunc, PaginatedList } from "../../Pagination"; import LoadingSpinner from "../../Spinners/LoadingSpinner"; const FamilyWaitlist = ({ familyData, className, loader }) => { - let navigate = useNavigate(); - let { pathname } = useLocation(); + const navigate = useNavigate(); + const { pathname } = useLocation(); const [currentPage, setCurrentPage] = useState(0); - const indexOfFirstItem = Number(currentPage); - const indexOfLastItem = - Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE); - const currentTask = familyData?.result_list.slice( + const itemsPerPage = Number(process.env.REACT_APP_ITEM_PER_PAGE); + const indexOfFirstItem = currentPage; + const indexOfLastItem = currentPage + itemsPerPage; + const currentTask = familyData?.result_list?.slice( indexOfFirstItem, indexOfLastItem ); const handlePagination = (e) => handlePagingFunc(e, setCurrentPage); - console.log("I am in family waitlist", familyData); - return (
{
) : ( <> - {familyData && familyData?.result_list && ( + {familyData && familyData.result_list && (
- { - <> - {familyData && - familyData?.result_list && - familyData.result_list.length > 0 && - currentTask.map((value, index) => { - // find due date - // const dueDate = value?.delivery_date.split(" ")[0]; - // the price - // let thePrice = PriceFormatter( - // value?.price * 0.01, - // value?.currency_code, - // value?.currency - // ); - return ( - - - - - - - ); - })} - - } + {currentTask.map((value) => { + const addedDate = value?.added.split(" ")[0]; + const taskImg = require(`../../../assets/images/family/${ + value?.banner || "default.jpg" + }`); + return ( + + + + + ); + })}
-
-
- data -
-
-
-
-

- {/* {value.title} */} - title -

-
- desd -
-
-
- Date - Status - - -
+
+
+
+ task_img +
+
+

+ {value.title} +

+

+ {value.description} +

+
+
+
+

+ {addedDate} +

+

+ Status: {value.status} +

+
+
+
+ +
- {/* PAGINATION BUTTON */} = - familyData?.result_list.length - ? true - : false + currentPage + itemsPerPage >= familyData?.result_list.length } data={familyData?.result_list} start={indexOfFirstItem} stop={indexOfLastItem} /> - {/* END OF PAGINATION BUTTON */}
)}