File size: 977 Bytes
4114d85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { useState } from 'react'
import PropTypes from 'prop-types'
import { FormControlLabel, Checkbox } from '@mui/material'

export const CheckboxInput = ({ value, label, onChange, disabled = false }) => {
    const [myValue, setMyValue] = useState(value)

    return (
        <>
            <FormControlLabel
                sx={{ mt: 1, width: '100%' }}
                size='small'
                control={
                    <Checkbox
                        disabled={disabled}
                        checked={myValue}
                        onChange={(event) => {
                            setMyValue(event.target.checked)
                            onChange(event.target.checked)
                        }}
                    />
                }
                label={label}
            />
        </>
    )
}

CheckboxInput.propTypes = {
    value: PropTypes.bool,
    label: PropTypes.string,
    onChange: PropTypes.func,
    disabled: PropTypes.bool
}