import { useApi } from './useApi'
import { DEFAULT_PAGE_SIZE, type Paginated } from '@/types/pagination'
import type { ApiActivity } from '@/types/activity'

// 활동 피드 API Composable — 인터셉터가 success/data 를 언래핑
export function useActivity() {
  const api = useApi()

  // 프로젝트 활동 피드(최신순, 페이지네이션)
  async function list(
    projectId: string,
    page = 1,
    size = DEFAULT_PAGE_SIZE,
  ): Promise<Paginated<ApiActivity>> {
    return (await api.get(`/projects/${projectId}/activity`, {
      params: { page, size },
    })) as unknown as Paginated<ApiActivity>
  }

  return { list }
}
