import { Layer } from "react-map-gl";
import { getPointSymbolLayer } from "./layers-config";
import { useLayersVisibility } from "../../stores/useLayersVisibility";
import { LAYER_IDS } from "./constants";

export const PVZ = ({id, categoryId}) => {
  const { isVisible } = useLayersVisibility();
  const filter = ["==", ["get", "group_id"], id]

  return (
    <>
      <Layer
        {...getPointSymbolLayer(String(id))}
        id={LAYER_IDS.pvz + id}
        source={"pvz"}
        source-layer={"public.service_post_and_pvz"}
        layout={{
          ...getPointSymbolLayer(String(id)).layout,
          visibility: isVisible[LAYER_IDS.pvz_category + categoryId] ? "visible" : "none",
        }}
        filter={filter}
      />
    </>
  );
};
