diff --git a/src/Components/PatientForm/OtherDetails8.tsx b/src/Components/PatientForm/OtherDetails8.tsx index 295805a..3ad757c 100644 --- a/src/Components/PatientForm/OtherDetails8.tsx +++ b/src/Components/PatientForm/OtherDetails8.tsx @@ -1,10 +1,10 @@ import { Grid, FormLabel, TextField, FormControl, RadioGroup, FormControlLabel, Radio } from "@mui/material"; import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; -import React from "react"; +import React, { useEffect } from "react"; import { LocalizationProvider, DatePicker } from '@mui/x-date-pickers'; import dayjs from "dayjs"; -interface FormValues { +interface Patient { familyHistory: string; sleep: string; pillow:string; @@ -14,9 +14,21 @@ interface FormValues { menstralCycle: any; } -export default function OtherDetails8(){ + type Props = { + handleFormSection8Data:( + familyHistory: string|undefined, + sleep: string|undefined, + pillow:string|undefined, + orthotics:string|undefined, + brestExam: any, + pregnancy:string|undefined, + menstralCycle: any, + )=> void + } + +export default function OtherDetails8({handleFormSection8Data}:Props){ - const [values, setValues] = React.useState({ + const [patient, setPatient] = React.useState({ familyHistory: '', sleep: '', pillow:'', @@ -26,6 +38,18 @@ export default function OtherDetails8(){ menstralCycle: dayjs('2022-04-17'), }); + useEffect(()=>{ + handleFormSection8Data( + patient.familyHistory, + patient.sleep, + patient.pillow, + patient.orthotics, + patient.brestExam=dayjs(patient.brestExam), + patient.pregnancy, + patient.menstralCycle=dayjs(patient.menstralCycle) + ) + },[patient]) + const formatDate = (inputDate:any) => { const date = new Date(inputDate); const year = date.getUTCFullYear(); @@ -35,7 +59,8 @@ export default function OtherDetails8(){ return `${year}-${month}-${day}`; }; - console.log("dsfdsfsdf",values) + + return( <> @@ -48,7 +73,7 @@ export default function OtherDetails8(){ label="" name='explanation' onChange={(event:any) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, familyHistory: event.target.value, })); @@ -62,9 +87,9 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, - educationLevel: event.target.value, + sleep: event.target.value, })); }} > @@ -81,7 +106,7 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, pillow: event.target.value, })); @@ -99,7 +124,7 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, orthotics: event.target.value, })); @@ -116,10 +141,10 @@ export default function OtherDetails8(){ { const formattedDate = formatDate(event) - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, brestExam: formattedDate, })); @@ -140,9 +165,9 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, - orthotics: event.target.value, + pregnancy: event.target.value, })); }} > @@ -157,10 +182,10 @@ export default function OtherDetails8(){ { const formattedDate = formatDate(event) - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, menstralCycle: formattedDate, })); diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx index 970389b..b9f5c10 100644 --- a/src/Components/PatientForm/PatientForm.tsx +++ b/src/Components/PatientForm/PatientForm.tsx @@ -84,6 +84,7 @@ export default function PatientForm(){ const [section5Data, setSection5Data] = React.useState({}); const [section6Data, setSection6Data] = React.useState({}); const [section7Data, setSection7Data] = React.useState({}); + const [section8Data, setSection8Data] = React.useState({}); const handleFormSection1Data = ( fullName?: string|undefined, @@ -311,6 +312,26 @@ export default function PatientForm(){ drugsExplanation, }) } + + const handleFormSection8Data = ( + familyHistory: string|undefined, + sleep: string|undefined, + pillow:string|undefined, + orthotics:string|undefined, + brestExam: any, + pregnancy:string|undefined, + menstralCycle: any, + ) =>{ + setSection8Data({ + familyHistory, + sleep, + pillow, + orthotics, + brestExam, + pregnancy, + menstralCycle, + }) + } const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); @@ -325,7 +346,7 @@ export default function PatientForm(){ setIsChecked(event.target.checked); }; - console.log("wyeytweevfde",section7Data) + console.log("wyeytweevfde",section8Data) return( @@ -420,7 +441,7 @@ export default function PatientForm(){ - +