import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { CheckCircle2, AlertCircle, Loader2, AlertTriangle } from "lucide-react"; import type { ClientFolderStatus } from "@/types/folder"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Badge } from "@/components/ui/badge"; interface FolderStatusPopoverProps { deviceId: string; status?: ClientFolderStatus; isLoading?: boolean; } export function FolderStatusPopover({ deviceId, status, isLoading, }: FolderStatusPopoverProps) { const missing = status?.missingFiles ?? []; const extra = status?.extraFiles ?? []; const hasMissing = missing.length > 0; const hasExtra = extra.length > 0; const hasIssues = hasMissing || hasExtra; // Xác định màu sắc và icon dựa trên trạng thái let statusColor = "text-green-500"; let statusIcon = ( ); if (isLoading) { statusColor = "text-blue-500"; statusIcon = ; } else if (hasMissing && hasExtra) { // Vừa thiếu vừa thừa -> Đỏ + Alert statusColor = "text-red-600"; statusIcon = ; } else if (hasMissing) { // Chỉ thiếu -> Đỏ statusColor = "text-red-500"; statusIcon = ; } else if (hasExtra) { // Chỉ thừa -> Cam statusColor = "text-orange-500"; statusIcon = ; } return (
Thư mục Setup: {deviceId}
{hasIssues && ( {hasMissing && hasExtra ? "Không đồng bộ" : hasMissing ? "Thiếu file" : "Thừa file"} )}
{isLoading ? (
Đang kiểm tra...
) : !status ? (
Chưa có dữ liệu
) : (
{/* File thiếu */} {hasMissing && (

File thiếu ({missing.length})

{missing.map((file, idx) => (
{file.fileName}
{file.folderPath}
))}
)} {/* File thừa */} {hasExtra && (

File thừa ({extra.length})

{extra.map((file, idx) => (
{file.fileName}
{file.folderPath}
))}
)} {/* Trạng thái OK */} {!hasIssues && (
Thư mục đạt yêu cầu
)}
)}
); }