"use server"; import { eq } from "drizzle-orm"; import { revalidatePath } from "next/cache"; import { db } from "@/lib/db"; import { getCurrentSession } from "@/lib/session"; import { households } from "@/modules/_core/schema"; export async function renameHousehold(formData: FormData) { const { household, role } = await getCurrentSession(); if (role !== "owner") throw new Error("Forbidden"); const name = formData.get("name"); if (typeof name !== "string" || !name.trim()) throw new Error("Invalid name"); await db.update(households).set({ name: name.trim() }).where(eq(households.id, household.id)); revalidatePath("/settings/household"); }