import { Checkbox, FormControlLabel } from "@mui/material";

export function CheckboxInput(p: {
  editable: boolean;
  label: string;
  checked: boolean | undefined;
  onValueChange: (v: boolean) => void;
}): React.ReactElement {
  return (
    <FormControlLabel
      control={
        <Checkbox
          disabled={!p.editable}
          checked={p.checked}
          onChange={(e) => { p.onValueChange(e.target.checked); }}
        />
      }
      label={p.label}
    />
  );
}
