From dfca65a59daf3e1c8fa983a325be493ad82615fa Mon Sep 17 00:00:00 2001 From: samau3 Date: Wed, 18 Sep 2024 22:12:35 -0700 Subject: [PATCH] Update check states only when field data are successfully sent to server --- .../src/pages/patients/PatientRegistration.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/pages/patients/PatientRegistration.jsx b/client/src/pages/patients/PatientRegistration.jsx index 90e64769..53fadca1 100644 --- a/client/src/pages/patients/PatientRegistration.jsx +++ b/client/src/pages/patients/PatientRegistration.jsx @@ -342,8 +342,8 @@ export default function PatientRegistration() { showSuccessNotification( 'Patient basic information has been successfully registered.', ); - setVisitedSections((prevVisitedSections) => ({ - ...prevVisitedSections, + setShowCheck((prevShowCheck) => ({ + ...prevShowCheck, patientData: true, })); return; @@ -358,6 +358,10 @@ export default function PatientRegistration() { showSuccessNotification( 'Patient basic information has been successfully updated.', ); + setShowCheck((prevShowCheck) => ({ + ...prevShowCheck, + patientData: true, + })); return; } throw new Error('Failed to update patient.'); @@ -385,6 +389,10 @@ export default function PatientRegistration() { showSuccessNotification( 'Patient information has been successfully updated.', ); + setShowCheck((prevShowCheck) => ({ + ...prevShowCheck, + [Object.keys(data)[0]]: true, + })); return; } if (res.status === StatusCodes.BAD_REQUEST) { @@ -432,11 +440,6 @@ export default function PatientRegistration() { [value]: true, })); - setShowCheck((prevShowCheck) => ({ - ...prevShowCheck, - [openedSection]: true, - })); - if (openedSection === 'patientData') { const patientData = { ...form.getValues().patientData,