import { apiRequest } from '../lib/api'

export interface BusinessActivityCategory {
  id: string
  parentId: string | null
  name: string
  slug: string
  description: string | null
  icon: string | null
  sortOrder: number
}

export async function listBusinessActivityCategories(signal?: AbortSignal) {
  const data = await apiRequest<{ items: BusinessActivityCategory[] }>(
    '/business-categories',
    { auth: true, signal },
  )
  return data.items.map((item) => ({
    ...item,
    id: String(item.id),
    parentId: item.parentId ? String(item.parentId) : null,
  }))
}
