import { eq } from "drizzle-orm"; import { HelpCircle } from "lucide-react"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { deleteHelpQuestion, updateHelpQuestion } from "@/actions/admin-help"; import { Button } from "@/components/ui/button"; import { db, WebsiteHelpCenterCategories } from "@/lib/db"; import { canAccess, getAdminContext, PERMS } from "@/lib/permissions"; // TODO: Cache Components adoption. Refactor this route so this opt-out can be removed. // See: https://nextjs.org/docs/app/guides/migrating-to-cache-components export const instant = false; export default async function EditHelpQuestion({ params, searchParams, }: { params: Promise<{ id: string }>; searchParams: Promise<{ error?: string }>; }) { const { session, permissions } = await getAdminContext(); if (!canAccess(permissions, PERMS.PAGES_VIEW, session.user.rank)) { redirect("/admin"); } const { id } = await params; const { error } = await searchParams; let entry: typeof WebsiteHelpCenterCategories.$inferSelect | null = null; try { const [row] = await db .select() .from(WebsiteHelpCenterCategories) .where(eq(WebsiteHelpCenterCategories.id, BigInt(id))) .limit(1); entry = row ?? null; } catch { notFound(); } if (!entry) notFound(); return (

Edit help-center entry

← Help Center

{error ? (

Error: {error}

) : null}