import { useTranslation } from "react-i18next"; import type { ResourceDTO } from "../common/inventory"; export function ResourceDetail({ resource }: { resource: ResourceDTO }) { const { t, i18n } = useTranslation("resources"); const display = (value: string | number | boolean | undefined) => value === undefined ? t("noValue") : typeof value === "boolean" ? t(value ? "yes" : "no") : String(value); return (

{t("snapshotNotice")}

{t("template")}
{resource.specification.templateName}
{t("status")}
{t(resource.values.active ? "active" : "inactive")}
{resource.specification.fields.map((field) => (
{field.name} {field.unit ? ` (${field.unit})` : ""}
{display(resource.values.characteristics[field.fieldId])}
))}
{resource.values.notes && (

{resource.values.notes}

)}

{t("history")} ({resource.history.length})

    {[...resource.history].reverse().map((revision) => (
  1. {new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium", timeStyle: "short", }).format(new Date(revision.recordedAt))}{" "} · {t("recordedBy", { name: revision.actorName })}

    {revision.values.name} · {t(revision.values.active ? "active" : "inactive")}

    {resource.specification.fields.map((field) => (
    {field.name}
    {display(revision.values.characteristics[field.fieldId])}
    ))}
    {revision.values.notes && (

    {revision.values.notes}

    )}
  2. ))}
); }