From 90444b8a17201ff6bad7d29ed3248b7a640aa1cd Mon Sep 17 00:00:00 2001 From: samau3 Date: Mon, 9 Sep 2024 23:15:21 -0700 Subject: [PATCH] Prevent form data loss from refetching and add guard statement for physician --- client/src/pages/patients/PatientRegistration.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/pages/patients/PatientRegistration.jsx b/client/src/pages/patients/PatientRegistration.jsx index ace29721..18268835 100644 --- a/client/src/pages/patients/PatientRegistration.jsx +++ b/client/src/pages/patients/PatientRegistration.jsx @@ -41,6 +41,10 @@ export default function PatientRegistration() { throw new Error('Failed to fetch patient.'); } }, + // disable retry and refetch on window focus to prevent data loss + // from triggering form.initialize() + retry: false, + refetchOnWindowFocus: false }); const form = useForm({ @@ -130,7 +134,7 @@ export default function PatientRegistration() { setInitialPhysicianData({ id: physician ? physician.id : '', - name: `${physician.firstName} ${physician.lastName}`, + name: physician ? `${physician.firstName} ${physician.lastName}`: '', }); const patientData = {