import { Form, Switch as AntSwitch } from 'antd';
import { ElementStatus } from 'types/elements';

const Switch = ({
  value,
  setCurrentValue,
  status,
  validateStatus,
  message,
  ...props
}) => {
  return (
    <Form.Item validateStatus={validateStatus} help={message}>
      <AntSwitch
        {...props}
        disabled={status === ElementStatus.Disabled}
        checked={value}
        onChange={(checked, event) => {
          setCurrentValue(checked);
        }}
      />
    </Form.Item>
  );
};

export default Switch;
