import { apiRequest } from '../lib/api'
import type { CityOption } from '@meshkee/dashboard-ui'

export type { CityOption }

export async function listIranProvinces(signal?: AbortSignal) {
  const data = await apiRequest<{ items: CityOption[] }>(
    '/cities?level=province&parentSlug=iran',
    { signal },
  )
  return data.items
}

export async function listCitiesByProvinceSlug(parentSlug: string, signal?: AbortSignal) {
  const data = await apiRequest<{ items: CityOption[] }>(
    `/cities?level=city&parentSlug=${encodeURIComponent(parentSlug)}`,
    { signal },
  )
  return data.items
}
