Files
ox_lib/web/src/features/dialog/components/checkbox.tsx
T
ANTONDandLinden cb5dac6151 refactor(web/dialog): split interfaces (#68)
* tweak(interface/menu): SetNuiFocusKeepInput

Default to allow input; disable with "disableInput = false" during registration.

* refactor(web/dialog): Split interfaces

for better typing of row options for different input types

* fix(web/dialog): Use proper type for onChange event

Co-authored-by: Linden <65407488+thelindat@users.noreply.github.com>
2022-08-09 23:50:14 +02:00

31 lines
781 B
TypeScript

import { Box, Checkbox } from "@chakra-ui/react";
import { useEffect } from "react";
import { ICheckbox } from "../../../interfaces/dialog";
interface Props {
row: ICheckbox;
index: number;
handleChange: (value: boolean, index: number) => void;
}
const CheckboxField: React.FC<Props> = (props) => {
useEffect(() => {
if(props.row.checked) props.handleChange(props.row.checked, props.index);
}, []);
return (
<>
<Box mb={3} key={`checkbox-${props.index}`}>
<Checkbox
onChange={(e: React.ChangeEvent<HTMLInputElement>) => props.handleChange(e.target.checked, props.index)}
defaultChecked={props.row.checked}
>
{props.row.label}
</Checkbox>
</Box>
</>
);
};
export default CheckboxField;