Files
bigcapital/client/src/components/Forms/Checkbox.tsx
Ahmed Bouhuolia 128feb73f8 feat: apply new cards design system.
feat: empty status datatables.
fix: edit account.
2020-11-18 21:55:17 +02:00

27 lines
629 B
TypeScript

import React, { useState } from 'react';
import {
Checkbox as BPCheckbox,
} from '@blueprintjs/core';
export default function CheckboxComponent(props) {
const { field, form, ...rest } = props;
const [value, setValue] = useState(field.value || false);
const handleChange = () => {
const checked = !value;
form.setFieldValue(field.name, checked);
setValue(checked);
};
const handleBlur = () => {
form.setFieldTouched(field.name);
};
const checkboxProps = {
...rest,
onChange: handleChange,
onBlur: handleBlur,
checked: value,
}
return <BPCheckbox {...checkboxProps} />;
}