feat(create-role): make isCreator condition checked by default (#1276)

This commit is contained in:
Rıdvan Akca
2023-09-11 16:28:47 +03:00
committed by GitHub
parent 25ce63b86d
commit 4795c35c68
4 changed files with 53 additions and 46 deletions

View File

@@ -4,9 +4,12 @@ import Checkbox, { CheckboxProps } from '@mui/material/Checkbox';
type ControlledCheckboxProps = {
name: string;
} & CheckboxProps;
defaultValue?: boolean;
} & Omit<CheckboxProps, 'defaultValue'>;
export default function ControlledCheckbox(props: ControlledCheckboxProps): React.ReactElement {
export default function ControlledCheckbox(
props: ControlledCheckboxProps
): React.ReactElement {
const { control } = useFormContext();
const {
required,
@@ -34,24 +37,25 @@ export default function ControlledCheckbox(props: ControlledCheckboxProps): Reac
...field
},
}) => {
return (
<Checkbox
{...checkboxProps}
{...field}
checked={!!value}
name={name}
disabled={disabled}
onChange={(...args) => {
controllerOnChange(...args);
onChange?.(...args);
}}
onBlur={(...args) => {
controllerOnBlur();
onBlur?.(...args);
}}
inputRef={ref}
/>
)}}
return (
<Checkbox
{...checkboxProps}
{...field}
checked={!!value}
name={name}
disabled={disabled}
onChange={(...args) => {
controllerOnChange(...args);
onChange?.(...args);
}}
onBlur={(...args) => {
controllerOnBlur();
onBlur?.(...args);
}}
inputRef={ref}
/>
);
}}
/>
);
}