From 83f9d5a1f4268dbe2d05ae6c1f9030b947a3c006 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Thu, 8 Jun 2023 20:57:19 +0100 Subject: [PATCH] popup component for worker active job added --- .../JobActions/CurrentTaskAction.jsx | 123 +++++++++++++++++- .../JobActions/IndexJobActions.jsx | 12 +- 2 files changed, 126 insertions(+), 9 deletions(-) diff --git a/src/components/MyActiveJobs/JobActions/CurrentTaskAction.jsx b/src/components/MyActiveJobs/JobActions/CurrentTaskAction.jsx index 8d94b4f..dac45e2 100644 --- a/src/components/MyActiveJobs/JobActions/CurrentTaskAction.jsx +++ b/src/components/MyActiveJobs/JobActions/CurrentTaskAction.jsx @@ -1,6 +1,37 @@ -import React from 'react' +import React, { useState, useRef } from 'react' + +import ModalCom from '../../Helpers/ModalCom' +import LoadingSpinner from '../../Spinners/LoadingSpinner' + +function CurrentTaskAction({jobDetails}) { + + const [checked, setChecked] = useState(false) + + const [reqStatus, setReqStatus] = useState({loading:false, status: false, message: ''}) + + let [popUp, setPopUp] = useState(false) + + const popUpHandler = () => { + if(popUp){ + setChecked(false) + } + setPopUp(prev => !prev) + } + + // FUNCTION TO HANDLE WHEN USER CLICKS ON SEND FOR REVIEW AND ACCEPTANCE + const taskCompletedSubmit = () => { + setReqStatus({loading:true, status: false, message: ''}) + if(!checked){ + setReqStatus({loading:false, status: false, message: 'Please check the box above'}) + return setTimeout(()=>{ + setReqStatus({loading:false, status: false, message: ''}) + }, 3000) + } + setTimeout(()=>{ + setReqStatus({loading:false, status: false, message: ''}) + }, 3000) + } -function CurrentTaskAction() { return (
@@ -19,7 +50,7 @@ function CurrentTaskAction() {
-
@@ -28,7 +59,93 @@ function CurrentTaskAction() { + {popUp && ( + +
+
+

+ Confirm Completion +

+ +
+
+
+
+ {setChecked(prev => !prev)}} + className='w-6 h-6 text-sky-blue bg-gray-100 focus:ring-sky-blue' + /> +

If you have completed this task

+
+
+ {reqStatus.loading ? + + : + + } +
+ + {/* FOR SUCCESS/ERROR DISPLAY SECTION*/} +
+ {reqStatus.message != "" && + (!reqStatus.status ? ( +
+ {reqStatus.message} +
+ ) : ( + reqStatus.status && ( +
+ {reqStatus.message} +
+ ) + ))} +
+ {/* END OF FOR SUCCESS/ERROR DISPLAY SECTION*/} +
+ + {/* cancel btn */} +
+ +
+
+
+
+ )}
) } diff --git a/src/components/MyActiveJobs/JobActions/IndexJobActions.jsx b/src/components/MyActiveJobs/JobActions/IndexJobActions.jsx index d718675..c7646f7 100644 --- a/src/components/MyActiveJobs/JobActions/IndexJobActions.jsx +++ b/src/components/MyActiveJobs/JobActions/IndexJobActions.jsx @@ -16,11 +16,11 @@ function IndexJobActions({details}) { // FUNCTION TO RENDER SPECIFIC JOB ACTION case 'OWNER': return (()=>{ if(description == 'ACTIVE'){ - return + return }else if(description == 'PASTDUE'){ - return + return }else if(description == 'REVIEW'){ - return + return } else { return null } @@ -28,11 +28,11 @@ function IndexJobActions({details}) { // FUNCTION TO RENDER SPECIFIC JOB ACTION case 'WORKER': return (()=>{ if(description == 'ACTIVE'){ - return + return }else if(description == 'PASTDUE'){ - return + return }else if(description == 'REVIEW'){ - return + return } else { return null }