Wallet, Negotiations, My Tickets, Notifications, Upcoming Missions, Active Campaigns and Recent Events were still conventional shadcn Item cards while Service Summary, Mission Briefing and Situation Report already used the dossier primitives. Wrap them in the shared TacticalFrame so the whole dashboard reads as one board: - classification strip naming the domain (Logistics // Banking, Helpdesk // Tickets, and so on), with a REF code on the wallet - squared corners, corner brackets and the faint grid texture - an inner header row of icon + uppercase title + action link, matching the Service Summary widget - squared (rounded-sm, bordered) status pills for tickets and campaigns - a ReadoutFooter on the wallet (account id + status) via the shared ReadoutFooter primitive Empty and self-hiding states are preserved, and the wallet's no-account path still returns the conventional MyWalletCard CTA. Also drops a dead CLOSING_STATUSES import from MyTickets.
96 lines
3.8 KiB
TypeScript
96 lines
3.8 KiB
TypeScript
import type { GameStructure, User } from "@/payload-types";
|
|
import { BookOpenTextIcon, LockIcon, ScrollTextIcon } from "lucide-react";
|
|
import { formatType } from "@/utils/event-log/formatType";
|
|
import { TacticalFrame } from "./tactical";
|
|
|
|
interface EventEntry {
|
|
id: number;
|
|
timestamp: string;
|
|
type: string;
|
|
message: string;
|
|
system: boolean;
|
|
actor?: number | User | null;
|
|
structure?: number | GameStructure | null;
|
|
visibility?: "public" | "restricted" | null;
|
|
}
|
|
|
|
interface RecentEventsProps {
|
|
events: EventEntry[];
|
|
currentUserId?: number;
|
|
}
|
|
|
|
function timeAgo(dateStr: string): string {
|
|
const now = new Date();
|
|
const date = new Date(dateStr);
|
|
const diffMs = now.getTime() - date.getTime();
|
|
const diffMins = Math.floor(diffMs / 60000);
|
|
if (diffMins < 1) return "just now";
|
|
if (diffMins < 60) return `${diffMins}m ago`;
|
|
const diffHours = Math.floor(diffMins / 60);
|
|
if (diffHours < 24) return `${diffHours}h ago`;
|
|
const diffDays = Math.floor(diffHours / 24);
|
|
return `${diffDays}d ago`;
|
|
}
|
|
|
|
export function RecentEvents({ events, currentUserId }: RecentEventsProps) {
|
|
return (
|
|
<TacticalFrame classification="Event Log // Recent">
|
|
<div className="flex items-center justify-between gap-2 px-4 pt-3">
|
|
<div className="flex min-w-0 items-center gap-2">
|
|
<ScrollTextIcon className="size-4 shrink-0 text-muted-foreground" />
|
|
<h3 className="truncate text-sm font-semibold uppercase tracking-wide">Recent Events</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="p-4 pt-3">
|
|
{events.length === 0 ? (
|
|
<p className="text-sm italic text-muted-foreground">No recent events recorded.</p>
|
|
) : (
|
|
<div className="flex flex-col">
|
|
{events.map((event, index) => {
|
|
const actor =
|
|
typeof event.actor === "object" && event.actor !== null
|
|
? (event.actor as User)
|
|
: null;
|
|
const actorId = actor?.id ?? (typeof event.actor === "number" ? event.actor : null);
|
|
const isYou = actorId != null && actorId === currentUserId;
|
|
const actorName = actor?.displayName ?? actor?.username ?? null;
|
|
const actorLabel = isYou ? "You" : actorName;
|
|
const isNarrative = event.system === false;
|
|
|
|
return (
|
|
<div key={event.id}>
|
|
<div
|
|
className={`flex items-start gap-3 py-2 text-sm ${isNarrative ? "border-l-2 border-amber-500/40 pl-3" : ""}`}
|
|
>
|
|
{isNarrative && (
|
|
<BookOpenTextIcon className="mt-0.5 size-4 shrink-0 text-amber-400" />
|
|
)}
|
|
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
<span className="shrink-0 tabular-nums">{timeAgo(event.timestamp)}</span>
|
|
{actorLabel && (
|
|
<span className={`font-medium ${isYou ? "text-foreground" : ""}`}>
|
|
{actorLabel}
|
|
</span>
|
|
)}
|
|
<span className="capitalize">{formatType(event.type)}</span>
|
|
{event.visibility === "restricted" && (
|
|
<LockIcon className="size-3 shrink-0 text-amber-400" />
|
|
)}
|
|
</div>
|
|
<span className={`min-w-0 ${isNarrative ? "text-amber-100/90" : ""}`}>
|
|
{event.message}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
{index < events.length - 1 && <div className="border-t border-border" />}
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</TacticalFrame>
|
|
);
|
|
}
|