diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 81d29fa..42d577c 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -11,7 +11,7 @@ const validationSchema = Yup.object().shape({ country: Yup.string() .min(1, "Minimum 3 characters") .max(25, "Maximum 25 characters") - .required("Country is required"), + .required("Currency is required"), price: Yup.string() .typeError("Invalid number") .min(1, "Price must be greater than 0") @@ -46,12 +46,6 @@ function AddJob({ popUpHandler, categories }) { const { walletDetails } = useSelector((state) => state.walletDetails); let dispatch = useDispatch(); - let [currency, setCurrency] = useState({ - loading: true, - status: false, - data: null, - }); // To Hold the array of currency getUserCurrency returns - let initialValues = { // initial values for formik country: "", @@ -69,29 +63,8 @@ function AddJob({ popUpHandler, categories }) { message: "", }); // Holds state when submit button is pressed - // FUNCTION TO GET Currency - const getUserCurrency = () => { - setCurrency((prev) => ({ ...prev, loading: true })); - ApiCall.getUserWallets() - .then((res) => { - if (res.data.internal_return < 0) { - setCurrency({ loading: false, status: true, data: [] }); - return; - } - - setCurrency({ - loading: false, - status: true, - data: res.data.result_list, - }); - }) - .catch((err) => { - setCurrency({ loading: false, status: false, data: [] }); - }); - }; - - const getWalletDetail = (country) => { - const walletChecker = walletDetails.result_list.find( + 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; @@ -108,7 +81,8 @@ function AddJob({ popUpHandler, categories }) { category: values.category?.join("@"), }; - const walletAmount = getWalletDetail(reqData.country); + const walletAmount = getWalletDetail(reqData.country); // GETTING USER BALANCE BASED ON COUNTRY SELECTED + if (reqData.price > walletAmount) { setRequestStatus({ loading: false, @@ -159,10 +133,6 @@ function AddJob({ popUpHandler, categories }) { } }; - useEffect(() => { - getUserCurrency(); - }, []); - return (