From c9ad84c3a800e6d52abff9e0cb8199eb553abdd8 Mon Sep 17 00:00:00 2001 From: Potenz Date: Fri, 29 Aug 2025 14:44:31 +0530 Subject: [PATCH] save and claim button added --- .../components/patients/add-patient-modal.tsx | 31 +++++++++++++++++-- apps/Frontend/src/pages/claims-page.tsx | 13 +++++++- apps/Frontend/src/pages/patients-page.tsx | 9 +++++- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/apps/Frontend/src/components/patients/add-patient-modal.tsx b/apps/Frontend/src/components/patients/add-patient-modal.tsx index 43021b4..1d32f80 100644 --- a/apps/Frontend/src/components/patients/add-patient-modal.tsx +++ b/apps/Frontend/src/components/patients/add-patient-modal.tsx @@ -36,7 +36,9 @@ interface AddPatientModalProps { // Define the ref type export type AddPatientModalRef = { shouldSchedule: boolean; + shouldClaim: boolean; navigateToSchedule: (patientId: number) => void; + navigateToClaim: (patientId: number) => void; }; export const AddPatientModal = forwardRef< @@ -51,6 +53,7 @@ export const AddPatientModal = forwardRef< const isEditing = !!patient; const [, navigate] = useLocation(); const [saveAndSchedule, setSaveAndSchedule] = useState(false); + const [saveAndClaim, setSaveAndClaim] = useState(false); const patientFormRef = useRef(null); // Ref for PatientForm // Set up the imperativeHandle to expose functionality to the parent component @@ -65,9 +68,14 @@ export const AddPatientModal = forwardRef< useImperativeHandle(ref, () => ({ shouldSchedule: saveAndSchedule, + shouldClaim: saveAndClaim, // ✅ NEW navigateToSchedule: (patientId: number) => { navigate(`/appointments?newPatient=${patientId}`); }, + navigateToClaim: (patientId: number) => { + // ✅ NEW + navigate(`/claims?newPatient=${patientId}`); + }, })); const handleFormSubmit = (data: InsertPatient | UpdatePatient) => { @@ -79,10 +87,15 @@ export const AddPatientModal = forwardRef< }; const handleSaveAndSchedule = () => { + setSaveAndClaim(false); // ensure only one flag at a time setSaveAndSchedule(true); - if (patientFormRef.current) { - patientFormRef.current.submit(); - } + patientFormRef.current?.submit(); + }; + + const handleSaveAndClaim = () => { + setSaveAndSchedule(false); // ensure only one flag at a time + setSaveAndClaim(true); + patientFormRef.current?.submit(); }; return ( @@ -120,6 +133,18 @@ export const AddPatientModal = forwardRef< Cancel + {!isEditing && ( + + )} + {!isEditing && (