48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
import { executeLegacySystemMutation } from "@/features/housekeeping/domains/system/services/mutations";
|
|
import { requirePermission } from "@/lib/admin/guard";
|
|
import { PERMS } from "@/lib/permissions";
|
|
|
|
// emulator_settings: PK is the string column `key`, payload is `value` (VarChar 512).
|
|
// emulator_texts: PK is the string column `key`, payload is `value` (VarChar 4096).
|
|
// Both tables are emulator-owned; we only ever read/update existing rows or add new
|
|
// keys via upsert. We never migrate or drop them.
|
|
|
|
export async function updateEmulatorSetting(formData: FormData): Promise<void> {
|
|
const actor = await requirePermission(PERMS.SETTINGS_EDIT);
|
|
const key = String(formData.get("key") ?? "")
|
|
.normalize("NFC")
|
|
.trim()
|
|
.slice(0, 100);
|
|
const value = String(formData.get("value") ?? "")
|
|
.normalize("NFC")
|
|
.slice(0, 512);
|
|
if (!key) return;
|
|
await executeLegacySystemMutation(
|
|
actor,
|
|
"configuration.emulator-setting.update",
|
|
{ key, value },
|
|
);
|
|
revalidatePath("/admin/emulator");
|
|
}
|
|
|
|
export async function updateEmulatorText(formData: FormData): Promise<void> {
|
|
const actor = await requirePermission(PERMS.SETTINGS_EDIT);
|
|
const key = String(formData.get("key") ?? "")
|
|
.normalize("NFC")
|
|
.trim()
|
|
.slice(0, 100);
|
|
const value = String(formData.get("value") ?? "")
|
|
.normalize("NFC")
|
|
.slice(0, 4096);
|
|
if (!key) return;
|
|
await executeLegacySystemMutation(
|
|
actor,
|
|
"configuration.emulator-text.update",
|
|
{ key, value },
|
|
);
|
|
revalidatePath("/admin/emulator");
|
|
}
|