Voeg bewerken van sociaal ondernemer toe (naam en slug)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 13:13:59 +02:00
parent 46f5ae4aeb
commit 46eecc31a4
4 changed files with 132 additions and 1 deletions
+22
View File
@@ -57,3 +57,25 @@ export async function deleteTenant(formData: FormData) {
redirect("/tenants");
}
export async function updateTenant(formData: FormData) {
const session = await getSession();
if (!session) redirect("/login");
const accountId = Number(formData.get("account_id"));
const name = ((formData.get("name") as string) ?? "").trim();
const slug = ((formData.get("slug") as string) ?? "").trim().toLowerCase().replace(/[^a-z0-9-]/g, "-");
if (!accountId) redirect("/tenants");
if (!name || !slug) redirect(`/tenants/${accountId}?error=missing`);
const db = getPlatformDb();
const existing = db
.prepare("SELECT id FROM accounts WHERE slug = ? AND id != ?")
.get(slug, accountId);
if (existing) redirect(`/tenants/${accountId}?error=slug`);
db.prepare("UPDATE accounts SET name = ?, slug = ? WHERE id = ?").run(name, slug, accountId);
redirect("/tenants");
}