"use client"; import { Ban, Check, Circle, Loader2, RefreshCw, X } from "lucide-react"; import { memo } from "react"; import { Button } from "@/components/ui/button"; import type { BatchItemStatus, VerificationSummary } from "./studio-types"; const statusLabels: Record = { pending: "Waiting", started: "Starting", downloading: "Downloading assets", converting: "Preparing assets", writing_db: "Saving", done: "Imported", failed: "Failed", }; export const BatchProgress = memo(function BatchProgress({ progress, done, succeeded, failed, cancelling, verification, failedClassnames, onCancel, onDismiss, onRetry, }: { progress: Map; done: boolean; succeeded: number; failed: number; cancelling?: boolean; verification?: VerificationSummary | null; startTime?: number; failedClassnames?: string[]; onCancel?: () => void; onDismiss?: () => void; onRetry?: (classnames: string[]) => void; }) { const entries = [...progress.values()]; const completed = entries.filter( (item) => item.status === "done" || item.status === "failed", ).length; const total = entries.length; const percent = total ? Math.round((completed / total) * 100) : 0; const imported = done ? succeeded : entries.filter((item) => item.status === "done").length; const errors = done ? failed : entries.filter((item) => item.status === "failed").length; const unfinished = Math.max(0, total - completed); const heading = !done ? cancelling ? "Stopping import…" : "Importing furniture…" : unfinished ? "Import stopped" : errors ? "Import completed with errors" : "Import completed"; const issues = verification ? verification.furniDataMissing + verification.furniDataConflicts : 0; return (

{heading}

{imported} imported · {errors} failed {unfinished > 0 && ` · ${unfinished} ${done ? "not completed" : "remaining"}`}

{done ? ( <> {!!failedClassnames?.length && onRetry && ( )} ) : ( )}
{done && verification && (

{issues ? `${issues} catalog data issue(s) still need attention. Open Catalog audit to review them.` : "Catalog data verification completed."}

)}
View item details ({total})
{entries.map((item) => (
{item.status === "done" ? ( ) : item.status === "failed" ? ( ) : done || item.status === "pending" ? ( ) : ( )} {item.classname} {done && item.status !== "done" && item.status !== "failed" ? "Not completed" : statusLabels[item.status]}
{item.message && (

{item.message}

)} {[...new Set(item.warnings ?? [])].map((warning) => (

{warning}

))}
))}
); });