import { apiRequest } from '../lib/api'
import type { DashboardLocale } from '@meshkee/dashboard-core'

export interface ResolvedTenant {
  id: string
  name: string
  nameFa: string | null
  slug: string
  domain: string
  defaultLocale?: DashboardLocale
  logoUrl?: string | null
  faviconUrl?: string | null
}

export async function resolveTenantByDomain(host: string) {
  const encodedHost = encodeURIComponent(host)
  return apiRequest<ResolvedTenant>(`/tenants/${encodedHost}`)
}
