feat(housekeeping): deliver economy vertical
This commit is contained in:
1 parent
1ec05cda39
commit
9c4b973faf
62 files changed
+6306
-1285
No files matched your search
@@ -1,5 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import {
|
||||
type EconomyMutationOperation,
|
||||
executeLegacyEconomyMutation,
|
||||
} from "@/features/housekeeping/domains/economy/services/mutations";
|
||||
import { requirePermission } from "@/lib/admin/guard";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import {
|
||||
@@ -18,7 +22,16 @@ import type {
|
||||
import * as maintenance from "@/lib/services/furni-maintenance";
|
||||
|
||||
async function guard() {
|
||||
await requirePermission(PERMS.CATALOG_EDIT);
|
||||
return requirePermission(PERMS.CATALOG_EDIT);
|
||||
}
|
||||
|
||||
async function mutate<T>(
|
||||
operation: EconomyMutationOperation,
|
||||
input: Record<string, unknown> = {},
|
||||
): Promise<T> {
|
||||
const staff = await guard();
|
||||
const snapshot = await executeLegacyEconomyMutation(staff, operation, input);
|
||||
return snapshot.output as T;
|
||||
}
|
||||
|
||||
export async function getFurniHealthAction(): Promise<
|
||||
@@ -37,8 +50,9 @@ export async function fixSpriteIdsAction(): Promise<
|
||||
ActionResult<FixSpriteResult>
|
||||
> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.fixSpriteIds());
|
||||
return actionOk(
|
||||
await mutate<FixSpriteResult>("maintenance.fix-sprite-ids"),
|
||||
);
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
@@ -48,8 +62,7 @@ export async function fixCatalogOffersAction(): Promise<
|
||||
ActionResult<FixOfferResult>
|
||||
> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.fixCatalogOffers());
|
||||
return actionOk(await mutate<FixOfferResult>("maintenance.fix-offers"));
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
@@ -59,8 +72,7 @@ export async function reconcileIdsAction(): Promise<
|
||||
ActionResult<ReconcileResult>
|
||||
> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.reconcileIds());
|
||||
return actionOk(await mutate<ReconcileResult>("maintenance.reconcile-ids"));
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
@@ -70,8 +82,7 @@ export async function removeDuplicateItemsBaseAction(): Promise<
|
||||
ActionResult<DedupResult>
|
||||
> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.removeDuplicates());
|
||||
return actionOk(await mutate<DedupResult>("maintenance.remove-duplicates"));
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
@@ -81,8 +92,9 @@ export async function previewAlignIdsAction(): Promise<
|
||||
ActionResult<AlignResult>
|
||||
> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.forceItemsBaseIdsToFurnidata(false));
|
||||
return actionOk(
|
||||
await mutate<AlignResult>("maintenance.align-ids", { apply: false }),
|
||||
);
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
@@ -92,8 +104,9 @@ export async function applyAlignIdsAction(): Promise<
|
||||
ActionResult<AlignResult>
|
||||
> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.forceItemsBaseIdsToFurnidata(true));
|
||||
return actionOk(
|
||||
await mutate<AlignResult>("maintenance.align-ids", { apply: true }),
|
||||
);
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
@@ -103,8 +116,12 @@ export async function fixEverythingAction(input?: {
|
||||
dedupePages?: boolean;
|
||||
}): Promise<ActionResult<maintenance.FixAllResult>> {
|
||||
try {
|
||||
await guard();
|
||||
return actionOk(await maintenance.fixEverything(input ?? {}));
|
||||
return actionOk(
|
||||
await mutate<maintenance.FixAllResult>(
|
||||
"maintenance.fix-everything",
|
||||
input ?? {},
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
return handleActionError(e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user