"use client"; 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"; export function FurnitureComparison({ item, local, }: { item: FurniItem; local: FurnitureInspection; }) { const comparison = compareFurniture(item, local); return (
{!local.furnidataReadable && (

Local furnidata could not be read. Its values are not verified.

)}
{comparison.fields.map((field) => ( ))}
Field Local now Source
{field.label} {field.changed ? " · Changed" : ""} {field.before ?? "—"} {field.after ?? "Not supplied"}

Source values are compared with local data. Import may remap IDs and translate names. Existing furniture keeps its local IDs and SQL settings; new furniture receives a free local ID when the source ID is occupied.

SQL records and catalog offers
{local.sql.length ? ( local.sql.map((row) => (

Item #{row.id} · Sprite #{row.spriteId} · {row.name}

)) ) : (

No local SQL item.

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

Offer #{row.id} · Page #{row.pageId} · {row.credits} credits +{" "} {row.points} points

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

Checking local data and assets…

); 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 ? (
{ { complete: "Complete", incomplete: "Needs repair", new: "Not imported", conflict: "Local conflict", unknown: "Not verified", }[health.state] } {health.missing.length > 0 && (

Missing: {health.missing.join(", ")}

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

Duplicate records or mismatched IDs/types require review before repair.

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

Some local data could not be checked. Retry verification before repair.

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

Repair adds missing parts and preserves existing IDs, settings, furnidata and catalog offers. Missing offers use the automatic category and price shown below.

)}
) : (

Local inspection unavailable.

); }