import React from "react";

import CheckIcon from "@mui/icons-material/Check";
import { ChipProps } from "@mui/material/Chip";

import Chip from "./Chip";

export interface FilterChipProps
  extends Omit<ChipProps, "label" | "variant" | "icon" | "onClick" | "checked" | "onChange"> {
  label: string;
  checked?: boolean;
  onChange?: (v: boolean) => void;
}

export const FilterChip: React.FC<FilterChipProps> = ({
  label,
  color,
  checked,
  onChange,
  ...props
}) => {
  return (
    <Chip
      color={checked ? color : "default"}
      icon={checked ? <CheckIcon /> : undefined}
      label={label}
      variant={checked ? "filled" : "outlined"}
      onClick={() => onChange?.(!checked)}
      {...props}
    />
  );
};

export default FilterChip;
