"use client"; import { clsx } from "clsx"; import { EstimateStatus, EstimateVersionStatus } from "@planarchy/shared"; import type { EstimateMetricView, EstimateVersionView, EstimateWorkspaceView, } from "~/components/estimates/EstimateWorkspace.types.js"; import { InfoTooltip } from "~/components/ui/InfoTooltip.js"; import { formatDateLong, formatMoney } from "~/lib/format.js"; const STATUS_STYLES: Record = { DRAFT: "bg-slate-100 text-slate-700 dark:bg-slate-900/30 dark:text-slate-300", IN_REVIEW: "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300", APPROVED: "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300", ARCHIVED: "bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300", }; const VERSION_STYLES: Record = { WORKING: "bg-sky-100 text-sky-700 dark:bg-sky-900/30 dark:text-sky-300", BASELINE: "bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-300", SUBMITTED: "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300", APPROVED: "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300", SUPERSEDED: "bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300", }; function formatMetricValue(metric: EstimateMetricView) { if (metric.valueCents != null) { return formatMoney(metric.valueCents, metric.currency ?? "EUR"); } if (metric.key === "margin_percent") { return `${metric.valueDecimal.toFixed(0)}%`; } return new Intl.NumberFormat("de-DE", { maximumFractionDigits: 1 }).format(metric.valueDecimal); } export function OverviewTab({ estimate }: { estimate: EstimateWorkspaceView }) { const versions = estimate.versions as EstimateVersionView[]; const latestVersion = versions[0] ?? null; const latestMetrics = latestVersion?.metrics ?? []; return (
{estimate.status.replace("_", " ")} {estimate.project && ( {estimate.project.shortCode} )}

Opportunity

{estimate.opportunityId ?? "Not set"}

Base currency

{estimate.baseCurrency}

Latest version

{latestVersion ? `v${latestVersion.versionNumber}${latestVersion.label ? ` - ${latestVersion.label}` : ""}` : "No version"}

Updated

{formatDateLong(estimate.updatedAt)}

{latestVersion?.notes && (

Version notes

{latestVersion.notes}

)}

Scope items

{latestVersion?.scopeItems.length ?? 0}
{(latestVersion?.scopeItems ?? []).slice(0, 4).map((item) => (

{item.name}

{item.scopeType}
))} {(latestVersion?.scopeItems.length ?? 0) === 0 &&

No scope rows captured yet.

}

Demand lines

{latestVersion?.demandLines.length ?? 0}
{(latestVersion?.demandLines ?? []).slice(0, 4).map((line) => (

{line.name}

{line.hours.toFixed(1)} h
))} {(latestVersion?.demandLines.length ?? 0) === 0 &&

No demand lines captured yet.

}
); }