Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 976b4afbbf | |||
| 5f0364df10 |
@@ -1,10 +1,16 @@
|
|||||||
import React, { useState, useRef } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
import ModalCom from '../../Helpers/ModalCom'
|
import ModalCom from '../../Helpers/ModalCom'
|
||||||
import LoadingSpinner from '../../Spinners/LoadingSpinner'
|
import LoadingSpinner from '../../Spinners/LoadingSpinner'
|
||||||
|
|
||||||
|
import usersService from '../../../services/UsersService'
|
||||||
|
|
||||||
function CurrentTaskAction({jobDetails}) {
|
function CurrentTaskAction({jobDetails}) {
|
||||||
|
|
||||||
|
const apiCall = new usersService()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const [checked, setChecked] = useState(false)
|
const [checked, setChecked] = useState(false)
|
||||||
|
|
||||||
const [reqStatus, setReqStatus] = useState({loading:false, status: false, message: ''})
|
const [reqStatus, setReqStatus] = useState({loading:false, status: false, message: ''})
|
||||||
@@ -20,16 +26,37 @@ function CurrentTaskAction({jobDetails}) {
|
|||||||
|
|
||||||
// FUNCTION TO HANDLE WHEN USER CLICKS ON SEND FOR REVIEW AND ACCEPTANCE
|
// FUNCTION TO HANDLE WHEN USER CLICKS ON SEND FOR REVIEW AND ACCEPTANCE
|
||||||
const taskCompletedSubmit = () => {
|
const taskCompletedSubmit = () => {
|
||||||
setReqStatus({loading:true, status: false, message: ''})
|
setReqStatus({loading:true, status: false, message: ''}) // Sets loading spinner active
|
||||||
if(!checked){
|
let reqData = {
|
||||||
|
contract: jobDetails.contract,
|
||||||
|
contract_uid: jobDetails.contract_uid,
|
||||||
|
job_action: 'NOTIFY_COMPLETE',
|
||||||
|
}
|
||||||
|
if(!checked){ // checks that checkbox is selected
|
||||||
setReqStatus({loading:false, status: false, message: 'Please check the box above'})
|
setReqStatus({loading:false, status: false, message: 'Please check the box above'})
|
||||||
return setTimeout(()=>{
|
return setTimeout(()=>{
|
||||||
setReqStatus({loading:false, status: false, message: ''})
|
setReqStatus({loading:false, status: false, message: ''})
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
setTimeout(()=>{
|
|
||||||
setReqStatus({loading:false, status: false, message: ''})
|
// API CALL TO MARK TASK AS COMPLETED BY WORKER
|
||||||
}, 3000)
|
apiCall.taskCompleted(reqData).then((res)=>{
|
||||||
|
if(res.status != 200 || res.data.internal_return < 0){
|
||||||
|
setReqStatus({loading:false, status: false, message: 'unable to complete request. Try again'})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setReqStatus({loading:false, status: true, message: 'Task marked completed successfully'})
|
||||||
|
setTimeout(()=>{ // Sets popout to false and navigates user to /mytask after 3 seconds
|
||||||
|
popUpHandler()
|
||||||
|
navigate('/mytask', {replace: true})
|
||||||
|
}, 3000)
|
||||||
|
}).catch(err => {
|
||||||
|
setReqStatus({loading:false, status: false, message: 'Opps! Network error. Try again'})
|
||||||
|
}).finally(()=>{
|
||||||
|
setTimeout(()=>{
|
||||||
|
setReqStatus({loading:false, status: false, message: ''})
|
||||||
|
}, 3000)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -653,6 +653,18 @@ class usersService {
|
|||||||
return this.postAuxEnd("/offersresponse", postData);
|
return this.postAuxEnd("/offersresponse", postData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// END POINT FOR WORKER TO MARK TASK AS COMPLETED
|
||||||
|
taskCompleted(reqData) {
|
||||||
|
var postData = {
|
||||||
|
uid: localStorage.getItem("uid"),
|
||||||
|
member_id: localStorage.getItem("member_id"),
|
||||||
|
sessionid: localStorage.getItem("session_token"),
|
||||||
|
action: 14015,
|
||||||
|
...reqData,
|
||||||
|
};
|
||||||
|
return this.postAuxEnd("/activetaskstatus", postData);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- 20:27:30.118 FLOG_MAX [757411]: REQ_STRING(username)
|
- 20:27:30.118 FLOG_MAX [757411]: REQ_STRING(username)
|
||||||
- 20:27:30.118 FLOG_MAX [757411]: REQ_STRING(password)
|
- 20:27:30.118 FLOG_MAX [757411]: REQ_STRING(password)
|
||||||
|
|||||||
Reference in New Issue
Block a user