"use client"; import Link from "next/link"; import type { GameNpc } from "@/payload-types"; import { cn } from "@/lib/utils"; 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 { readonly npc: GameNpc; } export function NpcCard({ npc }: NpcCardProps) { const factionName = 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 (
{imageUrl ? ( ) : ( <>
{monogram}
)}
{readoutCells.map((cell, index) => (
{cell.value} {cell.label}
))}
); }