- update-Nitrov3.sh: build CMS into .next-staging and swap atomically so a failed build never takes the live site down; auto-merge new variables from .env.example; validate env for duplicates/broken lines; restart the emulator/CMS only when rebuilt or unhealthy; fix step renumbering - next.config.ts: support NEXT_DIST_DIR for staged production builds - fix all TS errors (unused imports, missing tryDownloadCandidates helper) so tsc and the production build pass clean - add Dockerfile/.dockerignore and switch docker-compose to a CMS container - include prevailing UI/refactor changes (SurfaceCard, ticketing, tsconfig)
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
"use server";
|
|
|
|
import { z } from "zod";
|
|
import { db, WebsiteSetting } from "@/lib/db";
|
|
import { PERMS } from "@/lib/permissions";
|
|
import { adminAction } from "@/lib/safe-action";
|
|
import { actionOk } from "@/lib/safe-action-shared";
|
|
import { deleteImportedItem } from "@/lib/services/furni-import";
|
|
import { siteSettings } from "@/lib/services/site-settings";
|
|
|
|
const deleteSchema = z.object({ classname: z.string().trim().min(1) });
|
|
|
|
export const deleteImportedFurni = adminAction(
|
|
{ permission: PERMS.ASSETS_IMPORT, schema: deleteSchema },
|
|
async (ctx) =>
|
|
actionOk(
|
|
(await deleteImportedItem(ctx.data.classname)) as unknown as Record<
|
|
string,
|
|
unknown
|
|
>,
|
|
),
|
|
);
|
|
|
|
const translateToggleSchema = z.object({ enabled: z.boolean() });
|
|
|
|
/** Persist the global "translate furniture names" setting from the studio. */
|
|
export const setFurnidataTranslateEnabled = adminAction(
|
|
{ permission: PERMS.ASSETS_IMPORT, schema: translateToggleSchema },
|
|
async (ctx) => {
|
|
const value = ctx.data.enabled ? "1" : "0";
|
|
await db
|
|
.insert(WebsiteSetting)
|
|
.values({ key: "furnidata_translate_enabled", value })
|
|
.onDuplicateKeyUpdate({ set: { value } });
|
|
await siteSettings.reload();
|
|
return actionOk({ enabled: ctx.data.enabled });
|
|
},
|
|
);
|