Compare commits

...

2 Commits

Author SHA1 Message Date
victorAnumudu 07c72b5459 error display name for timeline_days changed 2023-05-18 15:58:48 +01:00
victorAnumudu 1a50788730 Disabled input field of country on add Job page 2023-05-18 14:18:26 +01:00
+32 -38
View File
@@ -4,14 +4,16 @@ import InputCom from "../Helpers/Inputs/InputCom";
import LoadingSpinner from "../Spinners/LoadingSpinner";
import usersService from "../../services/UsersService";
import { useSelector } from "react-redux";
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")
@@ -31,12 +33,12 @@ 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 = {
// initial values for formik
country: "",
// country: "",
price: 0,
title: "",
description: "",
@@ -48,12 +50,14 @@ function AddJob() {
const ApiCall = new usersService();
const navigate = useNavigate();
let {userDetails} = useSelector((state)=> state.userDetails)
let [pageLoading, setPageLoading] = useState(true); // State used for knowing when the page is mounting
let [country, setCountry] = useState({
loading: false,
loading: true,
status: false,
data: [],
data: '',
}); // To Hold the array of country getUserCountry returns
let [requestStatus, setRequestStatus] = useState({
@@ -68,24 +72,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,
data: res.data.signup_country?.find(item => item[0]==userDetails.country)[1],
});
})
.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)
ApiCall.jobManagerCreateJob({...values, country:userDetails.country})
.then((res) => {
if (res.data.internal_return < 1) {
setRequestStatus({
@@ -148,18 +152,19 @@ function AddJob() {
{/* country */}
<div className="xl:flex xl:space-x-7 mb-6">
<div className="field w-full mb-6 xl:mb-0">
{/* <InputCom
fieldClass="px-6"
label="Country"
labelClass='tracking-wide'
inputBg = 'bg-slate-100'
type="text"
name="country"
// placeholder="Select Country"
value={props.values.country}
inputHandler={props.handleChange}
/> */}
<label
<InputCom
fieldClass="px-6 cursor-not-allowed"
label="Country"
labelClass='tracking-wide'
inputBg = 'bg-slate-100'
type="text"
name="country"
disable={true}
value={country.loading ? 'loading' : country.data ? country.data : 'no country found!'}
// inputHandler={(e)=> setCountry((prev) => ({...prev, data:e.target.value}))}
/>
{/* <label
htmlFor="country"
className="input-label text-[#181c32] dark:text-white text-[13.975px] leading-[20.9625px] font-semibold block"
>
@@ -197,12 +202,12 @@ function AddJob() {
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 */}
@@ -272,17 +277,6 @@ function AddJob() {
{/* Details */}
<div className="field w-full mb-6">
{/* <InputCom
fieldClass="px-6"
label="Job Delivery Details"
labelClass='tracking-wide'
inputBg = 'bg-slate-100'
type="text"
name="details"
// placeholder="Please Enter Detail Description of Job"
value={props.values.details}
inputHandler={props.handleChange}
/> */}
<label
htmlFor="Job Delivery Details"
className='className="input-label text-[#181c32] dark:text-white text-[13.975px] leading-[20.9625px] font-semibold block"'