import { ShellPage } from "@/components/page-templates"; import { Button, SectionCard } from "@/components/ui"; import { createTenant } from "@/lib/admin-crud"; import { getSession } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import { redirect } from "next/navigation"; export default async function NewTenantPage({ searchParams }: { searchParams?: Promise<{ error?: string }>; }) { const session = await getSession(); if (!session || session.role !== "super_admin") { redirect("/unauthorized"); } const [plans, params] = await Promise.all([ prisma.subscriptionPlan.findMany({ orderBy: { priceMonthly: "asc" } }), searchParams ?? Promise.resolve({ error: undefined }) ]); const error = params.error; const errorMessage = error === "missing_fields" ? "Nama perusahaan, slug, timezone, dan plan wajib diisi." : error === "invalid_plan" ? "Plan tidak valid." : error === "slug_exists" ? "Slug tenant sudah dipakai." : error === "admin_email_exists" ? "Email admin awal sudah terpakai." : null; return (
{errorMessage ?

{errorMessage}

: null}
); }