import { useFilters } from "../../stores/useFilters";
import { useMemo } from "react";

const REGION_FIELD_MAPPER = {
  ao: "okrug_id",
  rayon: "rayon_id",
};

export const useRegionFilterExpression = () => {
  const {
    filters: { region },
  } = useFilters();

  return useMemo(
    () =>
      region
        ? ["==", ["get", REGION_FIELD_MAPPER[region.type]], region.id]
        : null,
    [region]
  );
};
