Compare commits

..

3 Commits

Author SHA1 Message Date
victorAnumudu f5575ecce5 disabled user country 2023-05-18 16:33:18 +01:00
victorAnumudu b5b95a9040 duplicate info removed 2023-05-18 16:15:37 +01:00
victorAnumudu 24f3a40a43 Only returns User Country as Default Country in Add Job Page 2023-05-18 16:12:14 +01:00
+51 -36
View File
@@ -10,10 +10,10 @@ import { Form, Formik } from "formik";
import * as Yup from "yup";
const validationSchema = Yup.object().shape({
// country: Yup.string()
// .min(1, "Minimum 3 characters")
// .max(25, "Maximum 25 characters")
// .required("Country is required"),
country: Yup.string()
.min(1, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("Country is required"),
price: Yup.number()
.typeError("you must specify a number")
.min(1, "Price must be greater than 0")
@@ -36,15 +36,15 @@ const validationSchema = Yup.object().shape({
.required("Timeline is required"),
});
let initialValues = {
// initial values for formik
// country: "",
price: 0,
title: "",
description: "",
job_detail: "",
timeline_days: "",
};
// let initialValues = {
// // initial values for formik
// country: "NG",
// price: 0,
// title: "",
// description: "",
// job_detail: "",
// timeline_days: "",
// };
function AddJob() {
const ApiCall = new usersService();
@@ -57,9 +57,19 @@ function AddJob() {
let [country, setCountry] = useState({
loading: true,
status: false,
data: '',
data: [],
}); // To Hold the array of country getUserCountry returns
let initialValues = {
// initial values for formik
country: userDetails.country,
price: "",
title: "",
description: "",
job_detail: "",
timeline_days: "",
};
let [requestStatus, setRequestStatus] = useState({
loading: false,
status: false,
@@ -72,24 +82,24 @@ function AddJob() {
ApiCall.getSignupCountryData()
.then((res) => {
if (res.data.internal_return < 1) {
setCountry({ loading: false, status: true, data: '' });
setCountry({ loading: false, status: true, data: [] });
return;
}
setCountry({
loading: false,
status: true,
data: res.data.signup_country?.find(item => item[0]==userDetails.country)[1],
data: res.data.signup_country,
});
})
.catch((err) => {
setCountry({ loading: false, status: false, data: '' });
setCountry({ loading: false, status: false, data: [] });
});
};
// FUNCTION TO HANDLE ADD JOB FORM
const handleAddJob = (values, helpers) => {
setRequestStatus({ loading: true, status: false, message: "" });
ApiCall.jobManagerCreateJob({...values, country:userDetails.country})
ApiCall.jobManagerCreateJob(values)
.then((res) => {
if (res.data.internal_return < 1) {
setRequestStatus({
@@ -123,8 +133,8 @@ function AddJob() {
};
useEffect(() => {
setPageLoading(false);
getUserCountry();
setPageLoading(false);
}, []);
return pageLoading.loading ? (
@@ -152,7 +162,7 @@ function AddJob() {
{/* country */}
<div className="xl:flex xl:space-x-7 mb-6">
<div className="field w-full mb-6 xl:mb-0">
<InputCom
{/* <InputCom
fieldClass="px-6 cursor-not-allowed"
label="Country"
labelClass='tracking-wide'
@@ -161,10 +171,10 @@ function AddJob() {
name="country"
disable={true}
value={country.loading ? 'loading' : country.data ? country.data : 'no country found!'}
// inputHandler={(e)=> setCountry((prev) => ({...prev, data:e.target.value}))}
inputHandler={(e)=> setCountry((prev) => ({...prev, data:e.target.value}))}
/>
{/* <label
/> */}
<label
htmlFor="country"
className="input-label text-[#181c32] dark:text-white text-[13.975px] leading-[20.9625px] font-semibold block"
>
@@ -173,6 +183,7 @@ function AddJob() {
<select
id="country"
name="country"
disabled
value={props.values.country}
className={`input-field p-2 mt-3 rounded-md placeholder:text-base text-dark-gray dark:text-white w-full h-10 bg-slate-100 dark:bg-[#11131F] focus:ring-0 focus:outline-none`}
onChange={props.handleChange}
@@ -187,27 +198,31 @@ function AddJob() {
<option className="text-slate-500 text-lg" value="">
Select...
</option>
{country.data.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item[0]}
>
{item[1]}
</option>
))}
{country.data.map((item, index) => {
if(item[0] == userDetails.country){
return (
<option
key={index}
className="text-slate-500 text-lg"
value={item[0]}
>
{item[1]}
</option>
)
}
})}
</>
) : (
<option className="text-slate-500 text-lg" value="">
No Options Found! Try Again
</option>
)}
</select> */}
{/* {props.errors.country && props.touched.country && (
</select>
{props.errors.country && props.touched.country && (
<p className="text-sm text-red-500">
{props.errors.country}
</p>
)} */}
)}
</div>
{/* Price */}
@@ -219,7 +234,7 @@ function AddJob() {
inputBg="bg-slate-100"
type="number"
name="price"
// placeholder="Please Enter Amount"
placeholder="0"
value={props.values.price}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}