Socialify

Folder ..

Viewing checkBoxWrapper.tsx
37 lines (33 loc) • 828.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import ConfigType from '../../../common/types/configType'

type CheckBoxProps = {
  title: string
  keyName: keyof ConfigType
  checked?: boolean
  disabled?: boolean

  handleChange: (value: any, key: keyof ConfigType) => void
}

const CheckBoxWrapper = ({
  title,
  keyName,
  checked,
  disabled,
  handleChange
}: CheckBoxProps) => {
  return (
    <div className="form-control">
      <label className="label cursor-pointer justify-start gap-2">
        <input
          className="checkbox checkbox-sm"
          type="checkbox"
          checked={!!checked}
          disabled={disabled}
          onChange={(e) => {
            handleChange({ state: e.target.checked }, keyName)
          }}
        />
        <span className="label-text">{title}</span>
      </label>
    </div>
  )
}

export default CheckBoxWrapper