Skip to content

Commit

Permalink
Merge pull request #860 from konavivekramakrishna/fix#create-patient
Browse files Browse the repository at this point in the history
Reset Form after Submission to Fix Notification Popup
  • Loading branch information
mozzy11 authored Mar 22, 2024
2 parents 924896a + 1f94029 commit ebc2507
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions frontend/src/components/patient/CreatePatientForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -536,6 +540,7 @@ function CreatePatientForm(props) {
dateFormat="d/m/Y"
datePickerType="single"
light={true}
maxDate={new Date()}
className="inputText"
>
<DatePickerInput
Expand Down

0 comments on commit ebc2507

Please sign in to comment.