import React from 'react'
import { Cell } from 'react-sticky-table'

import Checkbox from '../Form/Checkbox'

export type TableCheckboxProps = {
  name: string
  checked: boolean
  handleCheck: () => void
  /** Optional prop to add a test id to the TableCheckbox for QA testing */
  qaTestId?: string
}

const TableCheckbox = ({
  name,
  checked,
  handleCheck,
  qaTestId = 'table-checkbox',
}: TableCheckboxProps): React.JSX.Element => {
  return (
    <Cell
      style={{
        width: '18px',
      }}
    >
      <Checkbox
        label={name}
        name={name}
        checked={checked}
        callout={handleCheck}
        hideLabel
        qaTestId={qaTestId}
      />
    </Cell>
  )
}

export default TableCheckbox
