import React from "react"; import { Card, CardHeader, CardTitle, CardContent } from "./ui/card"; import { Badge } from "./ui/badge"; import { type RecentEvent } from "@shared/modules/dashboard/dashboard.types"; import { cn } from "../lib/utils"; import { Skeleton } from "./ui/skeleton"; function timeAgo(dateInput: Date | string) { const date = new Date(dateInput); const now = new Date(); const seconds = Math.floor((now.getTime() - date.getTime()) / 1000); if (seconds < 60) return "just now"; const minutes = Math.floor(seconds / 60); if (minutes < 60) return `${minutes}m ago`; const hours = Math.floor(minutes / 60); if (hours < 24) return `${hours}h ago`; return date.toLocaleDateString(); } interface RecentActivityProps { events: RecentEvent[]; isLoading?: boolean; className?: string; } export function RecentActivity({ events, isLoading, className }: RecentActivityProps) { return ( Live Activity {!isLoading && events.length > 0 && ( {events.length} EVENTS )} {isLoading ? (
{[1, 2, 3].map((i) => (
))}
) : events.length === 0 ? (
😴

No recent activity

) : (
{events.map((event, i) => (
{event.icon || "📝"}

{event.message}

{event.type} {timeAgo(event.timestamp)}
))}
)}
); }