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

export const SlaughterUnpaidFeesCheckbox = ({
  handleSelectedItems,
  item,
  selectedItems,
}) => {
  // Initialize the checkbox state with false (unchecked)
  const [isChecked, setIsChecked] = useState(
    selectedItems.includes(item.provinceRequest.provinceKillRequestKey)
  );
  // Function to handle checkbox state changes
  const handleCheckboxChange = (event) => {
    setIsChecked(event.target.checked);
    handleSelectedItems(item.provinceRequest.provinceKillRequestKey, item);
  };

  return (
    <FormControlLabel
      control={
        <Checkbox
          checked={isChecked}
          onChange={handleCheckboxChange}
          color="primary" // Change the color to your preference
        />
      }
    />
  );
};
