import config from "@payload-config"; import { getPayload } from "payload"; import { headers } from "next/headers"; import { notFound } from "next/navigation"; import type { Metadata } from "next"; import { Map as MapIcon } from "lucide-react"; import { hasPermission } from "@/utils/access-control/hasPermission"; import { hasLogisticsQualification } from "@/utils/access-control/hasLogisticsQualification"; import { MapLoader } from "../MapLoader"; interface MapViewPageProps { params: Promise<{ id: string }>; } export async function generateMetadata({ params }: MapViewPageProps): Promise { const { id } = await params; return { title: `World Map #${id}: Polaris Task Force` }; } export default async function MapViewPage({ params }: MapViewPageProps) { const { id } = await params; const mapId = Number(id); const payload = await getPayload({ config: await config }); const { user } = await payload.auth({ headers: await headers(), canSetHeaders: false }); const map = Number.isInteger(mapId) ? await payload .findByID({ collection: "maps", id: mapId, depth: 0, overrideAccess: true }) .catch(() => null) : null; if (!map) notFound(); const [canEdit, canPlace] = await Promise.all([ user ? hasPermission(payload, user, "maps:update") : Promise.resolve(false), user ? hasLogisticsQualification(payload, user) : Promise.resolve(false), ]); // Inactive maps stay reachable for editors previewing them, but are hidden // from everyone else. if (!map.isActive && !canEdit) notFound(); return (

{map.name}

PTF Unit Command // Tactical Grid {map.worldSizeWidth}×{map.worldSizeHeight} m
); }