"use client"; import { useEffect, useState } from "react"; import { Repository, RepoStatus, AggregatedMetrics, fetchRepoStatus, fetchRepoMetrics } from "@/lib/api"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { StatusBadge } from "./StatusBadge"; import { MetricChart } from "./MetricChart"; import { Button } from "@/components/ui/button"; import { Trash2, ExternalLink, Box, RefreshCw } from "lucide-react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; interface RepositoryCardProps { repo: Repository; onRemove: (id: string) => void; timeRange: string; } export function RepositoryCard({ repo, onRemove, timeRange }: RepositoryCardProps) { const [status, setStatus] = useState(null); const [metrics, setMetrics] = useState(null); const [loading, setLoading] = useState(true); const pollData = async () => { try { const [newStatus, newMetrics] = await Promise.all([ fetchRepoStatus(repo.id), fetchRepoMetrics(repo.id, timeRange) ]); setStatus(newStatus); setMetrics(newMetrics); } catch (err) { console.error("Failed to poll card data", err); } finally { setLoading(false); } }; useEffect(() => { pollData(); const interval = setInterval(pollData, 10000); // Poll every 10s return () => clearInterval(interval); }, [repo.id, timeRange]); return (
{repo.repo}

{repo.namespace}

{status ? ( <> ) : (
)} Delete Monitoring? This will stop monitoring the repository {repo.namespace}/{repo.repo}. This action cannot be undone. Cancel onRemove(repo.id)} className="bg-destructive text-destructive-foreground hover:bg-destructive/90"> Delete
); }