import { cities, localities, propertyTypes } from "@/constants/leads";

type StateKey = keyof typeof cities;
type CityKey = keyof typeof localities;

export const getAvailableCities = (selectedState: string | undefined) => {
  if (!selectedState) return [];
  if (selectedState in cities) {
    return cities[selectedState as StateKey];
  }

  return [];
};

export const getAvailableLocalities = (selectedCity: string | undefined) => {
  if (!selectedCity) return [];
  if (selectedCity in localities) {
    return localities[selectedCity as CityKey];
  }

  return [];
};


export const getPropertyCategory = (propertyType: string | undefined): string => {
  if (!propertyType) return "";
  const foundType = propertyTypes.find(type => type.value === propertyType);
  return foundType ? foundType.category : "";
}