import * as React from 'react';
import { FastSwitch } from 'components/ui';
import { FormTypes } from '../../types';

function Switch(props: FormTypes.FormItem.FormAtomicInputProps) {
  const {
    values,
    config,
    validateTrigger,
  } = props;
  const {
    key,
    notModify,
  } = config;

  return (
    <FastSwitch
      checked={values[key]}
      disabled={notModify}
      // eslint-disable-next-line react/destructuring-assignment
      onChange={props[validateTrigger]}
    />
  );
}

export default Switch;
