import { api } from '@/core/services/api'
import type { PaginatedApiResponse } from '@/core/types/api'
import type { ActivityLogItem, ListActivityLogsParams } from '../types/activity-log.types'

export async function listActivityLogs(
  params: ListActivityLogsParams,
): Promise<PaginatedApiResponse<ActivityLogItem>> {
  const { data } = await api.get<PaginatedApiResponse<ActivityLogItem>>('/v1/activitylogs', {
    params,
  })

  if (!data.success) {
    throw new Error(data.message ?? 'Failed to load activity logs')
  }

  return data
}
