import { useEffect, useState } from 'react'; import { FaPlus, FaSignOutAlt, FaTrash, FaClock, FaUsers, FaUser } from 'react-icons/fa'; import { api } from '../api/client'; export default function SuperAdmin({ user, onLogout }) { const [tenants, setTenants] = useState([]); const [loading, setLoading] = useState(true); const [showNew, setShowNew] = useState(false); const [createdInfo, setCreatedInfo] = useState(null); const load = async () => { setLoading(true); try { setTenants(await api.getTenants()); } finally { setLoading(false); } }; useEffect(() => { load(); }, []); const extend = async (id, days) => { await api.updateTenant(id, { extend_days: days }); load(); }; const setStatus = async (id, status) => { await api.updateTenant(id, { status }); load(); }; const del = async (id) => { if (!confirm('Tenant inkl. aller Daten loeschen?')) return; await api.deleteTenant(id); load(); }; return (
Pfandsystem · SuperAdmin
{user.email}

Tenants

{tenants.length} Tenants · {tenants.filter(t => t.typ === 'demo').length} Demos

{loading ?
Lade…
: (
{tenants.map(t => { const expired = t.demo_expires_at && new Date(t.demo_expires_at) < new Date(); return ( ); })} {tenants.length === 0 && ( )}
Name Slug Typ Status User / Kunden Ablauf
{t.name}
{t.kontakt_email}
{t.slug} {t.typ} {t.user_count} {t.kunden_count} {t.demo_expires_at ? ( {new Date(t.demo_expires_at).toLocaleDateString('de-DE')} ) : } {t.typ === 'demo' && ( )}
Noch keine Tenants.
)}
{showNew && setShowNew(false)} onCreated={(info) => { setCreatedInfo(info); setShowNew(false); load(); }} />} {createdInfo && setCreatedInfo(null)} />}
); } function NewTenantModal({ onClose, onCreated }) { const [form, setForm] = useState({ name: '', kontakt_email: '', firma: '', days: 30, seed: true }); const [busy, setBusy] = useState(false); const [error, setError] = useState(''); const submit = async (e) => { e.preventDefault(); setBusy(true); setError(''); try { onCreated(await api.createTenant(form)); } catch (e) { setError(e.message); } finally { setBusy(false); } }; return (
e.stopPropagation()} className="bg-white rounded-xl max-w-md w-full p-6 shadow-soft space-y-4">

Neuer Demo-Account

{error &&
{error}
} setForm(f => ({ ...f, name: e.target.value }))} /> setForm(f => ({ ...f, kontakt_email: e.target.value }))} /> setForm(f => ({ ...f, firma: e.target.value }))} /> setForm(f => ({ ...f, days: parseInt(e.target.value) || 30 }))} />
); } function CreatedInfoModal({ info, onClose }) { return (
e.stopPropagation()} className="bg-white rounded-xl max-w-md w-full p-6 shadow-soft space-y-3">

Demo-Account angelegt

Der Interessent erhaelt eine Einladungs-Mail. Hier zur Sicherheit die Daten:

Slug:
{info.slug}
E-Mail:
{info.admin_email}
Passwort:
{info.admin_password_oneshot}
Gueltig:
{info.demo_expires_in_days} Tage

Das Passwort wird nur einmal angezeigt.

); } function Field({ label, children }) { return
{children}
; }