1
0
Fork 0
polaris-task-force/src/components/frontend/operations/OperationSections.tsx
Z8MB1E 4b9d231ba5 chore(ui): drop grid-texture hover fade
Remove the hover-only brightening of the tactical dossier grid texture so it
keeps a constant opacity across EmploymentCard, CampaignCard, and the
operations surfaces (OperationSections, StrategicSummary, tokens).
2026-10-05 03:36:38 -04:00

237 lines
7.8 KiB
TypeScript

import Link from "next/link";
import { CornerBrackets } from "./CornerBrackets";
import { ClassificationStrip } from "./ClassificationStrip";
import { LedgerRow, type ReadoutCell } from "./LedgerRow";
import { NoticeState } from "./NoticeState";
import { ProvenanceChip } from "./ProvenanceChip";
import { DOSSIER } from "./tokens";
import type { SurfaceOverview } from "@/lib/operations/surface";
const cell = "px-3 py-2 align-middle text-xs";
const headCell = "px-3 py-2 text-left font-mono text-[9px] uppercase tracking-widest text-white/50";
function CardShell({
title,
children,
}: {
title: string;
children: React.ReactNode;
}) {
return (
<section className="group relative overflow-hidden rounded-none border border-border/70 bg-card" data-slot="operation-card">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 z-[5] opacity-[0.04]"
style={DOSSIER.gridTexture}
/>
<CornerBrackets />
<header className={`${DOSSIER.strip} relative z-10`}>
<h2 className={DOSSIER.stripLabel}>{title}</h2>
</header>
<div className="relative z-10 px-5 py-3">{children}</div>
</section>
);
}
export function RecentOperationsCard({ operations }: { operations: SurfaceOverview["recentOperations"] }) {
return (
<CardShell title="Recent operations">
{operations.length === 0 ? (
<NoticeState variant="empty" message="No operation activity recorded yet." />
) : (
<table className="w-full border-collapse">
<thead>
<tr className="border-b border-white/10">
<th className={headCell}>Operation</th>
<th className={headCell}>Events</th>
<th className={headCell}>Applied</th>
<th className={headCell}>Failed</th>
<th className={headCell}>Rejected</th>
<th className={headCell}>Last activity</th>
</tr>
</thead>
<tbody>
{operations.map((op) => (
<tr key={op.operationId} className="border-b border-white/5 last:border-0">
<td className={cell}>
<Link
href={`/operations/${encodeURIComponent(op.operationId)}`}
className="font-mono text-xs text-white/90 underline-offset-4 hover:underline"
>
{op.operationId}
</Link>
</td>
<td className={`${cell} font-mono tabular-nums`}>{op.eventCount}</td>
<td className={`${cell} font-mono tabular-nums text-emerald-400`}>{op.appliedCount}</td>
<td className={`${cell} font-mono tabular-nums text-rose-400`}>{op.failedCount}</td>
<td className={`${cell} font-mono tabular-nums text-amber-400`}>{op.rejectedCount}</td>
<td className={`${cell} font-mono tabular-nums text-white/70`}>{op.lastOccurredAt ?? "n/a"}</td>
</tr>
))}
</tbody>
</table>
)}
</CardShell>
);
}
export function MyExtractionsCard({
extractions,
signedIn,
}: {
extractions: SurfaceOverview["myExtractions"];
signedIn: boolean;
}) {
if (!signedIn) {
return (
<CardShell title="My extractions">
<NoticeState variant="empty" message="Sign in to see your extraction history." />
</CardShell>
);
}
return (
<CardShell title="My extractions">
{extractions.length === 0 ? (
<NoticeState variant="empty" message="No extractions recorded for you yet." />
) : (
<ul className="flex flex-col gap-1">
{extractions.map((ex) => (
<li
key={ex.eventId}
className="flex items-center justify-between gap-2 border border-white/10 px-2 py-1.5"
>
<span className="min-w-0 truncate font-mono text-xs text-white/80">{ex.eventLabel}</span>
<span className="flex shrink-0 items-center gap-2">
<Link
href={`/operations/${encodeURIComponent(ex.operationId)}`}
className="font-mono text-[10px] uppercase tracking-widest text-white/50 underline-offset-4 hover:underline"
>
{ex.operationId}
</Link>
<ProvenanceChip
label={ex.effectStatus ?? "pending"}
href={ex.effectStatus === "applied" ? "/operations/ledger?status=validated" : undefined}
/>
</span>
</li>
))}
</ul>
)}
</CardShell>
);
}
export function ReservationsCard({
reservations,
canSee,
}: {
reservations: SurfaceOverview["activeReservations"];
canSee: boolean;
}) {
if (!canSee) {
return (
<CardShell title="Active reservations">
<NoticeState variant="empty" message="Reservation summaries require the reservations permission." />
</CardShell>
);
}
return (
<CardShell title="Active reservations">
{reservations.length === 0 ? (
<NoticeState variant="empty" message="No active reservations." />
) : (
<ul className="flex flex-col gap-1">
{reservations.map((r) => {
const cells: ReadoutCell[] = [
{ label: "Key", value: r.reservationKey, mono: true },
{ label: "Expires", value: r.expiresAt ?? "n/a" },
];
return <LedgerRow key={r.reservationKey} cells={cells} />;
})}
</ul>
)}
</CardShell>
);
}
export function ReadinessCard({
readiness,
canSee,
}: {
readiness: SurfaceOverview["ownReadiness"];
canSee: boolean;
}) {
if (!canSee) {
return (
<CardShell title="Readiness">
<NoticeState variant="empty" message="Readiness aggregates require the readiness permission." />
</CardShell>
);
}
return (
<CardShell title="Readiness">
{readiness === null ? (
<NoticeState variant="empty" message="No readiness aggregate computed for you yet." />
) : (
<div className="flex flex-col gap-2">
<p className="font-mono text-2xl tabular-nums text-white">{readiness.score ?? "n/a"}</p>
{readiness.explanation && <p className="text-xs text-white/70">{readiness.explanation}</p>}
{readiness.windowLabel && (
<p className="font-mono text-[9px] uppercase tracking-widest text-white/50">
Window {readiness.windowLabel}
</p>
)}
</div>
)}
</CardShell>
);
}
export function PressureCard({
pressure,
canSee,
}: {
pressure: SurfaceOverview["pressure"];
canSee: boolean;
}) {
if (!canSee) {
return (
<CardShell title="Zone pressure">
<NoticeState variant="empty" message="Pressure summaries require the zone pressure permission." />
</CardShell>
);
}
return (
<CardShell title="Zone pressure">
{pressure.length === 0 ? (
<NoticeState variant="empty" message="No zone pressure recorded yet." />
) : (
<ul className="flex flex-col gap-1">
{pressure.map((p) => (
<li
key={p.zoneId}
className="flex items-center justify-between border border-white/10 px-2 py-1.5"
>
<span className="font-mono text-xs text-white/80">Zone {p.zoneId}</span>
<span
className={`font-mono text-[10px] uppercase tracking-widest ${
p.state === "controlled"
? "text-emerald-400"
: p.state === "contested"
? "text-amber-400"
: "text-white/60"
}`}
>
{p.state} ({p.pressure})
</span>
</li>
))}
</ul>
)}
</CardShell>
);
}
export function OperationsStrip({ left }: { left: string }) {
return <ClassificationStrip left={left} right="Polaris // Ops" />;
}