From 376cf44a9cf24e1695063203780c37ec67d88204 Mon Sep 17 00:00:00 2001 From: ebube Date: Tue, 28 Nov 2023 06:41:32 -0800 Subject: [PATCH 1/5] Currency option set to fixed and category option set --- src/components/AddJob/AddJob.jsx | 162 ++++++++++++++----------------- 1 file changed, 73 insertions(+), 89 deletions(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 90c2db8..0bfb873 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -38,23 +38,34 @@ const validationSchema = Yup.object().shape({ .typeError("you must specify a number") .min(1, "Price must be greater than 0") .required("Timeline is required"), - category: Yup.array().min(1, "Select at least one checkbox"), + category: Yup.string().min(1, "Select at least one checkbox"), }); function AddJob({ popUpHandler, categories }) { const ApiCall = new usersService(); const { walletDetails } = useSelector((state) => state.walletDetails); + const { userDetails } = useSelector((state) => state.userDetails); + let dispatch = useDispatch(); + const getWalletDetail = (country) => { // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED + const walletChecker = walletDetails?.data.find( + (item) => item.country === country + ); + return walletChecker ? walletChecker.code : ""; + }; + + const walletAmount = getWalletDetail(userDetails.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED + let initialValues = { // initial values for formik - country: "", + country: walletAmount, price: "", title: "", description: "", job_detail: "", timeline_days: "", - category: [], + category: "", }; let [requestStatus, setRequestStatus] = useState({ @@ -63,12 +74,6 @@ function AddJob({ popUpHandler, categories }) { message: "", }); // Holds state when submit button is pressed - // const getWalletDetail = (country) => { // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED - // const walletChecker = walletDetails?.data.find( - // (item) => item.country === country - // ); - // return walletChecker ? walletChecker.amount : 0; - // }; const handleAddJob = async (values, helpers) => { const reqData = { @@ -78,10 +83,9 @@ function AddJob({ popUpHandler, categories }) { description: values?.description, job_detail: values?.job_detail, timeline_days: values?.timeline_days, - category: values.category?.join("@"), + category: values.category, }; - // const walletAmount = getWalletDetail(reqData.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED // if (reqData.price > walletAmount) { // setRequestStatus({ @@ -134,7 +138,7 @@ function AddJob({ popUpHandler, categories }) { }; return ( -
+
- - +
{/* Price */} @@ -255,7 +233,7 @@ function AddJob({ popUpHandler, categories }) { {/* Details */}
-
+
- -
-
+ +
+
-
+ {props.errors.category} + + )} + +
-
-
+ +
From eacfae19f0566a8c9d9a440a97f8bd70a1560971 Mon Sep 17 00:00:00 2001 From: ebube Date: Tue, 28 Nov 2023 07:26:34 -0800 Subject: [PATCH 2/5] Currency Bug Fix --- src/components/AddJob/AddJob.jsx | 141 ++++++++++++++++--------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 0bfb873..6aaa71b 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -38,7 +38,7 @@ const validationSchema = Yup.object().shape({ .typeError("you must specify a number") .min(1, "Price must be greater than 0") .required("Timeline is required"), - category: Yup.string().min(1, "Select at least one checkbox"), + category: Yup.array().min(1, "Select at least one checkbox"), }); function AddJob({ popUpHandler, categories }) { @@ -48,24 +48,30 @@ function AddJob({ popUpHandler, categories }) { let dispatch = useDispatch(); - const getWalletDetail = (country) => { // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED + const getWalletDetail = (countryParams) => { + // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED const walletChecker = walletDetails?.data.find( - (item) => item.country === country + (item) => item.country === countryParams ); - return walletChecker ? walletChecker.code : ""; + return walletChecker + ? { + description: walletChecker.description, + country: walletChecker.country, + } + : ""; }; - const walletAmount = getWalletDetail(userDetails.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED + const walletAmount = getWalletDetail(userDetails.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED let initialValues = { // initial values for formik - country: walletAmount, + country: walletAmount?.description, price: "", title: "", description: "", job_detail: "", timeline_days: "", - category: "", + category: [], }; let [requestStatus, setRequestStatus] = useState({ @@ -74,18 +80,25 @@ function AddJob({ popUpHandler, categories }) { message: "", }); // Holds state when submit button is pressed + // const getWalletDetail = (country) => { // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED + // const walletChecker = walletDetails?.data.find( + // (item) => item.country === country + // ); + // return walletChecker ? walletChecker.amount : 0; + // }; const handleAddJob = async (values, helpers) => { const reqData = { - country: values?.country, + country: walletAmount?.country, price: Number(values.price) * 100, title: values?.title, description: values?.description, job_detail: values?.job_detail, timeline_days: values?.timeline_days, - category: values.category, + category: values.category?.join("@"), }; + // const walletAmount = getWalletDetail(reqData.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED // if (reqData.price > walletAmount) { // setRequestStatus({ @@ -138,7 +151,7 @@ function AddJob({ popUpHandler, categories }) { }; return ( -
+
- +
{/* Price */} @@ -233,7 +246,7 @@ function AddJob({ popUpHandler, categories }) { {/* Details */}
-
+
-
- -
-
+
From 492bda021f65c2edc843f37b4705cd32f21c6ab9 Mon Sep 17 00:00:00 2001 From: ebube Date: Tue, 28 Nov 2023 07:41:31 -0800 Subject: [PATCH 3/5] Select Option Bug Fixed --- src/components/AddJob/AddJob.jsx | 63 +++++++++++++++++--------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 6aaa71b..a5ee6c3 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -167,7 +167,7 @@ function AddJob({ popUpHandler, categories }) {
-
Categories -
-
+ {props.errors.category} + + )} + +
From 775bcd50053f4c04f5e3aa56a4b4db789fa8270e Mon Sep 17 00:00:00 2001 From: ebube Date: Tue, 28 Nov 2023 09:11:52 -0800 Subject: [PATCH 4/5] Clean up...added feature to edit popup --- src/components/AddJob/AddJob.jsx | 134 ++++++--------------- src/components/AddJob/settings.js | 100 +++++++++++++++ src/components/jobPopout/EditJobPopout.jsx | 85 ++++++++----- 3 files changed, 190 insertions(+), 129 deletions(-) create mode 100644 src/components/AddJob/settings.js diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index a5ee6c3..c29254c 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -1,45 +1,21 @@ -import { Field, Form, Formik } from "formik"; -import React, { useEffect, useState } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import * as Yup from "yup"; -import usersService from "../../services/UsersService"; -import { tableReload } from "../../store/TableReloads"; -import InputCom from "../Helpers/Inputs/InputCom"; -import LoadingSpinner from "../Spinners/LoadingSpinner"; +import { + validationSchema as VS, + getWalletDetail, + useDispatch, + useSelector, + usersService, + initialValues as IV, + initialReqState, + useState, + tableReload, + Formik, + InputCom, + Field, + Form, + LoadingSpinner, +} from "./settings"; -const validationSchema = Yup.object().shape({ - country: Yup.string() - .min(1, "Minimum 3 characters") - .max(25, "Maximum 25 characters") - .required("Currency is required"), - price: Yup.string() - .typeError("Invalid number") - .min(1, "Price must be greater than 0") - .test("no-e", "Invalid number", (value) => { - if (value && /\d+e/.test(value)) { - return false; - } - return true; - }) - .required("Price is required"), - title: Yup.string() - .min(5, "Minimum 5 characters") - .max(149, "Maximum 149 characters") - .required("Title is required"), - description: Yup.string() - .min(5, "Minimum 5 characters") - .max(299, "Maximum 299 characters") - .required("Description is required"), - job_detail: Yup.string() - .min(3, "Minimum 3 characters") - .max(499, "Maximum 499 characters") - .required("Details is required"), - timeline_days: Yup.number() - .typeError("you must specify a number") - .min(1, "Price must be greater than 0") - .required("Timeline is required"), - category: Yup.array().min(1, "Select at least one checkbox"), -}); +const validationSchema = VS; function AddJob({ popUpHandler, categories }) { const ApiCall = new usersService(); @@ -48,44 +24,13 @@ function AddJob({ popUpHandler, categories }) { let dispatch = useDispatch(); - const getWalletDetail = (countryParams) => { - // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED - const walletChecker = walletDetails?.data.find( - (item) => item.country === countryParams - ); - return walletChecker - ? { - description: walletChecker.description, - country: walletChecker.country, - } - : ""; - }; - - const walletAmount = getWalletDetail(userDetails.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED - - let initialValues = { - // initial values for formik - country: walletAmount?.description, - price: "", - title: "", - description: "", - job_detail: "", - timeline_days: "", - category: [], - }; - - let [requestStatus, setRequestStatus] = useState({ - loading: false, - status: false, - message: "", - }); // Holds state when submit button is pressed - - // const getWalletDetail = (country) => { // A FUNCTION TO GET USER BALANCE BASED ON COUNTRY SELECTED - // const walletChecker = walletDetails?.data.find( - // (item) => item.country === country - // ); - // return walletChecker ? walletChecker.amount : 0; - // }; + const getWalletDetails = getWalletDetail( + userDetails.component, + walletDetails + ); + const walletAmount = getWalletDetails; // GETTING USER BALANCE BASED ON COUNTRY SELECTED + const initialValues = { ...IV, country: walletAmount?.description }; + const [requestStatus, setRequestStatus] = useState(initialReqState); // Holds state when submit button is pressed const handleAddJob = async (values, helpers) => { const reqData = { @@ -98,21 +43,6 @@ function AddJob({ popUpHandler, categories }) { category: values.category?.join("@"), }; - // const walletAmount = getWalletDetail(reqData.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED - - // if (reqData.price > walletAmount) { - // setRequestStatus({ - // loading: false, - // status: false, - // message: "Insufficient Balance", - // }); - - // setTimeout(() => { - // setRequestStatus({ loading: false, status: false, message: "" }); - // }, 1500); - // return; - // } - setRequestStatus({ loading: true, status: false, message: "" }); try { @@ -150,6 +80,14 @@ function AddJob({ popUpHandler, categories }) { } }; + // Check if the user is using iOS + const isIOS = /MacIntel|MacPPC/.test(navigator.platform) && !window.MSStream; + + // Check if the user is using Windows + const isWindows = /Windows/.test(navigator.userAgent); + + // console.log(isIOS, isWindows, navigator); + return (
+ {walletDetails?.loading ? ( + + ) : walletDetails.data.length ? ( + <> + {/* */} + {Object?.entries(categories).map(([key, value]) => ( + + ))} + + ) : ( + + )} + +
{/* FOR TASK IMAGE */} From 455f4001f7b01da948fca8cc1afe13d56872282a Mon Sep 17 00:00:00 2001 From: ebube Date: Tue, 28 Nov 2023 09:18:54 -0800 Subject: [PATCH 5/5] Final Check --- src/components/AddJob/AddJob.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index c29254c..bbd0094 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -25,7 +25,7 @@ function AddJob({ popUpHandler, categories }) { let dispatch = useDispatch(); const getWalletDetails = getWalletDetail( - userDetails.component, + userDetails.country, walletDetails ); const walletAmount = getWalletDetails; // GETTING USER BALANCE BASED ON COUNTRY SELECTED