39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
import { z } from "zod";
|
|
import { contentMutationService } from "@/features/housekeeping/domains/content/services/mutations";
|
|
import { actionOk, adminAction } from "@/lib/foundation/action";
|
|
import { PERMS } from "@/lib/permissions";
|
|
|
|
const schema = z.object({
|
|
groupOrder: z.array(z.string()),
|
|
hiddenGroups: z.array(z.string()),
|
|
hiddenItems: z.array(z.string()),
|
|
itemOrder: z.record(z.string(), z.array(z.string())),
|
|
});
|
|
|
|
export const saveAdminNavConfig = adminAction(
|
|
{
|
|
permission: PERMS.SETTINGS_EDIT,
|
|
schema,
|
|
rateLimitKey: "admin-nav-config-save",
|
|
rateLimitMax: 30,
|
|
},
|
|
async (ctx) => {
|
|
const result = await contentMutationService.execute(
|
|
{
|
|
correlationId: String(ctx.requestId),
|
|
expectedActorId: Number(ctx.session.user.id),
|
|
legacy: true,
|
|
},
|
|
"navigation.update",
|
|
ctx.data,
|
|
);
|
|
if (!result.ok) throw new Error("Navigation update failed");
|
|
revalidatePath("/admin", "layout");
|
|
revalidatePath("/admin/menu");
|
|
return actionOk({ saved: true });
|
|
},
|
|
);
|