From 81fb560898dd83aeffdd456211de5fc402312095 Mon Sep 17 00:00:00 2001 From: vipeeshpavithran Date: Thu, 7 Sep 2023 14:31:45 +0530 Subject: [PATCH] Screen responsive changes --- .../PatientForm/PersonalSection1.tsx | 884 ++++++++++-------- 1 file changed, 515 insertions(+), 369 deletions(-) diff --git a/src/Components/PatientForm/PersonalSection1.tsx b/src/Components/PatientForm/PersonalSection1.tsx index bd55434..4681b2d 100644 --- a/src/Components/PatientForm/PersonalSection1.tsx +++ b/src/Components/PatientForm/PersonalSection1.tsx @@ -1,389 +1,535 @@ import * as React from 'react'; -import { Button, FormControl, FormControlLabel, FormLabel, Grid, Paper, Radio, RadioGroup, TextField } from '@mui/material'; +import { + Button, + FormControl, + FormControlLabel, + FormLabel, + Grid, + Paper, + Radio, + RadioGroup, + TextField, +} from '@mui/material'; import { LocalizationProvider, DatePicker } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { useEffect } from 'react'; 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; - } + 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; +} - type Props = { - 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, - )=> void - patientDataDiplay:any; - type:string; - } - +type Props = { + 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 + ) => void; + patientDataDiplay: any; + type: string; +}; -export default function PersonalSection({handleFormSection1Data,patientDataDiplay,type}:Props){ +export default function PersonalSection({ + handleFormSection1Data, + patientDataDiplay, + type, +}: Props) { + const [birthDateValue, setBirthDateValue] = React.useState(); + const [patient, setPatient] = React.useState({ + fullName: '', + fullNameError: false, + homePhone: '', + cellPhone: '', + cellPhoneError: false, + email: '', + emailError: false, + age: '', + ageError: false, + dateOfBirth: birthDateValue, + socialSecurityNumber: '', + mailingAddress: '', + mailingAddressFalse: false, + city: '', + state: '', + zipCode: '', + gender: 'male', + }); - const [birthDateValue, setBirthDateValue] = React.useState(); - const [patient, setPatient] = React.useState({ - fullName: "", - fullNameError:false, - homePhone: "", - cellPhone: "", - cellPhoneError: false, - email: "", - emailError: false, - age: "", - ageError: false, - dateOfBirth: birthDateValue, - socialSecurityNumber: "", - mailingAddress:"", - mailingAddressFalse:false, - city: "", - state: "", - zipCode: "", - gender: "male", - }); + useEffect(() => { + handleFormSection1Data( + patient.fullName, + patient.homePhone, + patient.cellPhone, + patient.email, + patient.age, + birthDateValue, + patient.socialSecurityNumber, + patient.mailingAddress, + patient.city, + patient.state, + patient.zipCode, + patient.gender + ); + }, [patient]); + return ( + <> + + + { + setPatient((prevValues: any) => ({ + ...prevValues, + fullName: e.target.value, + })); + }} + onBlur={(e) => { + if (e.target.value === '') { + setPatient((prevValues: any) => ({ + ...prevValues, + fullNameError: true, + })); + } else { + setPatient((prevValues: any) => ({ + ...prevValues, + fullNameError: false, + })); + } + }} + required + error={patient.fullNameError} + helperText={patient.fullNameError ? 'Please enter your name' : ''} + /> + - useEffect(()=>{ - handleFormSection1Data( - patient.fullName, - patient.homePhone, - patient.cellPhone, - patient.email, - patient.age, - birthDateValue, - patient.socialSecurityNumber, - patient.mailingAddress, - patient.city, - patient.state, - patient.zipCode, - patient.gender, - ) - },[patient]) + + { + setPatient((prevValues: any) => ({ + ...prevValues, + cellPhone: e.target.value, + })); + }} + onBlur={(e) => { + if (!/^\d{10}$/.test(e.target.value)) { + setPatient((prevValues: any) => ({ + ...prevValues, + cellPhoneError: true, + })); + } else { + setPatient((prevValues: any) => ({ + ...prevValues, + cellPhoneError: false, + })); + } + }} + error={patient.cellPhoneError} + helperText={ + patient.cellPhoneError + ? 'Please enter a valid 10-digit phone number' + : '' + } + /> + - - - return( - <> - - - { - setPatient((prevValues:any) => ({ - ...prevValues, - fullName: e.target.value, - })); - }} - onBlur={(e) => { - if (e.target.value === "") { - setPatient((prevValues:any) => ({ - ...prevValues, - fullNameError: true, - })); - } else { - setPatient((prevValues:any) => ({ - ...prevValues, - fullNameError: false, - })); - } - }} - required - error={patient.fullNameError} - helperText={patient.fullNameError ? "Please enter your name" : ""} - /> - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + homePhone: e.target.value, + })); + }} + // error={!(/^\d{10}$/.test(patient.homePhone))} + // helperText={!(/^\d{10}$/.test(patient.homePhone)) ? "Please enter a valid 10-digit phone number" : ""} + /> + - - - { - setPatient((prevValues:any) => ({ - ...prevValues, - cellPhone: e.target.value, - })); - }} - onBlur={(e) => { - if (!(/^\d{10}$/.test(e.target.value))) { - setPatient((prevValues:any) => ({ - ...prevValues, - cellPhoneError: true, - })); - } else { - setPatient((prevValues:any) => ({ - ...prevValues, - cellPhoneError: false, - })); - } - }} - error={patient.cellPhoneError} - helperText={patient.cellPhoneError? "Please enter a valid 10-digit phone number" : ""} - /> - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + email: e.target.value, + })); + }} + onBlur={(e) => { + if (!/^\S+@\S+\.\S+$/.test(e.target.value)) { + setPatient((prevValues: any) => ({ + ...prevValues, + emailError: true, + })); + } else { + setPatient((prevValues: any) => ({ + ...prevValues, + emailError: false, + })); + } + }} + error={patient.emailError} + helperText={ + patient.emailError ? 'Please enter a valid email address' : '' + } + /> + + + { + setPatient((prevValues: any) => ({ + ...prevValues, + age: e.target.value, + })); + }} + onBlur={(e) => { + if (e.target.value === '') { + setPatient((prevValues: any) => ({ + ...prevValues, + ageError: true, + })); + } else { + setPatient((prevValues: any) => ({ + ...prevValues, + ageError: false, + })); + } + }} + error={patient.ageError} + helperText={patient.ageError ? 'Please enter your age' : ''} + /> + - - { - setPatient((prevValues:any) => ({ - ...prevValues, - homePhone: e.target.value, - })); - }} - // error={!(/^\d{10}$/.test(patient.homePhone))} - // helperText={!(/^\d{10}$/.test(patient.homePhone)) ? "Please enter a valid 10-digit phone number" : ""} - /> - + + + + { + setBirthDateValue(newValue); + }} + renderInput={(params) => ( + + )} + /> + + + - - { - setPatient((prevValues:any) => ({ - ...prevValues, - email: e.target.value, - })); - }} - onBlur={(e) => { - if (!(/^\S+@\S+\.\S+$/.test(e.target.value))) { - setPatient((prevValues:any) => ({ - ...prevValues, - emailError: true, - })); - } else { - setPatient((prevValues:any) => ({ - ...prevValues, - emailError: false, - })); - } - }} - error={patient.emailError} - helperText={patient.emailError? "Please enter a valid email address" : ""} - /> - - - { - setPatient((prevValues:any) => ({ - ...prevValues, - age: e.target.value, - })); - }} - onBlur={(e) => { - if (e.target.value === "") { - setPatient((prevValues:any) => ({ - ...prevValues, - ageError: true, - })); - } else { - setPatient((prevValues:any) => ({ - ...prevValues, - ageError: false, - })); - } - }} - error={patient.ageError} - helperText={patient.ageError ? "Please enter your age" : ""} - - /> - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + socialSecurityNumber: e.target.value, + })); + }} + // onBlur={formik.handleBlur} + // error={formik.touched.socialSecurityNumber && Boolean(formik.errors.socialSecurityNumber)} + // helperText={formik.touched.socialSecurityNumber && formik.errors.socialSecurityNumber} + /> + - - - - { - setBirthDateValue(newValue); - }} - renderInput={(params) => } - /> - - - - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + mailingAddress: e.target.value, + })); + }} + onBlur={(e) => { + if (e.target.value === '') { + setPatient((prevValues: any) => ({ + ...prevValues, + mailingAddressError: true, + })); + } else { + setPatient((prevValues: any) => ({ + ...prevValues, + mailingAddressError: false, + })); + } + }} + error={patient.mailingAddressError} + helperText={ + patient.mailingAddressError + ? 'Please enter your mailing address' + : '' + } + /> + - - { - setPatient((prevValues:any) => ({ - ...prevValues, - socialSecurityNumber: e.target.value, - })); - }} - // onBlur={formik.handleBlur} - // error={formik.touched.socialSecurityNumber && Boolean(formik.errors.socialSecurityNumber)} - // helperText={formik.touched.socialSecurityNumber && formik.errors.socialSecurityNumber} - /> - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + state: e.target.value, + })); + }} + /> + - - { - setPatient((prevValues:any) => ({ - ...prevValues, - mailingAddress: e.target.value, - })); - }} - onBlur={(e) => { - if (e.target.value === "") { - setPatient((prevValues:any) => ({ - ...prevValues, - mailingAddressError: true, - })); - } else { - setPatient((prevValues:any) => ({ - ...prevValues, - mailingAddressError: false, - })); - } - }} - error={patient.mailingAddressError} - helperText={patient.mailingAddressError? "Please enter your mailing address" : ""} - /> - - - - { - setPatient((prevValues:any) => ({ - ...prevValues, - state: e.target.value, - })); - }} - /> - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + city: e.target.value, + })); + }} + /> + - - { - setPatient((prevValues:any) => ({ - ...prevValues, - city: e.target.value, - })); - }} - /> - - - - { - setPatient((prevValues:any) => ({ - ...prevValues, - zipCode: e.target.value, - })); - }} - // onBlur={formik.handleBlur} - // error={formik.touched.zipCode && Boolean(formik.errors.zipCode)} - // helperText={formik.touched.zipCode && formik.errors.zipCode} - /> - + + { + setPatient((prevValues: any) => ({ + ...prevValues, + zipCode: e.target.value, + })); + }} + // onBlur={formik.handleBlur} + // error={formik.touched.zipCode && Boolean(formik.errors.zipCode)} + // helperText={formik.touched.zipCode && formik.errors.zipCode} + /> + - - - Gender - { - setPatient((prevValues:any) => ({ - ...prevValues, - gender: e.target.value, - })); - }} - sx={{display:'flex', flexDirection:'row'}} - > - } label="Male" /> - } label="Female" /> - - - - - - ) -} \ No newline at end of file + + + Gender + { + setPatient((prevValues: any) => ({ + ...prevValues, + gender: e.target.value, + })); + }} + sx={{ display: 'flex', flexDirection: 'row' }} + > + } + label='Male' + /> + } + label='Female' + /> + + + + + + ); +}