import { ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
import { translateCrudLabel } from '../helpers/translateCrudLabel'

type Props = {
  children: ReactNode
  type: 'checkbox' | 'radio' | 'switch'
  label?: string
  className?: string
}

const FormCheckRadio = (props: Props) => {
  const { t } = useTranslation('common')

  return (
    <label className={`${props.type} ${props.className}`}>
      {props.children}
      <span className="check" />
      <span className="pl-2">{translateCrudLabel(props.label, t)}</span>
    </label>
  )
}

export default FormCheckRadio
