diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 05f4d74..05fda87 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -33,7 +33,7 @@ const validationSchema = Yup.object().shape({ timeline_days: Yup.number() .typeError("you must specify a number") .min(1, "Price must be greater than 0") - .required("Price is required"), + .required("Timeline is required"), }); let initialValues = { @@ -51,15 +51,14 @@ function AddJob() { const navigate = useNavigate(); let {userDetails} = useSelector((state)=> state.userDetails) - console.log(userDetails, userDetails.country) let [pageLoading, setPageLoading] = useState(true); // State used for knowing when the page is mounting - // let [country, setCountry] = useState({ - // loading: false, - // status: false, - // data: [], - // }); // To Hold the array of country getUserCountry returns + let [country, setCountry] = useState({ + loading: true, + status: false, + data: '', + }); // To Hold the array of country getUserCountry returns let [requestStatus, setRequestStatus] = useState({ loading: false, @@ -68,24 +67,24 @@ function AddJob() { }); // Holds state when submit button is pressed // FUNCTION TO GET COUNTRY - // const getUserCountry = () => { - // setCountry((prev) => ({ ...prev, loading: true })); - // ApiCall.getSignupCountryData() - // .then((res) => { - // if (res.data.internal_return < 1) { - // setCountry({ loading: false, status: true, data: [] }); - // return; - // } - // setCountry({ - // loading: false, - // status: true, - // data: res.data.signup_country, - // }); - // }) - // .catch((err) => { - // setCountry({ loading: false, status: false, data: [] }); - // }); - // }; + const getUserCountry = () => { + setCountry((prev) => ({ ...prev, loading: true })); + ApiCall.getSignupCountryData() + .then((res) => { + if (res.data.internal_return < 1) { + setCountry({ loading: false, status: true, data: '' }); + return; + } + setCountry({ + loading: false, + status: true, + data: res.data.signup_country?.find(item => item[0]==userDetails.country)[1], + }); + }) + .catch((err) => { + setCountry({ loading: false, status: false, data: '' }); + }); + }; // FUNCTION TO HANDLE ADD JOB FORM const handleAddJob = (values, helpers) => { @@ -125,7 +124,7 @@ function AddJob() { useEffect(() => { setPageLoading(false); - // getUserCountry(); + getUserCountry(); }, []); return pageLoading.loading ? ( @@ -161,8 +160,9 @@ function AddJob() { type="text" name="country" disable={true} - // placeholder="Select Country" - value={userDetails.country} + value={country.loading ? 'loading' : country.data ? country.data : 'no country found!'} + // inputHandler={(e)=> setCountry((prev) => ({...prev, data:e.target.value}))} + /> {/*