import { FormControl, Grid, Stack, TextField, useMediaQuery, Select, } from "@mui/material"; import Box from '@mui/material/Box'; import { useTheme } from "@mui/material/styles"; import PropTypes from "prop-types"; import Input from "../common/Input"; import SingleSelect from "../common/SingleSelect"; import SingleSelectNew from "../common/SingleSelectNew"; import MultipleSelectNew from "../common/MultipleSelectNew"; import { Fullscreen } from "@mui/icons-material"; import TextArea from "../common/TextArea"; //import Input from "./Input"; //import Input from "../Input"; const CheckupParameterForm = ({ values, touched, handleBlur, errors, handleChange, setFieldValue, handleSubmit, getFieldProps, keyHealthParameter, lessMoreRisk, healthAdvice, checkupSection, checkupParaValues, checkupType, unitDate, ruleEquation }) => { CheckupParameterForm.propTypes = { values: PropTypes.object.isRequired, touched: PropTypes.object.isRequired, errors: PropTypes.object.isRequired, handleBlur: PropTypes.func.isRequired, handleChange: PropTypes.func.isRequired, setFieldValue: PropTypes.func.isRequired, handleSubmit: PropTypes.func.isRequired, }; const healthkeyselect = ["Capital/non consumeble instruments", "other"]; const lessriskselect = ["Active", "Not Active"]; const moreriskselect = ["Active", "Not Active"]; const lessadviceselect = ["Active", "Not Active"]; const moreadviceselect = ["Active", "Not Active"]; const sectionselect = ["I", "II", "III"]; const inputtypeselect = ["Text", "Number"]; const statusselect = ["Lower", "Middle"]; const editableselect = ["Yes", "No"]; const unitselect = ["Yes", "No"]; const paramselect = ["opd", "daycare", "injury"]; const rulesselect = ["Yes", "No"]; const parentselect = ["Yes", "No"]; const ailment = [{ label: "Yes", id: 1 }]; const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("md")); const isSmaller = useMediaQuery(theme.breakpoints.down("sm")); return ( {errors.parameterName} ) : null } /> option.label} value={ keyHealthParameter.find((option) => option.id === values.keyHealthMapNameId) || null } onChange={(event, newValue) => { setFieldValue("keyHealthMapNameId", newValue ? newValue.id : ""); // Store only the id in Formik }} onBlur={handleBlur} /> {errors.startingRange} ) : null } /> {errors.endingRange} ) : null } /> values.lessRisksIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("lessRisksIds", selectedIds); }} onBlur={handleBlur} options={lessMoreRisk} getOptionLabel={(option) => option.label} // Display the label for each option /> values.moreRisksIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("moreRisksIds", selectedIds); }} onBlur={handleBlur} options={lessMoreRisk} getOptionLabel={(option) => option.label} // Display the label for each option /> values.lessAdvicesIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("lessAdvicesIds", selectedIds); }} onBlur={handleBlur} options={healthAdvice} getOptionLabel={(option) => option.label} // Display the label for each option /> values.moreAdvicesIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("moreAdvicesIds", selectedIds); }} onBlur={handleBlur} options={healthAdvice} getOptionLabel={(option) => option.label} // Display the label for each option /> option.label} value={ checkupSection.find((option) => option.id === values.checkupFormSectionId) || null } onChange={(event, newValue) => { setFieldValue("checkupFormSectionId", newValue ? newValue.id : ""); // Store only the id in Formik }} onBlur={handleBlur} /> {errors.columnorder} ) : null } /> {errors.columnName} ) : null } /> {errors.groupId} ) : null } /> {errors.placeHolderName} ) : null } /> values.parameterValueIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("parameterValueIds", selectedIds); }} onBlur={handleBlur} options={checkupParaValues} getOptionLabel={(option) => option.label} // Display the label for each option /> option} value={values.inputType} onChange={(event, newValue) => { setFieldValue("inputType", newValue ? newValue : ""); // Store only the id in Formik }} onBlur={handleBlur} /> values.checkupTypeIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("checkupTypeIds", selectedIds); }} onBlur={handleBlur} options={checkupType} getOptionLabel={(option) => option.label} // Display the label for each option /> option} // value={values.enabled} // value={values.enabled === "Y" ? "Active" : "Inactive"} // onChange={(event, newValue) => { // setFieldValue("enabled", newValue === "Active" ? 'Y' : "N"); // Store only the id in Formik // }} value={ values.enabled === "Y" ? "Active" : values.enabled === "N" ? "Inactive" : "" // Display empty on start } onChange={(event, newValue) => { if (newValue === "Active") { setFieldValue("enabled", "Y"); } else if (newValue === "Inactive") { setFieldValue("enabled", "N"); } else { setFieldValue("enabled", ""); // Handle clearing the selection } }} onBlur={handleBlur} /> option} value={ values.readonlyField === "Y" ? "Editable" : values.readonlyField === "N" ? "Non-Editable" : "" // Display empty on start } onChange={(event, newValue) => { if (newValue === "Editable") { setFieldValue("readonlyField", "Y"); } else if (newValue === "Non-Editable") { setFieldValue("readonlyField", "N"); } else { setFieldValue("readonlyField", ""); // Handle clearing the selection } }} onBlur={handleBlur} /> option.label} value={ unitDate.find((option) => option.id === values.unitId) || null } onChange={(event, newValue) => { setFieldValue("unitId", newValue ? newValue.id : ""); // Store only the id in Formik }} onBlur={handleBlur} /> option.label} value={ [{label : 'Yes',id : 1},{label : 'No',id : 0}].find((option) => option.id === values.opdParam) || null } onChange={(event, newValue) => { setFieldValue("opdParam", newValue ? newValue.id : ""); // Store only the id in Formik }} onBlur={handleBlur} /> option.label} value={ [{label : 'Yes',id : 1},{label : 'No',id : 0}].find((option) => option.id === values.ipdParam) || null } onChange={(event, newValue) => { setFieldValue("ipdParam", newValue ? newValue.id : ""); // Store only the id in Formik }} onBlur={handleBlur} /> option.label} value={ [{label : 'Yes',id : 1},{label : 'No',id : 0}].find((option) => option.id === values.injParam) || null } onChange={(event, newValue) => { setFieldValue("injParam", newValue ? newValue.id : ""); // Store only the id in Formik }} onBlur={handleBlur} /> values.ruleIds.includes(option.id))} onChange={(event, newValue) => { const selectedIds = newValue.map((option) => option.id); setFieldValue("ruleIds", selectedIds); }} onBlur={handleBlur} options={ruleEquation} getOptionLabel={(option) => option.label} // Display the label for each option /> {errors.parentParam} ) : null } /> {errors.defaultValue} ) : null } /> ); }; export default CheckupParameterForm; { /*
{errors.cpname} ) : null } /> { const syntheticEvent = { target: { name: "healthkeyname", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.healthkeyname && touched.healthkeyname ? ( {errors.healthkeyname} ) : null } /> {errors.startingrange} ) : null } /> sx={{ width: "1000px" }} {errors.endingrange} ) : null } /> { const syntheticEvent = { target: { name: "lessrisk", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.lessrisk && touched.lessrisk ? ( {errors.lessrisk} ) : null } /> { const syntheticEvent = { target: { name: "morerisk", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.morerisk && touched.morerisk ? ( {errors.morerisk} ) : null } /> { const syntheticEvent = { target: { name: "lessadvice", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.lessadvice && touched.lessadvice ? ( {errors.lessadvice} ) : null } /> { const syntheticEvent = { target: { name: "moreadvice", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.moreadvice && touched.moreadvice ? ( {errors.moreadvice} ) : null } /> { const syntheticEvent = { target: { name: "section", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.section && touched.section ? ( {errors.section} ) : null } /> {errors.columnorder} ) : null } /> {errors.placeholder} ) : null } /> {errors.parametervaluename} ) : null } /> { const syntheticEvent = { target: { name: "inputtype", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.inputtype && touched.inputtype ? ( {errors.inputtype} ) : null } /> {errors.checkuptype} ) : null } /> { const syntheticEvent = { target: { name: "status", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.status && touched.status ? ( {errors.status} ) : null } /> { const syntheticEvent = { target: { name: "edit", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.edit && touched.edit ? ( {errors.edit} ) : null } /> { const syntheticEvent = { target: { name: "selectunit", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.selectunit && touched.selectunit ? ( {errors.selectunit} ) : null } /> {errors.refrange} ) : null } /> { const syntheticEvent = { target: { name: "opd", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.opd && touched.opd ? ( {errors.opd} ) : null } /> { const syntheticEvent = { target: { name: "daycare", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.daycare && touched.daycare ? ( {errors.daycare} ) : null } /> { const syntheticEvent = { target: { name: "injury", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.injury && touched.injury ? ( {errors.injury} ) : null } /> { const syntheticEvent = { target: { name: "rangerule", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.rangerule && touched.rangerule ? ( {errors.rangerule} ) : null } /> { const syntheticEvent = { target: { name: "parent", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.parent && touched.parent ? ( {errors.parent} ) : null } /> { const syntheticEvent = { target: { name: "mandatory", value: newValue, }, }; handleChange(syntheticEvent); }} onBlur={handleBlur} type="text" helperText={ errors.mandatory && touched.mandatory ? ( {errors.mandatory} ) : null } /> {errors.default} ) : null } />
*/ }