{guide.name}
import Link from "next/link"; import Image from "@/components/ui/resilient-image"; import { ArrowLeftIcon } from "lucide-react"; import { notFound, redirect } from "next/navigation"; import { connection } from "next/server"; import { GuideSectionEditor } from "@/components/admin/guide-section-editor"; import { GuideSectionNav } from "@/components/admin/guide-section-nav"; import { AdminHeader } from "@/components/admin/admin-header"; import { EditorPresence } from "@/components/admin/editor-presence"; import { Button } from "@/components/ui/button"; import { getAdminSession } from "@/lib/auth/server"; import { getCachedCatalogOptions } from "@/lib/cache/catalog"; import { toTeamDraft } from "@/lib/guides/team-draft"; import { getAdminGuideContent, getGuideEditorHeader, } from "@/lib/guides/queries"; const sections = [ "weapon", "artifact", "constellations", "team", ] as const; export const instant = false; export default async function StructuredEditorPage({ params, }: { params: Promise<{ character: string; page: string }>; }) { await connection(); if (!(await getAdminSession())) redirect("/auth/login?next=%2Fadmin"); const { character, page } = await params; const guide = await getGuideEditorHeader(character); if (!guide) notFound(); const extraSections = guide.sections.filter((section) => section.kind === "extra"); if (page === "extra") { redirect( extraSections[0] ? `/admin/${character}/${extraSections[0].slug}` : `/admin/${character}`, ); } const fixedSection = sections.includes(page as (typeof sections)[number]); const extraSection = extraSections.find((section) => section.slug === page); if (!fixedSection && !extraSection) notFound(); const editorSection = fixedSection ? page as (typeof sections)[number] : "extra" as const; const sectionTitle = extraSection?.title ?? guide.sections.find((section) => section.slug === page)?.title ?? page; const [catalog, content] = await Promise.all([ getCachedCatalogOptions(), getAdminGuideContent(guide.slug, page), ]); if (!catalog || !content) notFound(); const guideCharacter = content.character; return (
{guide.name}