1
0
Fork 0

feat(personnel): add NPC portraits and rich bio, redesign contact cards

Game NPCs gain an image upload and a Lexical rich-text bio (with data
migration that wraps existing plain text in a paragraph). NPC profile, card
and directory surface the portrait, a status-chip row and initials fallback;
contacts list and detail pages adopt the redesigned cards.
This commit is contained in:
Jason Fraley 2026-10-05 03:22:11 -04:00
parent 4755cb681a
commit 755bd04875
12 changed files with 74166 additions and 193 deletions

View file

@ -150,23 +150,24 @@ export default async function NpcContactPage({ params }: NpcContactPageProps) {
const listings = listingsRes.docs as unknown as MarketListing[]; const listings = listingsRes.docs as unknown as MarketListing[];
return ( return (
<div className="grid gap-6 lg:grid-cols-2"> <div className="p-5">
<div className="lg:col-span-2"> <NpcProfile
<NpcProfile npc={npc} listings={listings} /> npc={npc}
</div> listings={listings}
<div className="px-5 pb-5 lg:col-start-2"> employmentSlot={
<EmploymentCard <EmploymentCard
employment={employment} employment={employment}
structures={structures} structures={structures}
canManage={canManage} canManage={canManage}
npcId={npc.id} npcId={npc.id}
npcName={npc.name} npcName={npc.name}
classifications={classifications} classifications={classifications}
hiringEnabled={Boolean(rules.staffHiringEnabled)} hiringEnabled={Boolean(rules.staffHiringEnabled)}
hiringDisabledMessage={rules.staffHiringDisabledMessage ?? undefined} hiringDisabledMessage={rules.staffHiringDisabledMessage ?? undefined}
currencyConfig={currencyConfig} currencyConfig={currencyConfig}
/> />
</div> }
/>
</div> </div>
); );
} }

View file

