From a9d982386ce6e6f28c286aaf3f1fe08a715f897d Mon Sep 17 00:00:00 2001 From: Ebube Date: Sun, 18 Jun 2023 22:46:42 +0100 Subject: [PATCH] . --- src/components/MyJobs/MyJobTable.jsx | 187 ++++++++++++++++----------- src/components/MyJobs/index.jsx | 3 + src/views/MyJobsPage.jsx | 5 +- 3 files changed, 118 insertions(+), 77 deletions(-) diff --git a/src/components/MyJobs/MyJobTable.jsx b/src/components/MyJobs/MyJobTable.jsx index be596aa..9ea5b11 100644 --- a/src/components/MyJobs/MyJobTable.jsx +++ b/src/components/MyJobs/MyJobTable.jsx @@ -19,6 +19,8 @@ export default function MyJobTable({ MyJobList, reloadJobList, className }) { userDetails: { country }, } = useSelector((state) => state?.userDetails); + const { jobListTable } = useSelector((state) => state.tableReload); + const userApi = useMemo(() => new usersService(), []); // Get Country Api @@ -45,8 +47,40 @@ export default function MyJobTable({ MyJobList, reloadJobList, className }) { getCountryList(); }, [getCountryList]); + const [jobCategories, setJobCategories] = useState({ + loading: false, + data: null, + }); + + useEffect(() => { + const getMyJobList = async () => { + setJobCategories({ loading: true, data: null }); + try { + const res = await userApi.getActiveJobList(); + setJobCategories({ loading: false, data: res.data?.categories }); + } catch (error) { + setJobCategories({ loading: true, data: null }); + throw new Error(error); + } + }; + getMyJobList(); + }, [jobListTable]); + + // Creating All cart.. + let _jobCategories = useMemo( + () => ({ All: "All", ...jobCategories.data }), + [jobCategories] + ); + console.log("Checking getJobData", _jobCategories); + + const [selectedCategory, setCategory] = useState(_jobCategories.All); + + // Convert to array in order to map + const mappedArray = Object.entries(_jobCategories).map(([key, value]) => { + return { key, value }; +}); + const filterCategories = ["All Categories", "Explore", "Featured"]; - const [selectedCategory, setCategory] = useState(filterCategories[0]); let [jobPopout, setJobPopout] = useState({ show: false, data: {} }); // STATE TO HOLD THE VALUE OF THE ALERT DETAILS AND DETERMINE WHEN TO SHOW @@ -110,85 +144,86 @@ export default function MyJobTable({ MyJobList, reloadJobList, className }) { value?.currency_code, value?.currency ); - return( - - -
-
-
- data + return ( + + +
+
+
+ data +
+
+

+ {value.title} +

+
{value.description}
+ + Price:{" "} + + {thePrice} + + + + Duration:{" "} + + {" "} + {value.timeline_days} day(s) + + +
-
-

- {value.title} -

-
{value.description}
- - Price:{" "} - - {thePrice} - - - - Duration:{" "} - - {" "} - {value.timeline_days} day(s) - - + +
+ + | +
+ -
- - | - -
-
- - - - - - - )}) + + + + + ); + }) ) : ( No Jobs Avaliable! diff --git a/src/components/MyJobs/index.jsx b/src/components/MyJobs/index.jsx index 4b2ab77..e041593 100644 --- a/src/components/MyJobs/index.jsx +++ b/src/components/MyJobs/index.jsx @@ -11,6 +11,9 @@ export default function MyJobs(props) { setPopUp((prev) => !prev); }; + console.log("Checking getJobData props", props) + + return ( diff --git a/src/views/MyJobsPage.jsx b/src/views/MyJobsPage.jsx index b37060d..ce69c18 100644 --- a/src/views/MyJobsPage.jsx +++ b/src/views/MyJobsPage.jsx @@ -1,9 +1,12 @@ -import MyJobs from "../components/MyJobs"; +import { useEffect, useState } from "react"; +import MyJobs from "../components/MyJobs"; import { useSelector } from "react-redux"; export default function MyJobsPage() { let { commonHeadBanner } = useSelector((state) => state.commonHeadBanner); const { userJobList } = useSelector((state) => state.userJobList); + + return ( <>