From 7998eaf52dd494535d66ebe7b3357b6909a5f1dc Mon Sep 17 00:00:00 2001 From: Ebube Date: Fri, 19 May 2023 00:11:44 +0100 Subject: [PATCH] implemented api and fixed interface bug --- src/components/AddJob/AddJob.jsx | 1 - src/components/FamilyAcc/FamilyTable.jsx | 123 ++++++++++-------- .../Helpers/Inputs/InputCom/index.jsx | 2 +- src/components/MyJobs/MyJobTable.jsx | 37 +++++- src/components/jobPopout/EditJobPopout.jsx | 67 ++++++---- src/services/UsersService.js | 12 ++ 6 files changed, 160 insertions(+), 82 deletions(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 6e35d2a..258fe8b 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -47,7 +47,6 @@ let initialValues = { function AddJob() { const ApiCall = new usersService(); const navigate = useNavigate(); - let [pageLoading, setPageLoading] = useState(true); // State used for knowing when the page is mounting let [country, setCountry] = useState({ diff --git a/src/components/FamilyAcc/FamilyTable.jsx b/src/components/FamilyAcc/FamilyTable.jsx index 0927118..3a2a0fe 100644 --- a/src/components/FamilyAcc/FamilyTable.jsx +++ b/src/components/FamilyAcc/FamilyTable.jsx @@ -4,7 +4,6 @@ import LoadingSpinner from "../Spinners/LoadingSpinner"; export default function FamilyTable({ className, familyList, loader }) { const filterCategories = ["All Categories", "Explore", "Featured"]; - const [selectedCategory, setCategory] = useState(filterCategories[0]); return (
- {loader ? ( -
- -
- ) : ( - + {loader ? ( +
+ +
+ ) : ( +
<> @@ -31,55 +30,65 @@ export default function FamilyTable({ className, familyList, loader }) { <> {familyList?.length > 0 ? ( - familyList?.map(({ firstname, lastname, age }, idx) => ( - - - - - - Manage - - - - )) + + + + + + ); + } + ) ) : ( -
-
-
- data -
-
-

- {`${firstname} ${lastname} (${age})`} -

- - Added{" "} - 10-10-2029 - -
-
-
-
- - 10-10-2019 - -
-
-
- - 100 - -
-
-
+
+
+ data +
+
+

+ {`${firstname} ${lastname} (${age})`} +

+ + Added:{" "} + + {addedDate} + + +
+
+
+
+ + {last_login} + +
+
+
+ + 100 + +
+
+ +
@@ -90,8 +99,8 @@ export default function FamilyTable({ className, familyList, loader }) {
- )} + + )}
); diff --git a/src/components/Helpers/Inputs/InputCom/index.jsx b/src/components/Helpers/Inputs/InputCom/index.jsx index 4cabcd9..7e0b2a5 100644 --- a/src/components/Helpers/Inputs/InputCom/index.jsx +++ b/src/components/Helpers/Inputs/InputCom/index.jsx @@ -82,7 +82,7 @@ export default function InputCom({ name={name} minLength={minLengthValidation()} maxLength={maxLengthValidation()} - pattern={() => inputPatterns} + // pattern={inputPatterns()} ref={inputRef} readOnly={disable} onBlur={blurHandler} diff --git a/src/components/MyJobs/MyJobTable.jsx b/src/components/MyJobs/MyJobTable.jsx index 4961b54..2532860 100644 --- a/src/components/MyJobs/MyJobTable.jsx +++ b/src/components/MyJobs/MyJobTable.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import dataImage1 from "../../assets/images/data-table-user-1.png"; import dataImage2 from "../../assets/images/data-table-user-2.png"; import dataImage3 from "../../assets/images/data-table-user-3.png"; @@ -10,8 +10,42 @@ import DeleteJobPopout from "../jobPopout/DeleteJobPopout"; import PaginatedList from "../Pagination/PaginatedList"; import { handlePagingFunc } from "../Pagination/HandlePagination"; import EditJobPopOut from "../jobPopout/EditJobPopout"; +import usersService from "../../services/UsersService"; +import { useSelector } from "react-redux"; export default function MyJobTable({ MyJobList, className }) { + const [myCountry, setCountries] = useState(""); + const { + userDetails: { country }, + } = useSelector((state) => state?.userDetails); + + const userApi = useMemo(() => new usersService(), []); + + // Get Country Api + const getCountryList = useCallback(async () => { + const res = await userApi.getSignupCountryData(); + + try { + if (res.status === 200) { + const { + data: { signup_country }, + } = await res; + console.log(signup_country); + let checkCountry = signup_country + ?.filter((item) => item[0] == country) + ?.map((item, idx) => item[1]) + .join(""); + setCountries(checkCountry); + } + } catch (error) { + throw new Error(error); + } + }, [userApi, country]); + + useEffect(() => { + getCountryList(); + }, [getCountryList]); + const filterCategories = ["All Categories", "Explore", "Featured"]; const [selectedCategory, setCategory] = useState(filterCategories[0]); @@ -209,6 +243,7 @@ export default function MyJobTable({ MyJobList, className }) { }); }} situation={editJob.show} + country={myCountry} /> )} diff --git a/src/components/jobPopout/EditJobPopout.jsx b/src/components/jobPopout/EditJobPopout.jsx index 91d45da..0d5e3a9 100644 --- a/src/components/jobPopout/EditJobPopout.jsx +++ b/src/components/jobPopout/EditJobPopout.jsx @@ -1,11 +1,13 @@ -import React, { useState } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import ModalCom from "../Helpers/ModalCom"; import { Form, Formik } from "formik"; import * as Yup from "yup"; import InputCom from "../Helpers/Inputs/InputCom"; import LoadingSpinner from "../Spinners/LoadingSpinner"; +import usersService from "../../services/UsersService"; +import { useNavigate } from "react-router-dom"; -const EditJobPopOut = ({ details, onClose, situation }) => { +const EditJobPopOut = ({ details, onClose, situation, country }) => { let [requestStatus, setRequestStatus] = useState({ loading: false, status: false, @@ -41,7 +43,7 @@ const EditJobPopOut = ({ details, onClose, situation }) => { let initialValues = { // initial values for formik - country: details?.country, + country: country, price: details?.price, title: details?.title, description: details?.description, @@ -49,7 +51,34 @@ const EditJobPopOut = ({ details, onClose, situation }) => { timeline_days: details?.timeline_days, }; - console.log(details); + const jobApi = useMemo(() => new usersService(), []); + const navigate = useNavigate(); + + const handleEditJob = useCallback( + async (values) => { + setRequestStatus({ loading: true, message: "" }); + let reqData = { + job_id: details.job_id, + job_uid: details.job_uid, + ...values, + }; + try { + let res = await jobApi.jobManagerUpdateJob(reqData); + let { data } = await res; + if (data?.internal_return < 0) return; + setRequestStatus({ loading: false, message: null }); + setTimeout(() => { + navigate("/myjobs", { replace: true }); + onClose(); + }, 1000); + } catch (error) { + setRequestStatus({ loading: false, message: error }); + throw new Error(error); + } + }, + [jobApi, navigate, onClose, details] + ); + return (
@@ -87,6 +116,7 @@ const EditJobPopOut = ({ details, onClose, situation }) => { {(props) => (
@@ -94,26 +124,19 @@ const EditJobPopOut = ({ details, onClose, situation }) => {
- - + inputHandler={props.handleChange} + blurHandler={props.handleBlur} + disable={true} + /> {props.errors.country && props.touched.country && (

{props.errors.country} diff --git a/src/services/UsersService.js b/src/services/UsersService.js index 7aca25a..92bca2d 100644 --- a/src/services/UsersService.js +++ b/src/services/UsersService.js @@ -461,6 +461,18 @@ class usersService { return this.postAuxEnd("/jobmanagercreatejob", postData); } + jobManagerUpdateJob(reqData) { + var postData = { + uid: localStorage.getItem("uid"), + member_id: localStorage.getItem("member_id"), + sessionid: localStorage.getItem("session_token"), + job_id: localStorage.getItem("job_id"), + action: 13010, + ...reqData + }; + return this.postAuxEnd("/jobmanagerupdatejob", postData); + } + // END POINT TO DELETE A JOB deleteJob(reqData) { var postData = {