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, name }) => {
  const { isVisible } = useLayersVisibility();
  const filter = ["==", ["get", "group_id"], id]

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