From 8419e26a4ec781b05b898dac8ae7431a6cb9f45e Mon Sep 17 00:00:00 2001 From: vipeeshpavithran Date: Thu, 14 Sep 2023 16:36:20 +0530 Subject: [PATCH] Refactored handle form submission function for first section --- src/Components/Interface/Patient.tsx | 14 ++ src/Components/PatientForm/PatientForm.tsx | 111 ++++++-------- .../PatientForm/PersonalSection1.tsx | 137 ++++++++---------- 3 files changed, 120 insertions(+), 142 deletions(-) create mode 100644 src/Components/Interface/Patient.tsx diff --git a/src/Components/Interface/Patient.tsx b/src/Components/Interface/Patient.tsx new file mode 100644 index 0000000..a566837 --- /dev/null +++ b/src/Components/Interface/Patient.tsx @@ -0,0 +1,14 @@ +export interface Patient { + fullName: string; + homePhone: string; + cellPhone: string; + email: string; + age: number | string; + dateOfBirth: string; + socialSecurityNumber: string; + mailingAddress: string; + city: string; + state: string; + zipCode: string; + gender: string; +} diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx index bc4216e..355e1df 100644 --- a/src/Components/PatientForm/PatientForm.tsx +++ b/src/Components/PatientForm/PatientForm.tsx @@ -35,7 +35,8 @@ import PatientImageMarker from '../ImageMarker/PatientImageMarker'; import ViewPatientImageMarker from '../ImageMarker/ViewPatientImageMarker'; import AlertDialog from '../Helper/AlertDialogBox'; import SignatureComponent from '../Helper/SignatureComponent'; -import { Link, useLocation } from 'react-router-dom'; +import { Link, useLocation } from 'react-router-dom'; +import { Patient } from '../Interface/Patient'; const Accordion = styled((props: AccordionProps) => ( @@ -91,36 +92,11 @@ export default function PatientForm({ type }: Props) { const [section7Data, setSection7Data] = React.useState({}); const [section8Data, setSection8Data] = React.useState({}); const [allPatientData, setAllPatientData] = React.useState([]); - const [patientDetailsButtonFlag, setPatientDetailsButtonFlag ] = React.useState(false) + const [patientDetailsButtonFlag, setPatientDetailsButtonFlag] = + React.useState(false); - const handleFormSection1Data = ( - fullName?: string | undefined, - homePhone?: string | undefined, - cellPhone?: string | undefined, - email?: string | undefined, - age?: number | undefined | string, - dateOfBirth?: string | undefined, - socialSecurityNumber?: string | undefined, - mailingAddress?: string | undefined, - city?: string | undefined, - state?: string | undefined, - zipCode?: string | undefined, - gender?: string | undefined - ) => { - setSection1Data({ - fullName, - homePhone, - cellPhone, - email, - age, - dateOfBirth, - socialSecurityNumber, - mailingAddress, - city, - state, - zipCode, - gender, - }); + const handleFormSection1Data = (patient: Patient) => { + setSection1Data(patient); }; const handleFormSection2Data = ( @@ -375,7 +351,7 @@ export default function PatientForm({ type }: Props) { section1Data.mailingAddress !== '' ) { TextFile(); - setPatientDetailsButtonFlag(true) + setPatientDetailsButtonFlag(true); setAlertProps({ open: true, severity: 'success', @@ -659,11 +635,16 @@ export default function PatientForm({ type }: Props) { {type !== 'display' ? ( <> - - - Signature: - - + + + {' '} + Signature: + + + @@ -708,37 +689,35 @@ export default function PatientForm({ type }: Props) { - {patientDetailsButtonFlag && type!=='display'? - - - :null} + {patientDetailsButtonFlag && type !== 'display' ? ( + + + + ) : null} - {type=='display'? - - - :null} + {type == 'display' ? ( + + + + ) : null}