diff --git a/frontend/src/api/activity.ts b/frontend/src/api/activity.ts new file mode 100644 index 000000000..ac7fa9bc2 --- /dev/null +++ b/frontend/src/api/activity.ts @@ -0,0 +1,15 @@ +import { apiClient } from '../services/apiClient'; + +export interface ActivityEvent { + id: string; + type: 'completed' | 'submitted' | 'posted' | 'review'; + username: string; + avatar_url?: string | null; + detail: string; + timestamp: string; +} + +export async function listActivity(limit?: number): Promise { + const params = limit ? { limit } : {}; + return apiClient.get('/activity', { params }); +} \ No newline at end of file diff --git a/frontend/src/hooks/useActivity.ts b/frontend/src/hooks/useActivity.ts new file mode 100644 index 000000000..2cae9841c --- /dev/null +++ b/frontend/src/hooks/useActivity.ts @@ -0,0 +1,13 @@ +import { useQuery } from '@tanstack/react-query'; +import { listActivity } from '../api/activity'; +import type { ActivityEvent } from '../api/activity'; + +export function useActivity() { + return useQuery({ + queryKey: ['activity'], + queryFn: () => listActivity(10), + refetchInterval: 30_000, + staleTime: 30_000, + retry: 1, + }); +} \ No newline at end of file diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index 180849b3f..b82b97869 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -5,15 +5,18 @@ import { ActivityFeed } from '../components/home/ActivityFeed'; import { HowItWorksCondensed } from '../components/home/HowItWorksCondensed'; import { FeaturedBounties } from '../components/home/FeaturedBounties'; import { WhySolFoundry } from '../components/home/WhySolFoundry'; +import { useActivity } from '../hooks/useActivity'; export function HomePage() { + const { data: activityEvents } = useActivity(); + return ( - + ); -} +} \ No newline at end of file