import { provinceAndCityEnum } from '@/enums/city';
export type useCityProps = {
  formatProvinceByData: () => { label: string; value: string; children?: Record<string, any>[] }[];
  formatCityByProvinceData: (
    arg1: Record<string, any>,
  ) => { label: string; value: string; children?: Record<string, any>[] }[];
};
export const useCity: useCityProps = () => {
  function formatProvinceByData() {
    const provinceCityData = provinceAndCityEnum.map((item) => {
      item.label = item.provinceName;
      item.value = item.provinceName;
      item.children = item.citys;
      return item;
    });
    return provinceCityData;
  }

  //   formatCityByProvinceData
  function formatCityByProvinceData(arg1) {
    const cityData = arg1?.children?.map((item) => {
      item.label = item.cityName;
      item.value = item.cityName;
      return item;
    });
    return cityData;
  }

  return {
    formatProvinceByData,
    formatCityByProvinceData,
  };
};
