import type { Metadata } from "next"; import config from "@payload-config"; import { getPayload } from "payload"; import { headers as nextHeaders } from "next/headers"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { ArrowLeftIcon, EyeOffIcon, MicIcon, TriangleAlertIcon } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; import { VoiceoverRecorder } from "@/components/frontend/voiceover/VoiceoverRecorder"; import { SpoilerDescription, SpoilerGate } from "@/components/frontend/voiceover/SpoilerGate"; import { getScriptForUser } from "@/lib/voiceover"; import { isPayloadUser } from "@/utils/access-control/isPayloadUser"; export const metadata: Metadata = { title: "Record voiceover: Polaris Task Force", description: "Read a Polaris Task Force voiceover script and submit a recording.", }; export default async function VoiceoverScriptPage({ params, }: { readonly params: Promise<{ id: string }>; }) { const { id } = await params; const scriptId = Number(id); if (!Number.isInteger(scriptId) || scriptId < 1) notFound(); const headers = await nextHeaders(); const payloadConfig = await config; const payload = await getPayload({ config: payloadConfig }); const { user } = await payload.auth({ headers, canSetHeaders: false }); if (!isPayloadUser(user)) { redirect(`/login?returnTo=${encodeURIComponent(`/voiceover/${id}`)}`); } const script = await getScriptForUser(payload, user, scriptId); if (!script) notFound(); return (
Voiceover scripts

{script.title}

Read the script at your pace, then submit one clear take for review.

{script.status === "draft" && (

Draft preview

This script is still a draft and is hidden from other users.

)} {script.spoiler && (

Potential campaign spoilers ahead

This script may include, infer, or otherwise expose campaign spoilers. Read on only if you are comfortable with that.

)}
); }