import { redirect } from "next/navigation";
import { getSession, destroySession } from "../../lib/auth";
import { listAccounts } from "../../lib/platform-db";
import { createTenant, deleteTenant } from "./actions";
export default async function TenantsPage({
searchParams,
}: {
searchParams: Promise<{ error?: string }>;
}) {
const session = await getSession();
if (!session) redirect("/login");
const { error } = await searchParams;
const accounts = listAccounts();
const errorMsg =
error === "slug"
? "Slug is al in gebruik."
: error === "missing"
? "Vul alle velden in."
: null;
return (
{/* Overzicht */}
Tenants ({accounts.length})
{accounts.length === 0 ? (
Nog geen tenants aangemaakt.
) : (
| Naam |
Slug |
URL |
Gebruikers |
Aangemaakt |
|
{accounts.map((a) => (
| {a.name} |
{a.slug} |
{a.slug}.rikxplatform.nl
|
{a.user_count} |
{new Date(a.created_at).toLocaleDateString("nl-NL")}
|
|
))}
)}
{/* Nieuw tenant formulier */}
Nieuwe tenant aanmaken
{errorMsg && (
{errorMsg}
)}
);
}