41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { ShellPage } from "@/components/page-templates";
|
|
import { TablePlaceholder } from "@/components/placeholders";
|
|
import { getSession } from "@/lib/auth";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { redirect } from "next/navigation";
|
|
|
|
function formatMoney(value: number) {
|
|
return new Intl.NumberFormat("id-ID", {
|
|
style: "currency",
|
|
currency: "IDR",
|
|
maximumFractionDigits: 0
|
|
}).format(value);
|
|
}
|
|
|
|
export default async function SuperAdminPlanCatalogPage() {
|
|
const session = await getSession();
|
|
if (!session || session.role !== "super_admin") {
|
|
redirect("/unauthorized");
|
|
}
|
|
|
|
const plans = await prisma.subscriptionPlan.findMany({
|
|
orderBy: { createdAt: "asc" }
|
|
});
|
|
|
|
return (
|
|
<ShellPage shell="super-admin" title="Plan Catalog" description="Master plan langganan untuk tenant.">
|
|
<TablePlaceholder
|
|
title="Plans"
|
|
columns={["Plan", "Price", "Message quota", "Seat quota", "Broadcast quota"]}
|
|
rows={plans.map((plan) => [
|
|
`${plan.name} (${plan.code})`,
|
|
formatMoney(plan.priceMonthly),
|
|
String(plan.messageQuota),
|
|
String(plan.seatQuota),
|
|
String(plan.broadcastQuota)
|
|
])}
|
|
/>
|
|
</ShellPage>
|
|
);
|
|
}
|