From c0905d9c050b43f7a7d14e568b03f13be11208ac Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 19 Aug 2024 20:09:02 +0530 Subject: [PATCH 1/2] Disable submit buttons in patient registration and encounter form when request is being processed --- src/Components/Facility/ConsultationForm.tsx | 2 ++ src/Components/Form/Form.tsx | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 69fead157e0..9c1f276c312 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -1501,12 +1501,14 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { onClick={() => navigate(`/facility/${facilityId}/patient/${patientId}`) } + disabled={isLoading} /> diff --git a/src/Components/Form/Form.tsx b/src/Components/Form/Form.tsx index fccc579286c..f371de54783 100644 --- a/src/Components/Form/Form.tsx +++ b/src/Components/Form/Form.tsx @@ -44,6 +44,7 @@ const Form = ({ }, [asyncGetDefaults]); const handleSubmit = async (event: React.FormEvent) => { + setIsLoading(true); event.preventDefault(); event.stopPropagation(); @@ -66,6 +67,7 @@ const Form = ({ errors: { ...state.errors, ...errors }, }); } + setIsLoading(false); }; const { Provider, Consumer } = useMemo(() => createFormContext(), []); @@ -117,6 +119,7 @@ const Form = ({ Date: Mon, 19 Aug 2024 20:12:58 +0530 Subject: [PATCH 2/2] added additional safety for disables in patient register --- src/Components/Patient/PatientRegister.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 45251327406..65dbd4deb33 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1127,6 +1127,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { validate={validateForm} onSubmit={handleSubmit} submitLabel={buttonText} + disabled={isLoading} onCancel={() => navigate("/facility")} className="bg-transparent px-1 py-2 md:px-2" onDraftRestore={(newState) => {