Merge pull request #124 from sartography/feature/ui_tweaks

Feature/UI tweaks
This commit is contained in:
Dan Funk 2023-02-03 14:40:06 -05:00 committed by GitHub
commit c563a1c403
1 changed files with 10 additions and 1 deletions

View File

@ -26,6 +26,7 @@ export default function TaskShow() {
const [userTasks, setUserTasks] = useState(null); const [userTasks, setUserTasks] = useState(null);
const params = useParams(); const params = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
const [disabled, setDisabled] = useState(false);
const { addError, removeError } = useAPIError(); const { addError, removeError } = useAPIError();
@ -58,6 +59,7 @@ export default function TaskShow() {
const processSubmitResult = (result: any) => { const processSubmitResult = (result: any) => {
removeError(); removeError();
setDisabled(false);
if (result.ok) { if (result.ok) {
navigate(`/tasks`); navigate(`/tasks`);
} else if (result.process_instance_id) { } else if (result.process_instance_id) {
@ -68,13 +70,20 @@ export default function TaskShow() {
}; };
const handleFormSubmit = (event: any) => { const handleFormSubmit = (event: any) => {
if (disabled) {
return;
}
setDisabled(true);
removeError(); removeError();
const dataToSubmit = event.formData; const dataToSubmit = event.formData;
delete dataToSubmit.isManualTask; delete dataToSubmit.isManualTask;
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
path: `/tasks/${params.process_instance_id}/${params.task_id}`, path: `/tasks/${params.process_instance_id}/${params.task_id}`,
successCallback: processSubmitResult, successCallback: processSubmitResult,
failureCallback: addError, failureCallback: (error: any) => {
addError(error);
setDisabled(false);
},
httpMethod: 'PUT', httpMethod: 'PUT',
postBody: dataToSubmit, postBody: dataToSubmit,
}); });