diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx index 42dd220..970389b 100644 --- a/src/Components/PatientForm/PatientForm.tsx +++ b/src/Components/PatientForm/PatientForm.tsx @@ -83,6 +83,7 @@ export default function PatientForm(){ const [section4Data, setSection4Data] = React.useState({}); const [section5Data, setSection5Data] = React.useState({}); const [section6Data, setSection6Data] = React.useState({}); + const [section7Data, setSection7Data] = React.useState({}); const handleFormSection1Data = ( fullName?: string|undefined, @@ -267,6 +268,49 @@ export default function PatientForm(){ explanation, }) } + + + const handleFormSection7Data = ( + hobbies: string|undefined, + educationLevel: string|undefined, + excercise: string|undefined, + excerciseExplanation: string|undefined, + tobacco: string|undefined, + tobaccoExplanation: string|undefined, + alcohol: string|undefined, + alcoholExplanation: string|undefined, + healthyDiet: string|undefined, + healthyDietExplanation: string|undefined, + sleep: string|undefined, + sleepExplanation: string|undefined, + workSchool: string|undefined, + workSchoolExplanation: string|undefined, + familyLife: string|undefined, + familyLifeExplanation: string|undefined, + drugs: string|undefined, + drugsExplanation:string|undefined, + ) =>{ + setSection7Data({ + hobbies, + educationLevel, + excercise, + excerciseExplanation, + tobacco, + tobaccoExplanation, + alcohol, + alcoholExplanation, + healthyDiet, + healthyDietExplanation, + sleep, + sleepExplanation, + workSchool, + workSchoolExplanation, + familyLife, + familyLifeExplanation, + drugs, + drugsExplanation, + }) + } const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); @@ -281,7 +325,7 @@ export default function PatientForm(){ setIsChecked(event.target.checked); }; - console.log("wyeytweevfde",section6Data) + console.log("wyeytweevfde",section7Data) return( @@ -366,7 +410,7 @@ export default function PatientForm(){ - + diff --git a/src/Components/PatientForm/RecreationalHobbiesSection7.tsx b/src/Components/PatientForm/RecreationalHobbiesSection7.tsx index 2a860fd..2304bbe 100644 --- a/src/Components/PatientForm/RecreationalHobbiesSection7.tsx +++ b/src/Components/PatientForm/RecreationalHobbiesSection7.tsx @@ -1,7 +1,7 @@ import { FormControl, FormControlLabel, FormLabel, Grid, Radio, RadioGroup, TextField } from "@mui/material"; -import React from "react"; +import React, { useEffect } from "react"; -interface FormValues { +interface Patient { hobbies: string; educationLevel: string; excercise: string; @@ -22,8 +22,31 @@ interface FormValues { drugsExplanation:string; } -export default function RecreationalHobbiesSection7(){ - const [values, setValues] = React.useState({ + type Props = { + handleFormSection7Data:( + hobbies: string|undefined, + educationLevel: string|undefined, + excercise: string|undefined, + excerciseExplanation: string|undefined, + tobacco: string|undefined, + tobaccoExplanation: string|undefined, + alcohol: string|undefined, + alcoholExplanation: string|undefined, + healthyDiet: string|undefined, + healthyDietExplanation: string|undefined, + sleep: string|undefined, + sleepExplanation: string|undefined, + workSchool: string|undefined, + workSchoolExplanation: string|undefined, + familyLife: string|undefined, + familyLifeExplanation: string|undefined, + drugs: string|undefined, + drugsExplanation:string|undefined, + )=> void + } + +export default function RecreationalHobbiesSection7({handleFormSection7Data}:Props){ + const [patient, setPatient] = React.useState({ hobbies: '', educationLevel: '', excercise:'', @@ -43,6 +66,31 @@ export default function RecreationalHobbiesSection7(){ drugs: '', drugsExplanation:'' }); + + + useEffect(()=>{ + handleFormSection7Data( + patient.hobbies, + patient.educationLevel, + patient.excercise, + patient.excerciseExplanation, + patient.tobacco, + patient.tobaccoExplanation, + patient.alcohol, + patient.alcoholExplanation, + patient.healthyDiet, + patient.healthyDietExplanation, + patient.sleep, + patient.sleepExplanation, + patient.workSchool, + patient.workSchoolExplanation, + patient.familyLife, + patient.familyLifeExplanation, + patient.drugs, + patient.drugsExplanation + ) + },[patient]) + return( <> @@ -55,7 +103,7 @@ export default function RecreationalHobbiesSection7(){ label="" name='explanation' onChange={(event:any) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, hobbies: event.target.value, })); @@ -69,7 +117,7 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, educationLevel: event.target.value, })); @@ -91,7 +139,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, excercise: event.target.value, })); @@ -105,12 +153,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, excerciseExplanation: event.target.value, })); @@ -125,7 +173,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, tobacco: event.target.value, })); @@ -139,12 +187,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, excerciseExplanation: event.target.value, })); @@ -159,7 +207,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, alcohol: event.target.value, })); @@ -173,12 +221,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, alcoholExplanation: event.target.value, })); @@ -193,7 +241,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, healthyDiet: event.target.value, })); @@ -207,12 +255,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, healthyDietExplanation: event.target.value, })); @@ -227,7 +275,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, sleep: event.target.value, })); @@ -241,12 +289,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, sleepExplanation: event.target.value, })); @@ -261,7 +309,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, workSchool: event.target.value, })); @@ -275,12 +323,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, workSchool: event.target.value, })); @@ -295,7 +343,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, familyLife: event.target.value, })); @@ -309,12 +357,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, familyLifeExplanation: event.target.value, })); @@ -329,7 +377,7 @@ export default function RecreationalHobbiesSection7(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, drugs: event.target.value, })); @@ -343,12 +391,12 @@ export default function RecreationalHobbiesSection7(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, drugsExplanation: event.target.value, }));