@ -3,6 +3,11 @@ import { getPayload } from "payload";
import type { GameNpc } from "@/payload-types"; import type { GameNpc } from "@/payload-types";
import { UsersIcon } from "lucide-react"; import { UsersIcon } from "lucide-react";
import { NpcDirectory } from "@/components/frontend/personnel/NpcDirectory"; import { NpcDirectory } from "@/components/frontend/personnel/NpcDirectory";
import {
ClassificationStrip,
CornerBrackets,
DOSSIER,
} from "@/components/frontend/operations";
export const metadata = { export const metadata = {
title: "Contacts: Polaris Task Force", title: "Contacts: Polaris Task Force",
@ -19,15 +24,28 @@ export default async function ContactsPage() {
return ( return (
<div className="flex flex-col gap-6 p-5"> <div className="flex flex-col gap-6 p-5">
<div className="flex flex-col gap-1"> <header className="group relative overflow-hidden rounded-none border border-border/70 bg-card">
<div className="flex items-center gap-2"> <div
<UsersIcon className="size-5 text-muted-foreground" /> aria-hidden="true"
<h1 className="text-lg font-semibold">Contacts</h1> className="pointer-events-none absolute inset-0 z-[5] opacity-[0.04]"
style={DOSSIER.gridTexture}
/>
<ClassificationStrip
left="Theater Contacts // Personnel"
right={`${npcs.length} Recorded`}
/>
<CornerBrackets />
<div className="relative z-10 flex items-center gap-3 px-5 py-4">
<UsersIcon className="size-5 shrink-0 text-white/50" />
<div className="flex flex-col gap-0.5">
<h1 className="text-xl font-bold tracking-tight text-white">Contacts</h1>
<p className="text-sm text-white/60">
{npcs.length} contact{npcs.length !== 1 ? "s" : ""} recorded in the theater of
operations.
</p>
</div>
</div> </div>
<p className="text-sm text-muted-foreground"> </header>
{npcs.length} contact{npcs.length !== 1 ? "s" : ""} recorded in the theater of operations.
</p>
</div>
<NpcDirectory npcs={npcs} /> <NpcDirectory npcs={npcs} />
</div> </div>

View file

@ -25,6 +25,15 @@ export const GameNpcs: CollectionConfig = {
description: "The NPC's name as shown in-game and on the frontend.", description: "The NPC's name as shown in-game and on the frontend.",
}, },
}, },
{
name: "image",
type: "upload",
relationTo: "media",
admin: {
description:
"Portrait/photo for this contact. Shown on the contacts directory and profile when set.",
},
},
{ {
name: "occupation", name: "occupation",
type: "text", type: "text",
@ -50,7 +59,7 @@ export const GameNpcs: CollectionConfig = {
}, },
{ {
name: "bio", name: "bio",
type: "textarea", type: "richText",
admin: { admin: {
description: "A short background/profile for this NPC.", description: "A short background/profile for this NPC.",
}, },

View file

@ -2,8 +2,10 @@
import Link from "next/link"; import Link from "next/link";
import type { GameNpc } from "@/payload-types"; import type { GameNpc } from "@/payload-types";
import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { ClassificationStrip, CornerBrackets, DOSSIER, type ReadoutCell } from "@/components/frontend/operations";
import { NpcStatusChips } from "@/components/frontend/personnel/NpcStatusChips";
import { initialsOf } from "@/components/frontend/personnel/initials";
interface NpcCardProps { interface NpcCardProps {
readonly npc: GameNpc; readonly npc: GameNpc;
@ -12,40 +14,110 @@ interface NpcCardProps {
export function NpcCard({ npc }: NpcCardProps) { export function NpcCard({ npc }: NpcCardProps) {
const factionName = const factionName =
typeof npc.faction === "object" && npc.faction !== null ? npc.faction.name : null; typeof npc.faction === "object" && npc.faction !== null ? npc.faction.name : null;
const locationName =
typeof npc.location === "object" && npc.location !== null ? npc.location.name : null;
const vendorEnabled = npc.vendor?.enabled === true;
const goodsCount = (npc.vendor?.sells ?? []).length;
const imageUrl =
typeof npc.image === "object" && npc.image !== null ? (npc.image.url ?? null) : null;
const refCode = String(npc.id).padStart(3, "0");
const monogram = initialsOf(npc.name);
const readoutCells: ReadoutCell[] = [
{ label: "Faction", value: factionName ?? "Unaffiliated" },
{ label: "Station", value: locationName ?? "Unknown" },
{ label: "Goods", value: vendorEnabled ? goodsCount.toString() : "—", mono: true },
];
return ( return (
<Link href={`/personnel/contacts/${npc.id}`} className="block h-full"> <Link
<Card className="h-full transition-colors hover:bg-accent/50"> href={`/personnel/contacts/${npc.id}`}
<CardHeader className="gap-2"> aria-label={`Open contact ${npc.name}`}
<CardTitle className="text-base">{npc.name}</CardTitle> className="block rounded-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
<p className="text-sm text-muted-foreground"> >
{npc.occupation ?? "Occupation not recorded"} <article className="group relative flex aspect-[4/5] flex-col overflow-hidden rounded-none border border-border/70 bg-card transition-colors duration-300 hover:border-foreground/30 motion-reduce:transition-none">
</p> <div className="relative z-20 shrink-0">
<div className="flex flex-wrap items-center gap-1.5"> <ClassificationStrip left="Contact" right={`REF ${refCode}`} />
{npc.isInGame === true && ( </div>
<Badge variant="secondary" className="border-emerald-500/30 text-emerald-500">
In Game <div className="relative min-h-0 flex-1 overflow-hidden">
</Badge> {imageUrl ? (
)} <img src={imageUrl} alt="" className="absolute inset-0 size-full object-cover" />
{npc.isGenerated === true && ( ) : (
<Badge variant="outline" className="border-amber-500/40 text-amber-500"> <>
Generated <div className="absolute inset-0 bg-gradient-to-br from-muted/40 via-card to-black/40" />
</Badge> <div className="absolute inset-0 flex items-center justify-center">
)} <span className="select-none font-mono text-[3rem] font-bold leading-none tracking-tighter text-white/[0.06] transition-opacity duration-500 group-hover:text-white/[0.1] motion-reduce:transition-none">
{npc.vendor?.enabled === true && ( {monogram}
<Badge variant="outline" className="border-violet-500/40 text-violet-500"> </span>
Vendor </div>
</Badge> </>
)} )}
<div
aria-hidden="true"
className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/55 to-black/25"
/>
<div className="relative z-10 flex h-full items-center justify-center px-3 text-center">
<div className="flex max-w-full flex-col items-center gap-1.5">
<h2
data-text={npc.name}
className="glitch-hover text-balance text-center text-sm font-bold leading-tight text-white drop-shadow-lg"
>
{npc.name}
<span aria-hidden="true" className="glitch-ghost glitch-shard-a">
{npc.name}
</span>
<span aria-hidden="true" className="glitch-ghost glitch-shard-b">
{npc.name}
</span>
<span aria-hidden="true" className="glitch-ghost glitch-shard-c">
{npc.name}
</span>
</h2>
<p className="glitch-soft line-clamp-1 max-w-full text-pretty text-[10px] text-white/60 drop-shadow">
{npc.occupation ?? "Occupation not recorded"}
</p>
<NpcStatusChips npc={npc} size="compact" className="mt-0.5 justify-center" />
</div>
</div> </div>
</CardHeader> </div>
<CardContent className="flex flex-col gap-2 text-sm">
<div className="flex items-center justify-between gap-3"> <div className="relative z-20 shrink-0">
<span className="text-muted-foreground">Faction</span> <footer className="flex items-stretch border-t border-white/15 bg-black/60 px-1 py-1 backdrop-blur-sm">
<span className="truncate text-right">{factionName ?? "Unaffiliated"}</span> {readoutCells.map((cell, index) => (
</div> <div
</CardContent> key={cell.label}
</Card> className={cn(
"flex min-w-0 flex-1 flex-col items-center justify-center px-1",
index < readoutCells.length - 1 && "border-r border-white/15",
)}
>
<span
className={cn(
"w-full truncate text-center text-[10px] text-white/80",
cell.mono && "font-mono tabular-nums",
)}
>
{cell.value}
</span>
<span className="text-[7px] uppercase tracking-widest text-white/40">
{cell.label}
</span>
</div>
))}
</footer>
</div>
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 z-[5] opacity-[0.04]"
style={DOSSIER.gridTexture}
/>
<CornerBrackets />
</article>
</Link> </Link>
); );
} }

View file

@ -3,13 +3,12 @@
import { useMemo, useState } from "react"; import { useMemo, useState } from "react";
import { SearchIcon } from "lucide-react"; import { SearchIcon } from "lucide-react";
import type { GameNpc } from "@/payload-types"; import type { GameNpc } from "@/payload-types";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox"; import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { NpcCard } from "@/components/frontend/personnel/NpcCard"; import { NpcCard } from "@/components/frontend/personnel/NpcCard";
import { DOSSIER, NoticeState } from "@/components/frontend/operations";
interface NpcDirectoryProps { interface NpcDirectoryProps {
readonly npcs: GameNpc[]; readonly npcs: GameNpc[];
@ -94,30 +93,29 @@ export function NpcDirectory({ npcs }: NpcDirectoryProps) {
</fieldset> </fieldset>
</div> </div>
<Badge variant="outline" className="w-fit"> <span className={cn("w-fit", DOSSIER.chip)}>
{filteredNpcs.length} of {npcs.length} {filteredNpcs.length} of {npcs.length}
</Badge> </span>
</div> </div>
{filteredNpcs.length === 0 ? ( {filteredNpcs.length === 0 ? (
<Card> <NoticeState
<CardContent className="flex flex-col gap-1 p-6"> variant="empty"
<p className="font-semibold"> message={
{npcs.length === 0 npcs.length === 0
? "No contacts have been added." ? "No contacts have been added."
: hasFilters : hasFilters
? "No contacts match those filters." ? "No contacts match those filters."
: "No contacts found."} : "No contacts found."
</p> }
<p className="text-sm text-muted-foreground"> hint={
{npcs.length === 0 npcs.length === 0
? "NPC records will appear here as the theater develops." ? "NPC records will appear here as the theater develops."
: "Try a different search or clear one of the filters."} : "Try a different search or clear one of the filters."
</p> }
</CardContent> />
</Card>
) : ( ) : (
<div className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3"> <div className="grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
{filteredNpcs.map((npc) => ( {filteredNpcs.map((npc) => (
<NpcCard key={npc.id} npc={npc} /> <NpcCard key={npc.id} npc={npc} />
))} ))}

View file

@ -1,53 +1,71 @@
"use client"; "use client";
import { Fragment } from "react"; import { Fragment, type ComponentType, type ReactNode } from "react";
import Link from "next/link"; import Link from "next/link";
import { ArrowLeftIcon, MapPinIcon, ShieldIcon, StoreIcon } from "lucide-react"; import { ArrowLeftIcon, MapPinIcon, ShieldIcon, StoreIcon } from "lucide-react";
import { RichText } from "@payloadcms/richtext-lexical/react";
import type { Asset, GameNpc, MarketListing } from "@/payload-types"; import type { Asset, GameNpc, MarketListing } from "@/payload-types";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
import {
ClassificationStrip,
CornerBrackets,
DOSSIER,
LedgerRow,
StrategicSummary,
type ReadoutCell,
} from "@/components/frontend/operations";
import { CurrencyAmount } from "@/components/frontend/banking/CurrencyAmount"; import { CurrencyAmount } from "@/components/frontend/banking/CurrencyAmount";
import { NpcStatusChips } from "@/components/frontend/personnel/NpcStatusChips";
import { initialsOf } from "@/components/frontend/personnel/initials";
interface NpcProfileProps { interface NpcProfileProps {
readonly npc: GameNpc; readonly npc: GameNpc;
readonly listings: MarketListing[]; readonly listings: MarketListing[];
/** Interactive employment controls, rendered in the dossier's right column. */
readonly employmentSlot?: ReactNode;
} }
function assetName(asset: number | Asset): string { function assetName(asset: number | Asset): string {
return typeof asset === "object" && asset !== null ? asset.name : `Asset #${asset}`; return typeof asset === "object" && asset !== null ? asset.name : `Asset #${asset}`;
} }
function StatusBadges({ npc }: { npc: GameNpc }) { function Field({
icon: Icon,
label,
value,
}: {
icon: ComponentType<{ className?: string }>;
label: string;
value: string;
}) {
return ( return (
<div className="flex flex-wrap items-center gap-1.5"> <div className="flex items-start gap-3">
{npc.isInGame === true && ( <Icon className="mt-0.5 size-4 shrink-0 text-white/40" />
<Badge variant="secondary" className="border-emerald-500/30 text-emerald-500"> <div className="flex flex-col gap-1">
In Game <span className={DOSSIER.readoutLabel}>{label}</span>
</Badge> <span className="text-sm text-white/90">{value}</span>
)} </div>
{npc.isGenerated === true && (
<Badge variant="outline" className="border-amber-500/40 text-amber-500">
Generated
</Badge>
)}
{npc.vendor?.enabled === true && (
<Badge variant="outline" className="border-violet-500/40 text-violet-500">
Vendor
</Badge>
)}
</div> </div>
); );
} }
export function NpcProfile({ npc, listings }: NpcProfileProps) { type LexicalData = Parameters<typeof RichText>[0]["data"];
/** Renders the NPC's Lexical richText bio, falling back to a placeholder when empty. */
function NpcBio({ bio }: { bio: GameNpc["bio"] }) {
const children = (bio as { root?: { children?: unknown[] } } | null | undefined)?.root?.children;
if (!bio || !Array.isArray(children) || children.length === 0) {
return <p className="text-sm text-white/60">No bio on file.</p>;
}
return (
<div className="lexical-content">
<RichText data={bio as LexicalData} />
</div>
);
}
export function NpcProfile({ npc, listings, employmentSlot }: NpcProfileProps) {
const faction = typeof npc.faction === "object" && npc.faction !== null ? npc.faction : null; const faction = typeof npc.faction === "object" && npc.faction !== null ? npc.faction : null;
const location = const location =
typeof npc.location === "object" && npc.location !== null ? npc.location : null; typeof npc.location === "object" && npc.location !== null ? npc.location : null;
@ -55,134 +73,171 @@ export function NpcProfile({ npc, listings }: NpcProfileProps) {
(asset): asset is Asset => typeof asset === "object" && asset !== null, (asset): asset is Asset => typeof asset === "object" && asset !== null,
); );
const vendorEnabled = npc.vendor?.enabled === true; const vendorEnabled = npc.vendor?.enabled === true;
const priceModifier = npc.vendor?.priceModifier ?? 1;
const imageUrl =
typeof npc.image === "object" && npc.image !== null ? (npc.image.url ?? null) : null;
const refCode = String(npc.id).padStart(3, "0");
const monogram = initialsOf(npc.name);
const heroCells: ReadoutCell[] = [
{ label: "Faction", value: faction?.name ?? "Unaffiliated" },
{ label: "Station", value: location?.name ?? "Unknown" },
{ label: "Goods", value: vendorEnabled ? sellableAssets.length.toString() : "—", mono: true },
{ label: "Listings", value: listings.length.toString(), mono: true },
];
return ( return (
<div className="flex flex-col gap-6 p-5"> <div className="flex flex-col gap-6">
<Link <Link
href="/personnel/contacts" href="/personnel/contacts"
className="inline-flex w-fit items-center gap-2 text-sm text-muted-foreground hover:text-foreground" className="inline-flex w-fit items-center gap-2 font-mono text-xs uppercase tracking-widest text-white/50 transition-colors hover:text-white/90"
> >
<ArrowLeftIcon className="size-4" /> <ArrowLeftIcon className="size-3.5" />
Back to Contacts Back to Contacts
</Link> </Link>
<div className="flex flex-col gap-2"> {/* Hero dossier */}
<div className="flex flex-wrap items-center gap-3"> <section
<h1 className="text-lg font-semibold">{npc.name}</h1> data-slot="npc-dossier-hero"
<StatusBadges npc={npc} /> className="group relative overflow-hidden rounded-none border border-border/70 bg-card"
>
<div aria-hidden="true" className="absolute inset-0">
{imageUrl ? (
<img src={imageUrl} alt="" className="absolute inset-0 size-full object-cover" />
) : (
<>
<div className="absolute inset-0 bg-gradient-to-br from-muted/40 via-card to-black/50" />
<div className="absolute inset-0 flex items-center justify-end">
<span className="select-none pr-6 font-mono text-[9rem] font-bold leading-none tracking-tighter text-white/[0.05] transition-opacity duration-500 group-hover:text-white/[0.08] motion-reduce:transition-none md:pr-12 md:text-[12rem]">
{monogram}
</span>
</div>
</>
)}
</div> </div>
<p className="text-sm text-muted-foreground">
{npc.occupation ?? "Occupation not recorded"} <div
</p> aria-hidden="true"
</div> className="absolute inset-0 bg-gradient-to-r from-black/75 via-black/40 to-transparent"
/>
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 z-[5] opacity-[0.04]"
style={DOSSIER.gridTexture}
/>
<ClassificationStrip left="Personnel File // Theater Contacts" right={`REF ${refCode}`} />
<CornerBrackets />
<div className="relative z-10 flex flex-col gap-3 px-6 py-10 md:py-14">
<h1
data-text={npc.name}
className="glitch-hover text-balance text-3xl font-bold tracking-tight text-white drop-shadow-lg"
>
{npc.name}
<span aria-hidden="true" className="glitch-ghost glitch-shard-a">
{npc.name}
</span>
<span aria-hidden="true" className="glitch-ghost glitch-shard-b">
{npc.name}
</span>
<span aria-hidden="true" className="glitch-ghost glitch-shard-c">
{npc.name}
</span>
</h1>
<p className="glitch-soft max-w-prose text-pretty text-sm uppercase tracking-wider text-white/60 drop-shadow">
{npc.occupation ?? "Occupation not recorded"}
</p>
<NpcStatusChips npc={npc} className="mt-1" />
</div>
<div className="relative z-10">
<LedgerRow cells={heroCells} />
</div>
</section>
<div className="grid gap-6 lg:grid-cols-2"> <div className="grid gap-6 lg:grid-cols-2">
<div className="flex flex-col gap-6"> <div className="flex flex-col gap-6">
<Card> <StrategicSummary classificationLeft="Bio" classificationRight="Personnel File">
<CardHeader className="gap-2"> <NpcBio bio={npc.bio} />
<CardTitle>Bio</CardTitle> </StrategicSummary>
<CardDescription>Background information on this contact.</CardDescription>
</CardHeader>
<CardContent>
<p className="whitespace-pre-wrap text-sm text-muted-foreground">
{npc.bio?.trim() || "No bio on file."}
</p>
</CardContent>
</Card>
<Card> <StrategicSummary classificationLeft="Assignment" classificationRight="Affiliations">
<CardHeader className="gap-2"> <div className="grid gap-4 sm:grid-cols-2">
<CardTitle>Assignment</CardTitle> <Field
<CardDescription>Known affiliations and current station.</CardDescription> icon={MapPinIcon}
</CardHeader> label="Stationed at"
<CardContent className="grid gap-4 sm:grid-cols-2"> value={location?.name ?? "Location unknown"}
<div className="flex items-start gap-3"> />
<MapPinIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" /> <Field
<div className="flex flex-col gap-1"> icon={ShieldIcon}
<span className="text-xs uppercase tracking-wider text-muted-foreground"> label="Faction"
Stationed at value={faction?.name ?? "Unaffiliated"}
</span> />
<span className="text-sm">{location?.name ?? "Location unknown"}</span> </div>
</div> </StrategicSummary>
</div>
<div className="flex items-start gap-3">
<ShieldIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
<div className="flex flex-col gap-1">
<span className="text-xs uppercase tracking-wider text-muted-foreground">
Faction
</span>
<span className="text-sm">{faction?.name ?? "Unaffiliated"}</span>
</div>
</div>
</CardContent>
</Card>
</div> </div>
<div className="flex flex-col gap-6"> <div className="flex flex-col gap-6">
{vendorEnabled && ( {vendorEnabled && (
<Card> <StrategicSummary classificationLeft="Vendor" classificationRight="Market Preferences">
<CardHeader className="gap-2"> <div className="flex flex-col gap-4">
<div className="flex items-center gap-2"> <div className="flex items-center justify-between gap-3">
<StoreIcon className="size-4 text-muted-foreground" /> <span className={`flex items-center gap-2 ${DOSSIER.readoutLabel}`}>
<CardTitle>Vendor information</CardTitle> <StoreIcon className="size-3.5 text-white/40" />
</div> Price modifier
<CardDescription>Market preferences for this contact.</CardDescription> </span>
</CardHeader> <span className="font-mono text-sm tabular-nums text-white/90">
<CardContent className="flex flex-col gap-4"> ×{priceModifier.toFixed(2)}
<div className="flex items-center justify-between gap-3 text-sm">
<span className="text-muted-foreground">Price modifier</span>
<span className="font-mono tabular-nums">
×{(npc.vendor?.priceModifier ?? 1).toFixed(2)}
</span> </span>
</div> </div>
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<span className="text-xs uppercase tracking-wider text-muted-foreground"> <span className={DOSSIER.readoutLabel}>Goods they sell</span>
Goods they sell
</span>
{sellableAssets.length > 0 ? ( {sellableAssets.length > 0 ? (
<div className="flex flex-wrap gap-1.5"> <div className="flex flex-wrap gap-1.5">
{sellableAssets.map((asset) => ( {sellableAssets.map((asset) => (
<Badge key={asset.id} variant="secondary" className="font-normal"> <span key={asset.id} className={DOSSIER.chip}>
{asset.name} {asset.name}
</Badge> </span>
))} ))}
</div> </div>
) : ( ) : (
<p className="text-sm text-muted-foreground">No goods assigned.</p> <p className="text-sm text-white/60">No goods assigned.</p>
)} )}
</div> </div>
</CardContent> </div>
</Card> </StrategicSummary>
)} )}
<Card> <StrategicSummary
<CardHeader className="flex-row items-start justify-between gap-3"> classificationLeft="Active Market Stock"
<div className="flex flex-col gap-2"> classificationRight={`${listings.length} Listing(s)`}
<CardTitle>Active Market Stock</CardTitle> >
<CardDescription>{listings.length} active listing(s).</CardDescription> <div className="flex flex-col gap-3">
<div className="flex justify-end">
<Button asChild variant="outline" size="sm">
<Link href="/logistics/market">View market</Link>
</Button>
</div> </div>
<Button asChild variant="outline" size="sm">
<Link href="/logistics/market">View market</Link>
</Button>
</CardHeader>
<CardContent>
{listings.length === 0 ? ( {listings.length === 0 ? (
<p className="text-sm italic text-muted-foreground">No active stock.</p> <p className="text-sm italic text-white/50">No active stock.</p>
) : ( ) : (
<div className="flex flex-col"> <div className="flex flex-col">
{listings.map((listing, index) => ( {listings.map((listing, index) => (
<Fragment key={listing.id}> <Fragment key={listing.id}>
{index > 0 && <Separator />} {index > 0 && <Separator className="bg-white/10" />}
<div className="flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0"> <div className="flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0">
<div className="min-w-0"> <div className="min-w-0">
<p className="truncate text-sm font-semibold"> <p className="truncate text-sm font-semibold text-white/90">
{assetName(listing.asset)} {assetName(listing.asset)}
</p> </p>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-white/50">
{listing.quantity.toLocaleString()} available {listing.quantity.toLocaleString()} available
</p> </p>
</div> </div>
<span className="shrink-0 text-sm font-semibold tabular-nums"> <span className="shrink-0 text-sm font-semibold tabular-nums text-white/90">
<CurrencyAmount value={listing.price} currency={listing.currency} /> <CurrencyAmount value={listing.price} currency={listing.currency} />
</span> </span>
</div> </div>
@ -190,8 +245,12 @@ export function NpcProfile({ npc, listings }: NpcProfileProps) {
))} ))}
</div> </div>
)} )}
</CardContent> </div>
</Card> </StrategicSummary>
{employmentSlot ? (
<Fragment key="employment">{employmentSlot}</Fragment>
) : null}
</div> </div>
</div> </div>
</div> </div>

View file

@ -0,0 +1,52 @@
"use client";
import type { GameNpc } from "@/payload-types";
import { cn } from "@/lib/utils";
const STATUS_CHIP: Record<string, string> = {
inGame: "border-emerald-500/40 bg-emerald-500/20 text-emerald-400",
generated: "border-amber-500/40 bg-amber-500/20 text-amber-400",
vendor: "border-violet-500/40 bg-violet-500/20 text-violet-400",
};
function Chip({
label,
tone,
size,
}: {
label: string;
tone: keyof typeof STATUS_CHIP;
size: "default" | "compact";
}) {
return (
<span
className={cn(
"inline-flex items-center border font-mono uppercase leading-none tracking-widest",
size === "compact" ? "px-1 py-px text-[8px]" : "px-1.5 py-0.5 text-[9px]",
STATUS_CHIP[tone],
)}
>
{label}
</span>
);
}
/** Squared tactical status chips shared by the contact card and profile. */
export function NpcStatusChips({
npc,
className,
size = "default",
}: {
npc: GameNpc;
className?: string;
size?: "default" | "compact";
}) {
const vendorEnabled = npc.vendor?.enabled === true;
return (
<div className={cn("flex flex-wrap items-center gap-1.5", className)}>
{npc.isInGame === true && <Chip label="In Game" tone="inGame" size={size} />}
{npc.isGenerated === true && <Chip label="Generated" tone="generated" size={size} />}
{vendorEnabled && <Chip label="Vendor" tone="vendor" size={size} />}
</div>
);
}

View file

@ -0,0 +1,13 @@
/**
* Deterministic two-letter monogram used as the tactical "file photo" backdrop
* on personnel dossier surfaces. Pure, client-safe.
*/
export function initialsOf(name: string): string {
const words = name
.split(/[\s-]+/)
.map((word) => word.replace(/[^A-Za-z0-9]/g, ""))
.filter(Boolean);
if (words.length === 0) return "??";
if (words.length === 1) return words[0].slice(0, 2).toUpperCase();
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,57 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
/**
* Converts GameNpcs.bio from a plain-text column to a Lexical richText (jsonb)
* column. Existing plain-text bios are wrapped in a single Lexical paragraph
* so no data is lost; the `USING` clause is required because there is no
* implicit varchar -> jsonb cast.
*/
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "game_npcs"
ALTER COLUMN "bio" SET DATA TYPE jsonb
USING CASE
WHEN "bio" IS NULL THEN NULL
ELSE jsonb_build_object(
'root', jsonb_build_object(
'type', 'root',
'format', '',
'indent', 0,
'version', 1,
'direction', NULL,
'children', jsonb_build_array(
jsonb_build_object(
'type', 'paragraph',
'format', '',
'indent', 0,
'version', 1,
'direction', NULL,
'textStyle', '',
'textFormat', 0,
'children', jsonb_build_array(
jsonb_build_object(
'type', 'text',
'text', "bio",
'mode', 'normal',
'style', '',
'detail', 0,
'format', 0,
'version', 1
)
)
)
)
)
)
END;`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "game_npcs"
ALTER COLUMN "bio" SET DATA TYPE varchar
USING CASE
WHEN "bio" IS NULL THEN NULL
ELSE "bio" #>> '{root,children,0,children,0,text}'
END;`)
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "game_npcs" ADD COLUMN "image_id" integer;
ALTER TABLE "game_npcs" ADD CONSTRAINT "game_npcs_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
CREATE INDEX "game_npcs_image_idx" ON "game_npcs" USING btree ("image_id");`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "game_npcs" DROP CONSTRAINT "game_npcs_image_id_media_id_fk";
DROP INDEX "game_npcs_image_idx";
ALTER TABLE "game_npcs" DROP COLUMN "image_id";`)
}