"use client"; import { useTranslations } from "next-intl"; import { Button } from "@/components/ui/button"; import { compareFurniture, type FurnitureInspection, furnitureHealth, } from "@/lib/furni/studio-inspection"; import { FurnitureCompleteness } from "./furniture-completeness"; import type { FurniItem } from "./studio-types"; import { useFurnitureInspection } from "./use-furniture-inspection"; const HEALTH_KEYS = { complete: "healthComplete", incomplete: "healthIncomplete", new: "healthNew", conflict: "healthConflict", unknown: "healthUnknown", } as const; const FIELD_KEYS = { Name: "fieldName", Description: "fieldDescription", Revision: "fieldRevision", Type: "fieldType", } as const; export function FurnitureComparison({ item, local, }: { item: FurniItem; local: FurnitureInspection; }) { const t = useTranslations("admin.studio.inspector"); const comparison = compareFurniture(item, local); return (
{!local.furnidataReadable && (

{t("furnidataUnreadable")}

)}
{comparison.fields.map((field) => { const labelKey = FIELD_KEYS[field.label as keyof typeof FIELD_KEYS]; return ( ); })}
{t("field")} {t("localNow")} {t("source")}
{labelKey ? t(labelKey) : field.label} {field.changed ? ` · ${t("changed")}` : ""} {field.before ?? "—"} {field.after ?? t("notSupplied")}

{t("compareNote")}

{t("sqlRecords")}
{local.sql.length ? ( local.sql.map((row) => (

{t("itemRow", { id: row.id, sprite: row.spriteId, name: row.name, })}

)) ) : (

{t("noSqlItem")}

)} {local.catalog.map((row) => (

{t("offerRow", { id: row.id, page: row.pageId, credits: row.credits, points: row.points, })}

))}
); } export function FurnitureInspector({ item, onRepair, busy = false, }: { item: FurniItem; onRepair?: () => Promise; busy?: boolean; }) { const t = useTranslations("admin.studio.inspector"); const inspection = useFurnitureInspection([item.classname]); if (inspection.loading) return (

{t("checking")}

); if (inspection.error) return (

{inspection.error}

); const local = inspection.items.find( (entry) => entry.classname === item.classname, ); const health = local ? furnitureHealth(local) : null; return local && health ? (
{t(HEALTH_KEYS[health.state])} {health.missing.length > 0 && (

{t("missing", { parts: health.missing.join(", ") })}

)} {health.state === "conflict" && (

{t("conflictNote")}

)} {health.state === "unknown" && (

{t("unknownNote")}

)} {health.state === "incomplete" && onRepair && ( <>

{t("repairNote")}

)}
) : (

{t("unavailable")}

); }