import request from "@/utils/request";

export const getCity = async (provinceCode, cityCode, areaCode) => {
  const resps = await Promise.all([
    request({
      url: `/region/allProvince`,
    }),
    request({
      url: `/region/allCity`,
      params: {
        provinceCode,
      },
    }),
    request({
      url: `/region/allArea`,
      params: {
        cityCode,
      },
    }),
  ]);
  const provinceStr = resps[0].data.find(
    (el) => el.provinceCode == provinceCode
  ).provinceName;
  // console.log(provinceStr);
  const cityStr = resps[1].data.find((el) => el.cityCode == cityCode).cityName;
  const areaStr = resps[2].data.find((el) => el.areaCode == areaCode).areaName;
  return `${provinceStr} ${cityStr} ${areaStr}`;
};
