hospital portal

This commit is contained in:
pajri
2023-02-01 16:22:03 +07:00
parent 8d5f4bb0bd
commit a7e688a52c
340 changed files with 46280 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
// form
import { useFormContext, Controller } from 'react-hook-form';
// @mui
import { Switch, FormControlLabel, FormControlLabelProps } from '@mui/material';
import { useEffect, useState } from 'react';
// ----------------------------------------------------------------------
type IProps = Omit<FormControlLabelProps, 'control'>;
interface Props extends IProps {
name: string;
}
export default function RHFSwitch({ name, ...other }: Props) {
const { control } = useFormContext();
return (
<FormControlLabel
control={
<Controller
name={name}
control={control}
render={({ field }) => <Switch {...field} checked={field.value} />}
/>
}
{...other}
/>
);
}
// interface Props extends IProps {
// valueTrue: any,
// valueFalse: any,
// }
// export function RHFSwitchEnum({ name, valueTrue, valueFalse, ...other}: Props) {
// const { control } = useFormContext();
// const [isChecked, setIsChecked] = useState(valueTrue === field.value);
// useEffect(() => {
// // setIsChecked()
// }, [])
// return (
// <FormControlLabel
// control={
// <Controller
// name={name}
// control={control}
// render={({ field }) => <Switch {...field} checked={field.value} />}
// />
// }
// {...other}
// />
// );
// }