import React from "react";

const CheckboxField = ({options}) => {
  const defaultOptions = {
    name: '',
    checked: false,
    description: '',
    onChange: () => {},
  }
  let safeOptions = {}
  Object.assign(safeOptions, defaultOptions, options);

  const labelId = 'dreamfox-field-' + safeOptions['name'];
  const label = safeOptions['description'];
  return (
    <div className="dreamfox-field dreamfox-field--checkbox">
      <input name={safeOptions['name']} id={labelId} type="checkbox" defaultChecked={safeOptions['checked']} onClick={safeOptions['onChange']} />
      {label && <label htmlFor={labelId}>{label}</label>}
    </div>
  );
}

export default CheckboxField;