import { useState } from "react"; import dataImage1 from "../../assets/images/data-table-user-1.png"; import PaginatedList from "../Pagination/PaginatedList"; import { handlePagingFunc } from "../Pagination/HandlePagination"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import { useNavigate, useLocation } from "react-router-dom"; import { PriceFormatter } from "../Helpers/PriceFormatter"; const noTasksBg = require("../../assets/images/no-task-background.jpg"); export default function MyJobTable({ className, ActiveJobList }) { let navigate = useNavigate(); let { 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 = ActiveJobList?.data?.slice( indexOfFirstItem, indexOfLastItem ); const handlePagination = (e) => { handlePagingFunc(e, setCurrentPage); }; // To navigate to task const [btnLoader, setBtnLoader] = useState(false); const navigateMarket = () => { setBtnLoader(true); setTimeout(() => { navigate("/market", { replace: true }); setBtnLoader(false); }, 2500); }; return (
{/* Adding this dark overlay in order to see the texts properly */} {!ActiveJobList?.data.length && (
)} {ActiveJobList?.data.length > 0 && ActiveJobList.loading && (
)}
{ActiveJobList?.data?.length > 0 && currentTask?.map((task, idx) => { let thePrice = PriceFormatter( task?.price * 0.01, task?.currency_code, task?.currency ); return (
data

{task?.title}

{task?.description} Price: {thePrice}
Duration: {Number(task?.timeline_days) === 1 ? `${task?.timeline_days} day` : `${task?.timeline_days} day(s)`} Due Date: {task?.delivery_date} Confirmation: {task?.contract}
); })} {ActiveJobList?.data?.length <= 0 && (
You currently have "0" task
)} {ActiveJobList?.internal_return < 0 && (

Error Occurred! Unable to display Tasks!

)}
{/* PAGINATION BUTTON */} = ActiveJobList?.data?.length ? true : false } data={ActiveJobList?.data} start={indexOfFirstItem} stop={indexOfLastItem} /> {/* END OF PAGINATION BUTTON */}
); }