Merge branch 'deleted-job-api-implementation' of WrenchBoard/Users-Wrench into master

This commit is contained in:
2023-05-12 20:48:20 +00:00
committed by Gogs
2 changed files with 18 additions and 7 deletions
+11 -3
View File
@@ -13,7 +13,7 @@ const validationSchema = Yup.object().shape({
.max(25, "Maximum 25 characters")
.required("Country is required"),
price: Yup.number()
.typeError("you must specify a number")
.typeError("you must specify a number")
.min(1, "Price must be greater than 0")
.required("Price is required"),
title: Yup.string()
@@ -36,7 +36,7 @@ const validationSchema = Yup.object().shape({
let initialValues = { // initial values for formik
country: '',
price: '',
price: 0,
title: '',
description: '',
job_detail: '',
@@ -137,8 +137,10 @@ function AddJob() {
<select
id='country'
name='country'
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}
onBlur={props.handleBlur}
>
{country.loading ? (
<option className="text-slate-500 text-lg" value="">
@@ -179,11 +181,13 @@ function AddJob() {
label="Price"
labelClass='tracking-wide'
inputBg = 'bg-slate-100'
type="text"
type="number"
name="price"
fieldClass='text-right'
// placeholder="Please Enter Amount"
value={props.values.price}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
{props.errors.price && props.touched.price && (
<p className="text-sm text-red-500">
@@ -206,6 +210,7 @@ function AddJob() {
// placeholder="Enter Job Title"
value={props.values.title}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
{props.errors.title && props.touched.title && (
<p className="text-sm text-red-500">
@@ -226,6 +231,7 @@ function AddJob() {
// placeholder="Enter a description"
value={props.values.description}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
{props.errors.description && props.touched.description && (
<p className="text-sm text-red-500">
@@ -258,6 +264,7 @@ function AddJob() {
name='job_detail'
value={props.values.job_detail}
onChange={props.handleChange}
onBlur={props.handleBlur}
/>
{props.errors.job_detail && props.touched.job_detail && (
<p className="text-sm text-red-500">
@@ -278,6 +285,7 @@ function AddJob() {
// placeholder="Please Enter Detail Description of Job"
value={props.values.timeline_days}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
{props.errors.timeline_days && props.touched.timeline_days && (
<p className="text-sm text-red-500">
+7 -4
View File
@@ -10,14 +10,15 @@ function DeleteJobPopout({details, onClose, situation}) {
let [requestStatus, setRequestStatus] = useState({laoding: false, status:false, message: ''}) // STATE FOR KNOWING WHEN A REQUEST IS MADE TO THE SERVER
// FUNCTION CALLED ONCE USER CONFIRM DELETE JOB
const deleteJob = (details) => {
setRequestStatus({laoding: true, status:false, message: ''})
const {job_id} = details
let reqData = {
job_id: details.job_id
job_id: details.job_id,
job_uid: details.job_uid
} // DATA NEEDED BY THE API
console.log(reqData)
// API CALL TO DELETE A JOB
ApiCall.deleteJob(reqData).then(res => {
if(res.data.internal_return < 0){
setRequestStatus({laoding: false, status:false, message: 'Could not perform the request, try again!'})
@@ -26,6 +27,8 @@ function DeleteJobPopout({details, onClose, situation}) {
setRequestStatus({laoding: false, status:true, message: 'Job deleted successfully'})
setTimeout(()=>{
navigate('/myjobs', {replace: true})
onClose()
window.location.reload()
}, 1000)
}).catch(error => {
setRequestStatus({laoding: false, status:false, message: 'Opps! something went wrong, try again'})