"use client"; import { AuditorReport } from "@/types"; import { useSendAuditorReport } from "@/hooks/use-dashboard"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { ScrollArea } from "@/components/ui/scroll-area"; import { FileText, Send, Eye, Clock, Plus } from "lucide-react"; import { toast } from "sonner"; interface ReportsPanelProps { reports: AuditorReport[] | undefined; isLoading: boolean; onCreateReport?: () => void; } function formatDate(timestamp: string): string { return new Date(timestamp).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", }); } export function ReportsPanel({ reports, isLoading, onCreateReport }: ReportsPanelProps) { const sendReport = useSendAuditorReport(); const handleSend = async (reportId: string) => { try { await sendReport.mutateAsync(reportId); toast.success("Report sent to CEO"); } catch { toast.error("Failed to send report"); } }; return (
Reports
{isLoading ? (
{[...Array(3)].map((_, i) => ( ))}
) : !reports || reports.length === 0 ? (
No reports yet
) : (
{reports.map((report) => { const isDraft = !report.sent_at; return (
{isDraft ? "Draft" : "Sent"} {report.title}
{report.report_type} {formatDate(report.created_at)}
{isDraft && ( )}
); })}
)}
); }