import * as React from 'react'
import { Checkbox } from '../../Checkbox'
import { FieldRenderProps } from 'react-final-form'

export class CheckboxAdapter extends React.PureComponent<FieldRenderProps> {
  handleChange = (event: React.SyntheticEvent) => {
    // @ts-ignore //TODO: FIX ME
    this.props.input.onChange(event.target.checked)
  }

  render() {
    return (
      <Checkbox
        {...this.props}
        checked={this.props.input.value}
        onChange={this.handleChange}
      />
    )
  }
}
