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 ( -