admin/services/geography.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

31 lines
1.2 KiB
TypeScript

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<string, unknown>
export type City = CityResponseDto & Record<string, unknown>
const geographyApi = getGeography()
export async function fetchProvinces(): Promise<Province[]> {
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<City[]> {
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<City[]> {
const response = await geographyApi.geographyControllerListCities(provinceId)
const payload = response.data.success ? unwrapApiData(response.data) : undefined
return Array.isArray(payload) ? (payload as City[]) : []
}