fix(housekeeping): address task 14 review round 2

This commit is contained in:
Simo committed 2026-08-30 11:30:17 +02:00
1 parent d09eaa33d6
commit c524b305d7
17 files changed
+614 -130

No files matched your search

+28 -4
View File
@@ -1,17 +1,41 @@
"use server";
import { revalidatePath } from "next/cache";
import { executeLegacyBrandAssetMutation } from "@/features/housekeeping/domains/content/services/mutation-runtime-external";
import { requireStaff } from "@/lib/admin/guard";
import type { ContentMutationSnapshot } from "@/features/housekeeping/domains/content/services/mutations";
import { createCorrelationId } from "@/features/housekeeping/foundation/contracts";
import { requireStaff, type StaffUser } from "@/lib/admin/guard";
async function executeAuditedLogoMutation(
staff: StaffUser,
input: unknown,
): Promise<ContentMutationSnapshot> {
const [
{ contentProductionMutationAdapter },
{ getHousekeepingCapabilityContext },
] = await Promise.all([
import(
"@/features/housekeeping/domains/content/services/mutations-production"
),
import("@/features/housekeeping/foundation/server-capability-context"),
]);
const capability = await getHousekeepingCapabilityContext();
if (capability.actor.id !== staff.id)
throw new Error("Authenticated staff changed during logo mutation");
return contentProductionMutationAdapter.execute("logo.save", input, {
capability,
correlationId: createCorrelationId(),
legacy: true,
});
}
export async function saveLogo(
formData: FormData,
): Promise<{ success: boolean; url?: string; error?: string }> {
await requireStaff();
const staff = await requireStaff();
try {
const file = formData.get("file") as File | null;
if (!file) return { success: false, error: "No file provided" };
const result = await executeLegacyBrandAssetMutation("logo.save", { file });
const result = await executeAuditedLogoMutation(staff, { file });
revalidatePath("/", "layout");
return {
success: true,