Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable submit buttons in patient registration and encounter form when request is being processed #8353

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1501,12 +1501,14 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
onClick={() =>
navigate(`/facility/${facilityId}/patient/${patientId}`)
}
disabled={isLoading}
/>
<Submit
onClick={handleSubmit}
label={
isUpdate ? "Update Consultation" : "Create Consultation"
}
disabled={isLoading}
/>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Form = <T extends FormDetails>({
}, [asyncGetDefaults]);

const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
setIsLoading(true);
event.preventDefault();
event.stopPropagation();

Expand All @@ -66,6 +67,7 @@ const Form = <T extends FormDetails>({
errors: { ...state.errors, ...errors },
});
}
setIsLoading(false);
};

const { Provider, Consumer } = useMemo(() => createFormContext<T>(), []);
Expand Down Expand Up @@ -117,6 +119,7 @@ const Form = <T extends FormDetails>({
<Cancel
onClick={props.onCancel}
label={props.cancelLabel ?? "Cancel"}
disabled={isLoading}
/>
<Submit
data-testid="submit-button"
Expand Down
1 change: 1 addition & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Loading