"use client" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Eye, AlertCircle } from "lucide-react" import { type Video } from "@/lib/api" interface RecentAnalysesTableProps { videos: Video[] isLoading?: boolean onViewResults?: (videoId: string, detectionType: string) => void } export function RecentAnalysesTable({ videos, isLoading, onViewResults }: RecentAnalysesTableProps) { const formatDate = (dateString: string) => { const date = new Date(dateString) return date.toLocaleDateString("en-IN", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" }) } const getStatusBadge = (status: string) => { switch (status) { case "completed": return Completed case "processing": return Processing case "pending": return Pending case "failed": return Failed default: return {status} } } const getDetectionTypeBadge = (type: string) => { if (type === "pothole-detection") { return Pothole } if (type === "pot-sign-detection") { return Pothole & Sign } return Signboard } return ( Recent Analyses {isLoading ? (
{[1, 2, 3, 4].map((i) => (
))}
) : videos.length === 0 ? (

No analyses found

Start a new analysis to see results here

) : (
{videos.slice(0, 8).map((video) => (

{video.filename || `Video ${video.id.slice(0, 8)}...`}

{formatDate(video.created_at)}

{getDetectionTypeBadge(video.detection_type)} {getStatusBadge(video.status)}

{video.detection_type === "pothole-detection" ? video.unique_pothole ?? 0 : video.detection_type === "pot-sign-detection" ? (video.unique_pothole ?? 0) + (video.unique_defected_sign_board ?? 0) + (video.unique_good_sign_board ?? 0) : (video.unique_defected_sign_board ?? 0) + (video.unique_good_sign_board ?? 0)}

Detections

{video.status === "completed" && onViewResults && ( )}
))}
)} ) }