29 lines
1008 B
TypeScript
29 lines
1008 B
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
import {
|
|
createPeopleMutationInvocation,
|
|
peopleMutationService,
|
|
} from "@/features/housekeeping/domains/people/services/mutations";
|
|
import { createCorrelationId } from "@/features/housekeeping/foundation/contracts";
|
|
import { requirePermissionRateLimited } from "@/lib/admin/guard";
|
|
import { PERMS } from "@/lib/permissions";
|
|
|
|
/** Disband a guild and clean related membership/forum rows. */
|
|
export async function disbandGuild(formData: FormData): Promise<void> {
|
|
const staff = await requirePermissionRateLimited(PERMS.USERS_EDIT);
|
|
const guildId = Number(formData.get("id"));
|
|
if (!Number.isSafeInteger(guildId) || guildId <= 0) return;
|
|
|
|
const result = await peopleMutationService.execute(
|
|
createPeopleMutationInvocation(staff, createCorrelationId()),
|
|
"guild.disband",
|
|
{ guildId },
|
|
);
|
|
if (!result.ok) {
|
|
if (result.error.code === "NOT_FOUND") return;
|
|
throw new Error("Could not disband guild");
|
|
}
|
|
revalidatePath("/admin/guilds");
|
|
}
|