import { redirect } from "next/navigation"; import { connection } from "next/server"; import { AdminHeader } from "@/components/admin/admin-header"; import { StygianEditor } from "@/components/admin/stygian-editor"; import { StygianSyncButton } from "@/components/admin/stygian-sync-button"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { getAdminSession } from "@/lib/auth/server"; import { getActiveCatalog } from "@/lib/guides/queries"; import { getStygianSchedule, listStygianSchedules } from "@/lib/stygian/repository"; export default async function AdminStygianPage({ searchParams }: { searchParams: Promise> }) { await connection(); if (!(await getAdminSession())) redirect("/admin/login"); const query = await searchParams; const schedules = await listStygianSchedules(); const raw = Array.isArray(query.schedule) ? query.schedule[0] : query.schedule; const selectedId = Number(raw) || schedules.find((entry) => entry.isActive)?.scheduleId || schedules[0]?.scheduleId; const [schedule, catalog] = await Promise.all([selectedId ? getStygianSchedule(selectedId) : null, getActiveCatalog()]); return (

Stygian Onslaught

Stygian Guide

Sync Lunaris schedules, prepare recommendations, and choose the public version.

{!schedule || !catalog ? No Stygian schedules yetUse the sync action below after the catalog has been synchronized. : null} {schedule && catalog ? ({ scheduleId, challengeName, version, isActive }))} schedule={{ scheduleId: schedule.scheduleId, challengeName: schedule.challengeName, version: schedule.version, isActive: schedule.isActive }} bosses={schedule.bosses.map(({ level, position, name, imageUrl }) => ({ level, position, name, imageUrl }))} recommendations={schedule.recommendations} characters={catalog.characters.map(({ key, name, aliases, imageUrl, rarity, constellations }) => ({ key, name, aliases, imageUrl, rarity, constellations: constellations.map(({ level, name: constellationName, iconUrl }) => ({ level, name: constellationName, iconUrl })) }))} weapons={catalog.weapons.map(({ key, name, aliases, imageUrl, rarity }) => ({ key, name, aliases, imageUrl, rarity }))} artifacts={catalog.artifacts.map(({ key, name, aliases, imageUrl, rarity }) => ({ key, name, aliases, imageUrl, rarity }))} /> : schedules.length === 0 && catalog ? : null}
); }