feat(catalog): undo bulk offer edits with guarded history restoration
CI / check (push) Successful in 2m1s
CI / deploy (push) Successful in 18s
CI / publish-container (push) Successful in 1m28s

This commit is contained in:
Simo committed 2026-09-11 10:47:46 +02:00
1 parent 13bd3695cb
commit c5a2b44807
33 files changed
+1399 -116

No files matched your search

+16
View File
@@ -5,6 +5,7 @@ import {
applyBulkOffersCommand,
listBulkOfferDestinationsCommand,
previewBulkOffersCommand,
undoBulkOffersCommand,
} from "@/features/catalog/server/bulk-offers";
import { catalogFailure } from "@/features/catalog/server/errors";
import { sendCatalogUpdate } from "@/features/catalog/server/sync-status";
@@ -66,3 +67,18 @@ export async function getBulkOfferDestinations() {
return { ok: false as const, error: catalogFailure(error).message };
}
}
export async function undoBulkOffers(historyIds: number[]) {
const staff = await requirePermission(PERMS.CATALOG_EDIT);
try {
return await withCatalogExport(async () => {
const data = await undoBulkOffersCommand(historyIds, staff.id);
await sendCatalogUpdate();
revalidatePath("/admin/catalog", "layout");
revalidatePath("/admin/logs/audit");
return { ok: true as const, data };
});
} catch (error) {
return { ok: false as const, error: catalogFailure(error).message };
}
}