import { redirect } from "next/navigation"; import { getSession } from "../../lib/auth"; import { listAccounts } from "../../lib/platform-db"; import { createTenant } from "./actions"; import { DeleteTenantButton } from "./DeleteTenantButton"; import { AppHeader } from "../AppHeader"; 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 */}

Sociaal ondernemers ({accounts.length})

{accounts.length === 0 ? (

Nog geen sociaal ondernemers aangemaakt.

) : (
{accounts.map((a) => ( ))}
Naam Slug URL Gebruikers Aangemaakt
{a.name} {a.slug} {a.slug}.rikxplatform.nl {a.user_count} {new Date(a.created_at).toLocaleDateString("nl-NL")} Inloggen ↗ Bewerken
)}
{/* Nieuwe sociaal ondernemer formulier */}

Nieuwe sociaal ondernemer aanmaken

{errorMsg && (

{errorMsg}

)}
); }