From 6a259038f5212b2be1141b5cec97722e0979082a Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 22 Mar 2024 10:49:27 +0530 Subject: [PATCH] reset create form after submit --- .../components/patient/CreatePatientForm.js | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/patient/CreatePatientForm.js b/frontend/src/components/patient/CreatePatientForm.js index 28f802b42e..8a327fba36 100644 --- a/frontend/src/components/patient/CreatePatientForm.js +++ b/frontend/src/components/patient/CreatePatientForm.js @@ -283,23 +283,27 @@ function CreatePatientForm(props) { setHealthDistricts(districts); }; - const handleSubmit = (values) => { - if ("years" in values) { - delete values.years; - } - if ("months" in values) { - delete values.months; - } - if ("days" in values) { - delete values.days; + const handleSubmit = async (values, { resetForm }) => { + if ("years" in values) { + delete values.years; + } + if ("months" in values) { + delete values.months; + } + if ("days" in values) { + delete values.days; + } + console.debug(JSON.stringify(values)); + postToOpenElisServer( + "/rest/patient-management", + JSON.stringify(values), + (status) => { + handlePost(status); + resetForm({ values: CreatePatientFormValues }); } - console.debug(JSON.stringify(values)); - postToOpenElisServer( - "/rest/patient-management", - JSON.stringify(values), - handlePost, - ); - }; + ); +}; + const handlePost = (status) => { setNotificationVisible(true); @@ -536,6 +540,7 @@ function CreatePatientForm(props) { dateFormat="d/m/Y" datePickerType="single" light={true} + maxDate={new Date()} className="inputText" >