import {Layer, Source} from "react-map-gl";
import {selectedRegionLayer} from "../../dzkh-features/Layers/layers-config.js";
import {useDzkhFilters} from "../../stores/useDzkhFilters.js";

const SelectedRegionLayer = ({ data }) => {
  return (
    <Source id="selected-region" type="geojson" data={data}>
      <Layer {...selectedRegionLayer} />
    </Source>
  );
};

export const SelectedRegion = () => {
  const {
    filters: { region },
  } = useDzkhFilters();

  if (region?.geometry) {
    return <SelectedRegionLayer data={region.geometry} />
  }

  return null
};
