diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 799dd2e..dc2e2e0 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -14,8 +14,14 @@ const validationSchema = Yup.object().shape({ .max(25, "Maximum 25 characters") .required("Country is required"), price: Yup.number() - .typeError("you must specify a number") + .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(3, "Minimum 3 characters") @@ -42,15 +48,16 @@ function AddJob({ popUpHandler, categories }) { let { userDetails } = useSelector((state) => state.userDetails); - let [country, setCountry] = useState({ + const [numberValue, setNumberValue] = useState(""); + let [currency, setCurrency] = useState({ loading: true, status: false, - data: [], - }); // To Hold the array of country getUserCountry returns + data: null, + }); // To Hold the array of currency getUserCurrency returns let initialValues = { // initial values for formik - country: userDetails.country, + currency: "", price: "", title: "", description: "", @@ -65,23 +72,25 @@ function AddJob({ popUpHandler, categories }) { message: "", }); // Holds state when submit button is pressed - // FUNCTION TO GET COUNTRY - const getUserCountry = () => { - setCountry((prev) => ({ ...prev, loading: true })); - ApiCall.getSignupCountryData() + // FUNCTION TO GET Currency + const getUserCurrency = () => { + setCurrency((prev) => ({ ...prev, loading: true })); + ApiCall.getUserWallets() .then((res) => { - if (res.data.internal_return < 1) { - setCountry({ loading: false, status: true, data: [] }); + if (res.data.internal_return < 0) { + setCurrency({ loading: false, status: true, data: [] }); return; } - setCountry({ + console.log("Res for currency >> ", res); + + setCurrency({ loading: false, status: true, - data: res.data.signup_country, + data: res.data.result_list, }); }) .catch((err) => { - setCountry({ loading: false, status: false, data: [] }); + setCurrency({ loading: false, status: false, data: [] }); }); }; @@ -113,7 +122,7 @@ function AddJob({ popUpHandler, categories }) { setRequestStatus({ loading: false, status: false, - message: "Opps! soemthing went wrong. Try Again", + message: "Opps! something went wrong. Try Again", }); }) .finally(() => { @@ -124,9 +133,11 @@ function AddJob({ popUpHandler, categories }) { }; useEffect(() => { - getUserCountry(); + getUserCurrency(); }, []); + console.log("Currency >> ", currency.data); + return (
{/* inputs starts here */} - {/* country */}