diff --git a/src/app/(frontend)/intelligence/campaigns/[id]/page.tsx b/src/app/(frontend)/intelligence/campaigns/[id]/page.tsx index 77b80c3..f1d14c8 100644 --- a/src/app/(frontend)/intelligence/campaigns/[id]/page.tsx +++ b/src/app/(frontend)/intelligence/campaigns/[id]/page.tsx @@ -2,7 +2,7 @@ import config from "@payload-config"; import { getPayload } from "payload"; import { notFound } from "next/navigation"; import Link from "next/link"; -import type { Campaign, Faction, Mission } from "@/payload-types"; +import type { Campaign, Faction, Media, Mission } from "@/payload-types"; import { RichText } from "@payloadcms/richtext-lexical/react"; import { ArrowLeftIcon, @@ -13,13 +13,7 @@ import { TargetIcon, UsersIcon, } from "lucide-react"; -import { - Item, - ItemContent, - ItemDescription, - ItemHeader, - ItemTitle, -} from "@/components/ui/item"; +import { Item, ItemContent, ItemDescription, ItemHeader, ItemTitle } from "@/components/ui/item"; interface CampaignDetailPageProps { params: Promise<{ id: string }>; @@ -48,9 +42,7 @@ const missionStatusColors: Record = { Cancelled: "bg-red-500/20 text-red-400", }; -export default async function CampaignDetailPage({ - params, -}: CampaignDetailPageProps) { +export default async function CampaignDetailPage({ params }: CampaignDetailPageProps) { const { id } = await params; const payload = await getPayload({ config }); @@ -58,7 +50,7 @@ export default async function CampaignDetailPage({ .findByID({ collection: "campaigns", id: Number(id), - depth: 0, + depth: 1, }) .catch(() => null); @@ -66,6 +58,12 @@ export default async function CampaignDetailPage({ notFound(); } + const coverImage = + typeof campaign.coverImage === "object" && campaign.coverImage !== null + ? (campaign.coverImage as Media) + : null; + const coverImageUrl = coverImage?.url ?? null; + const [missionsRes, factionsRes] = await Promise.all([ payload .find({ @@ -82,6 +80,7 @@ export default async function CampaignDetailPage({ classification: true, ownershipAndStatus: true, missionRoles: true, + coverImage: true, }, }) .catch(() => ({ docs: [] })), @@ -120,200 +119,220 @@ export default async function CampaignDetailPage({ } return ( -
- - - Back to Campaigns - - -
-
-
- -

{campaign.name}

-
-
- - {campaign.status === "inProgress" - ? "In Progress" - : campaign.status.charAt(0).toUpperCase() + - campaign.status.slice(1)} - - {startDate && ( - - - {startDate} - {endDate ? ` — ${endDate}` : " — Present"} - - )} -
+
+
+
+ + + Back to Campaigns +
-
+ {coverImageUrl ? ( + + ) : ( +
+ )} +
+
-

{campaign.summary}

+
+ + {campaign.status === "inProgress" + ? "In Progress" + : campaign.status.charAt(0).toUpperCase() + campaign.status.slice(1)} + +
-
- {/* ── Main Content (2/3) ──────────────────────────── */} -
- {campaign.description && ( - - - Description - - - - - - )} - -
-
-

- Missions -

- - {missions.length} mission{missions.length !== 1 ? "s" : ""} - +
+

+ {campaign.name} +

+

{campaign.summary}

+ {(startDate || endDate) && ( +
+ + {startDate && {startDate}} + {startDate && endDate && —} + {endDate ? {endDate} : startDate ? Present : null}
- {missions.length > 0 ? ( -
- {missions.map((mission) => ( - - - -
- - {mission.codeName} - - {mission.name} -
- - {mission.ownershipAndStatus.status} - -
- - - {mission.summary} - - -
- - ))} -
- ) : ( - - -

- No missions in this campaign yet. -

+ )} +
+ + +
+
+ {/* ── Main Content (2/3) ──────────────────────────── */} +
+ {campaign.description && ( + + + Description + + + )} -
-
- {/* ── Right Sidebar (1/3) ─────────────────────────── */} -
- {/* Campaign Stats */} - - -
- - Campaign Stats +
+
+

+ Missions +

+ + {missions.length} mission{missions.length !== 1 ? "s" : ""} +
- - -
-
- Total Missions - {missions.length} -
- {Object.entries(statusCounts).map(([status, count]) => ( -
- - - {status} - - {count} -
- ))} - {campaign.startDate && ( -
- Duration - - {startDate} - {endDate ? ` — ${endDate}` : " — Present"} - -
- )} -
-
- - - {/* Faction Roster */} - {factions.length > 0 && ( - - -
- - Faction Roster -
- - View all - -
- + {missions.length > 0 ? (
- {factions.map((faction) => ( - - -
- - {faction.name} - - - {faction.type === "majorFaction" - ? "Major" - : faction.type === "minorFaction" - ? "Minor" - : faction.type} - -
- + {missions.map((mission) => ( + + +
+ +
+ +
+ + {mission.codeName} + + {mission.name} +
+ + {mission.ownershipAndStatus.status} + +
+ + + {mission.summary} + + +
))}
+ ) : ( + + +

+ No missions in this campaign yet. +

+
+
+ )} +
+
+ + {/* ── Right Sidebar (1/3) ─────────────────────────── */} +
+ {/* Campaign Stats */} + + +
+ + Campaign Stats +
+
+ +
+
+ Total Missions + {missions.length} +
+ {Object.entries(statusCounts).map(([status, count]) => ( +
+ + + {status} + + {count} +
+ ))} + {campaign.startDate && ( +
+ Duration + + {startDate} + {endDate ? ` — ${endDate}` : " — Present"} + +
+ )} +
- )} + + {/* Faction Roster */} + {factions.length > 0 && ( + + +
+ + Faction Roster +
+ + View all + +
+ +
+ {factions.map((faction) => ( + + +
+ + {faction.name} + + + {faction.type === "majorFaction" + ? "Major" + : faction.type === "minorFaction" + ? "Minor" + : faction.type} + +
+ + + ))} +
+
+
+ )} +