2022-12-16 15:00:01 +01:00
|
|
|
import { Checkbox } from '@mantine/core';
|
2022-08-27 15:58:36 +02:00
|
|
|
import { useEffect } from 'react';
|
2022-10-27 14:22:15 +02:00
|
|
|
import { ICheckbox } from '../../../../interfaces/dialog';
|
2022-05-03 15:08:28 +02:00
|
|
|
|
|
|
|
|
interface Props {
|
2022-08-09 23:50:14 +02:00
|
|
|
row: ICheckbox;
|
2022-05-03 15:08:28 +02:00
|
|
|
index: number;
|
2022-08-09 23:50:14 +02:00
|
|
|
handleChange: (value: boolean, index: number) => void;
|
2022-05-03 15:08:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CheckboxField: React.FC<Props> = (props) => {
|
2022-08-05 15:10:37 +02:00
|
|
|
useEffect(() => {
|
2022-08-27 15:58:36 +02:00
|
|
|
if (props.row.checked) props.handleChange(props.row.checked, props.index);
|
2022-08-05 15:10:37 +02:00
|
|
|
}, []);
|
|
|
|
|
|
2022-05-03 15:08:28 +02:00
|
|
|
return (
|
2022-12-16 15:00:01 +01:00
|
|
|
<Checkbox
|
|
|
|
|
sx={{ display: 'flex' }}
|
|
|
|
|
label={props.row.label}
|
|
|
|
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => props.handleChange(e.target.checked, props.index)}
|
|
|
|
|
defaultChecked={props.row.checked}
|
|
|
|
|
/>
|
2022-05-03 15:08:28 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default CheckboxField;
|