import { useQuery } from '@tanstack/react-query'; import { Activity, Clock } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import { getUserActivity, type UserActivityItem } from '@/client'; import { formatDate } from './utils'; export function UserActivity({ username }: { username: string }) { const { data, isLoading, isError } = useQuery({ queryKey: ['user-activity', username], queryFn: async () => { const resp = await getUserActivity({ path: { username } }); return resp.data?.data ?? null; }, retry: false, }); if (isLoading) { return ( Loading activity... ); } if (isError || !data) { return ( Unable to load activity. ); } if (data.items.length === 0) { return (

No activity yet

); } const getTypeColor = (type: string) => { if (type === 'auth') return 'bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400'; return 'bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400'; }; return (
{data.items.map((item: UserActivityItem) => ( {item.activity_type === 'auth' ? 'A' : 'P'}

{item.title}

{item.resource_name && (

Project: {item.resource_name}

)}
{formatDate(item.created_at)}
))}
); }