Skip to content

Commit

Permalink
Update check states only when field data are successfully sent to server
Browse files Browse the repository at this point in the history
  • Loading branch information
samau3 committed Sep 19, 2024
1 parent 06819ac commit dfca65a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions client/src/pages/patients/PatientRegistration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -432,11 +440,6 @@ export default function PatientRegistration() {
[value]: true,
}));

setShowCheck((prevShowCheck) => ({
...prevShowCheck,
[openedSection]: true,
}));

if (openedSection === 'patientData') {
const patientData = {
...form.getValues().patientData,
Expand Down

0 comments on commit dfca65a

Please sign in to comment.