import type { CityResponseDto, ProvinceResponseDto } from '@/api/generated/models' import { unwrapApiData } from '@/services/apiResponse' import { getGeography } from '@/api/generated/geography/geography' export type Province = ProvinceResponseDto & Record export type City = CityResponseDto & Record const geographyApi = getGeography() export async function fetchProvinces(): Promise { const response = await geographyApi.geographyControllerListProvinces() const payload = response.data.success ? unwrapApiData(response.data) : undefined return Array.isArray(payload) ? (payload as Province[]) : [] } export async function fetchAllCities(): Promise { const response = await geographyApi.geographyControllerListAllCities() const payload = response.data.success ? unwrapApiData(response.data) : undefined return Array.isArray(payload) ? (payload as City[]) : [] } export async function fetchCities(provinceId: number): Promise { const response = await geographyApi.geographyControllerListCities(provinceId) const payload = response.data.success ? unwrapApiData(response.data) : undefined return Array.isArray(payload) ? (payload as City[]) : [] }