import { Checkbox as AntCheckbox, Form } from 'antd';
import { ElementStatus } from 'types/elements';

const Checkbox = ({
  value,
  setCurrentValue,
  status,
  validateStatus,
  message,
  text,
  containerStyle,
  ...props
}) => {
  return (
    <Form.Item
      validateStatus={validateStatus}
      help={message}
      style={containerStyle}
    >
      <AntCheckbox
        {...props}
        disabled={status === ElementStatus.Disabled}
        checked={value}
        onChange={e => setCurrentValue(e.target.checked)}
      >
        {text}
      </AntCheckbox>
    </Form.Item>
  );
};

export default Checkbox;
