1
0
Fork 0
polaris-task-force/src/components/frontend/dashboard/OpenNegotiations.tsx
Z8MB1E e1cfdd3329 feat(dashboard): apply the tactical dossier style to the remaining widgets
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.
2026-10-13 11:08:56 -04:00

99 lines
4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from "next/link";
import type { MarketListing, MarketNegotiation } from "@/payload-types";
import { ChevronRightIcon, HandshakeIcon } from "lucide-react";
import type { CurrencyConfig } from "@/lib/banking/format";
import { CurrencyAmount } from "@/components/frontend/banking/CurrencyAmount";
import { TacticalFrame } from "./tactical";
interface OpenNegotiationsProps {
readonly negotiations: MarketNegotiation[];
readonly currentUserId: number;
readonly currencyConfig: CurrencyConfig;
}
function listingOf(negotiation: MarketNegotiation): MarketListing | null {
return typeof negotiation.listing === "object" && negotiation.listing
? (negotiation.listing as MarketListing)
: null;
}
function assetNameOf(listing: MarketListing | null): string {
const asset = listing?.asset;
return typeof asset === "object" && asset ? asset.name : "Unknown item";
}
function buyerIdOf(negotiation: MarketNegotiation): number | null {
return typeof negotiation.buyer === "object" && negotiation.buyer
? negotiation.buyer.id
: negotiation.buyer;
}
export function OpenNegotiations({
negotiations,
currentUserId,
currencyConfig,
}: OpenNegotiationsProps) {
// Deliberately hidden when there is nothing on the table (same convention as
// NegotiationPanel on the market page).
if (negotiations.length === 0) return null;
const fmt = (n: number) => <CurrencyAmount value={n} currency={currencyConfig} />;
return (
<TacticalFrame classification="Logistics // Market">
<div className="flex items-center justify-between gap-2 px-4 pt-3">
<div className="flex min-w-0 items-center gap-2">
<HandshakeIcon className="size-4 shrink-0 text-muted-foreground" />
<h3 className="truncate text-sm font-semibold uppercase tracking-wide">Negotiations</h3>
<span className="shrink-0 text-xs text-muted-foreground">
{negotiations.length} open
</span>
</div>
<Link
href="/logistics/market"
className="shrink-0 py-1 text-xs text-muted-foreground transition-colors hover:text-primary"
>
Market
</Link>
</div>
<div className="p-4 pt-3">
<div className="flex flex-col gap-1">
{negotiations.map((negotiation) => {
const listing = listingOf(negotiation);
const role = buyerIdOf(negotiation) === currentUserId ? "buyer" : "seller";
const theirProposal =
(role === "buyer" && negotiation.proposedBy === "seller") ||
(role === "seller" && negotiation.proposedBy === "buyer");
const quantity = negotiation.quantity ?? listing?.quantity ?? 1;
return (
<Link
key={negotiation.id}
href="/logistics/market"
className="group flex items-center gap-3 rounded-sm p-2 transition-colors hover:bg-muted/50"
>
<HandshakeIcon className="size-4 shrink-0 text-muted-foreground" />
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
<div className="flex items-center gap-2">
<span className="truncate text-sm font-medium transition-colors group-hover:text-primary">
{assetNameOf(listing)}
</span>
<span className="shrink-0 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
{role === "buyer" ? "Buying" : "Selling"}
</span>
</div>
<span className="truncate text-xs text-muted-foreground">
{fmt(negotiation.amount ?? 0)} each · {quantity}× ·{" "}
{theirProposal ? "their offer" : "your offer"}
</span>
</div>
<ChevronRightIcon className="size-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
</Link>
);
})}
</div>
</div>
</TacticalFrame>
);
}