import { DetailedHTMLProps, InputHTMLAttributes } from 'react'

type ICheckbox = {
  value?: boolean
  label?: string
} & Omit<
  DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
  'value'
>

const Checkbox = ({
  name,
  label,
  id,
  value = false,
  type,
  ...props
}: ICheckbox) => {
  return (
    <>
      {label && <label htmlFor={id || name}>{label}</label>}
      <input
        id={id || label}
        name={name}
        checked={value}
        type='checkbox'
        {...props}
      />
    </>
  )
}

export default Checkbox
