"use client"; import Link from "next/link"; import { Item, ItemContent, ItemDescription, ItemHeader, ItemMedia, ItemTitle, } from "@/components/ui/item"; import { CapacityBar } from "@/components/frontend/storage/CapacityBar"; import { getCategoryLabel, getFunctionTypeLabel, getGridSlots, getResourceCount, calculateStoredMass, calculateUtilization, } from "@/lib/logistics"; import { GameStructure, Faction, Structure, Resource } from "@/payload-types"; import { BoxIcon, Building2Icon, ChevronRightIcon, Grid3x3Icon, MapPinIcon, } from "lucide-react"; interface StructureCardProps { structure: GameStructure & { type: Structure; faction?: Faction | null; }; } export function StructureCard({ structure }: StructureCardProps) { const structureType = structure.type; const storedResources = structure.storedResources ?? []; const currentMass = calculateStoredMass(storedResources); const utilization = calculateUtilization(structureType, storedResources); const resourceCount = getResourceCount(storedResources); const gridSlots = getGridSlots(structureType); const functionLabel = getFunctionTypeLabel(structureType.functionType); return (
{structure.name} {structureType.name}
{structure.faction && typeof structure.faction === "object" && ( {structure.faction.name} )} {getCategoryLabel(structureType.category)}
{resourceCount} resource{resourceCount !== 1 ? "s" : ""} {gridSlots !== null && ( {structureType.xSize}×{structureType.ySize} grid )} {functionLabel && ( {functionLabel} )}
{structure.coordinates && ( {structure.coordinates[0].toFixed(1)}, {structure.coordinates[1].toFixed(1)} )}
{resourceCount === 0 ? "Empty — no resources stored." : `${resourceCount} resource type${resourceCount !== 1 ? "s" : ""} stored`} View details
); }