import React from "react";
import PropTypes from "prop-types";
import { CheckBox as CheckboxButton } from "../../../../../CheckBox/CheckBox";

const Checkbox = (props) => {
  const item = props.item;
  return (
    <CheckboxButton
      leftText={item.city}
      rightText={item.offerCount}
      value={item}
      checked={
        props.filters.find(
          (itemInList) =>
            itemInList?.city?.toString() === item?.city?.toString()
        )
          ? true
          : false
      }
      onChange={props.onChange}
      fullWidth
    />
  );
};

Checkbox.propTypes = {
  item: PropTypes.any,
  filters: PropTypes.any,
  onChange: PropTypes.func,
};

export default Checkbox;
