import React, { useState } from "react"; import dataImage2 from "../../../assets/images/data-table-user-2.png"; import { useNavigate, useLocation } from "react-router-dom"; import { handlePagingFunc } from "../../Pagination/HandlePagination"; import PaginatedList from "../../Pagination/PaginatedList"; import LoadingSpinner from "../../Spinners/LoadingSpinner"; import Icons from "../../Helpers/Icons"; export default function FamilyTasks({ familyData, className, loader }) { const filterCategories = ["All Categories", "Explore", "Featured"]; const [selectedCategory, setCategory] = useState(filterCategories[0]); let navigate = useNavigate(); let { pathname } = useLocation(); let data = ["1", "2", "3", "4", "5", "6"]; // to be replaced later by result from API CALL 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( indexOfFirstItem, indexOfLastItem ); const handlePagination = (e) => { handlePagingFunc(e, setCurrentPage); }; return (
{loader ? (
) : ( <> {" "} {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] return ( ) })} }
data

{value.title}

Price:{" "} {value.price * 0.01} Duration:{" "} {" "} {value.timeline_days} day(s) Due Date:{" "} {" "} {dueDate}
{/* PAGINATION BUTTON */} = familyData?.result_list.length ? true : false } data={familyData?.result_list} start={indexOfFirstItem} stop={indexOfLastItem} /> {/* END OF PAGINATION BUTTON */}
)} )}
); }