'use client' import React, { useState } from 'react' import { ModalBase } from './ModalBase' import { apiFetch } from '../_api' export function CreateNamespaceModal({ tenantId, onClose, onCreated }: { tenantId: string; onClose: () => void; onCreated: () => void }) { const [form, setForm] = useState({ name: '', slug: '', isolation_level: 'shared', classification: 'internal' }) const [saving, setSaving] = useState(false) const [error, setError] = useState(null) const handleSubmit = async () => { if (!form.name) { setError('Name ist Pflichtfeld'); return } setSaving(true) try { await apiFetch(`tenants/${tenantId}/namespaces`, { method: 'POST', body: JSON.stringify(form) }) onCreated() } catch (e) { setError(e instanceof Error ? e.message : 'Fehler') } finally { setSaving(false) } } return ( {error &&
{error}
}
setForm(f => ({ ...f, name: e.target.value }))} className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm" />
setForm(f => ({ ...f, slug: e.target.value }))} className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono" />
) }