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 cd7c109a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 params = useParams();
const navigate = useNavigate();
const [disabled, setDisabled] = useState(false);
const { addError, removeError } = useAPIError();
@ -58,6 +59,7 @@ export default function TaskShow() {
const processSubmitResult = (result: any) => {
removeError();
setDisabled(false);
if (result.ok) {
navigate(`/tasks`);
} else if (result.process_instance_id) {
@ -68,13 +70,20 @@ export default function TaskShow() {
};
const handleFormSubmit = (event: any) => {
if (disabled) {
return;
}
setDisabled(true);
removeError();
const dataToSubmit = event.formData;
delete dataToSubmit.isManualTask;
HttpService.makeCallToBackend({
path: `/tasks/${params.process_instance_id}/${params.task_id}`,
successCallback: processSubmitResult,
failureCallback: addError,
failureCallback: (error: any) => {
addError(error);
setDisabled(false);
},
httpMethod: 'PUT',
postBody: dataToSubmit,
});