"use client"; import Link from "next/link"; import { formatDistanceToNow } from "date-fns"; import { Activity, CheckCircle2, PlusCircle, MessageSquare, UserPlus, Edit3, ArrowRight, } from "lucide-react"; import { cn } from "@/lib/utils"; import { useActivityFeed } from "@/hooks/use-activity-feed"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import type { ActivityItem } from "@/lib/supabase/database.types"; const activityTypeConfig: Record< ActivityItem["type"], { label: string; icon: React.ElementType; color: string } > = { task_created: { label: "Created", icon: PlusCircle, color: "bg-blue-500/10 text-blue-500", }, task_completed: { label: "Completed", icon: CheckCircle2, color: "bg-green-500/10 text-green-500", }, task_updated: { label: "Updated", icon: Edit3, color: "bg-yellow-500/10 text-yellow-500", }, comment_added: { label: "Comment", icon: MessageSquare, color: "bg-purple-500/10 text-purple-500", }, task_assigned: { label: "Assigned", icon: UserPlus, color: "bg-pink-500/10 text-pink-500", }, }; function RecentActivityItem({ activity }: { activity: ActivityItem }) { const config = activityTypeConfig[activity.type]; const Icon = config.icon; const timeAgo = formatDistanceToNow(new Date(activity.timestamp), { addSuffix: true }); return (
{activity.task_title}
{timeAgo}
Failed to load
No recent activity