Update Member Import

This commit is contained in:
2022-07-25 10:20:35 +07:00
parent 42e4129a79
commit 1edd8157c7
71 changed files with 1917 additions and 2743 deletions

View File

@@ -67,3 +67,49 @@ export function RHFMultiCheckbox({ name, options, ...other }: RHFMultiCheckboxPr
/>
);
}
// ----------------------------------------------------------------------
interface optionsCustomInterface {
value: string;
label: string;
}
interface RHFCustomMultiCheckboxProps {
name: string;
options: optionsCustomInterface[];
}
export function RHFCustomMultiCheckbox({ name, options, ...other }: RHFCustomMultiCheckboxProps) {
const { control } = useFormContext();
return (
<Controller
name={name}
control={control}
render={({ field }) => {
const onSelected = (option: optionsCustomInterface) =>
field.value.includes(option.value)
? field.value.filter((value: string) => value !== option.value)
: [...field.value, option.value];
return (
<FormGroup>
{options.map((option, index) => (
<FormControlLabel
key={index}
control={
<Checkbox
checked={field.value.includes(option.value)}
onChange={() => field.onChange(onSelected(option))}
/>
}
label={option.label}
{...other}
/>
))}
</FormGroup>
);
}}
/>
);
}