import { getTranslations } from "next-intl/server"; import { updateEmulatorSetting, updateEmulatorText } from "@/actions/admin-emulator"; import { StatusCard } from "@/components/admin/dashboard"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; const TEXTS_LIMIT = 300; export default async function AdminEmulator() { const t = await getTranslations("pages.admin.emulator"); let settings: { key: string; value: string }[] = []; try { settings = await prisma.emulatorSettings.findMany({ orderBy: { key: "asc" } }); } catch { settings = []; } let texts: { key: string; value: string }[] = []; let textsCount = 0; try { textsCount = await prisma.emulatorTexts.count(); } catch { textsCount = 0; } try { texts = await prisma.emulatorTexts.findMany({ orderBy: { key: "asc" }, take: TEXTS_LIMIT, }); } catch { texts = []; } const textsTruncated = textsCount > texts.length; return (

{t("title")}

{t.rich("subtitle", { code: (chunks) => {chunks}, })}

{t("settings")}

{t("keysCount", { count: settings.length })}

{t("addOverwriteSetting")}

{settings.map((s) => ( ))}
{t("colKey")} {t("colValue")}
{s.key}
{settings.length === 0 ? (

{t("noSettings")}

) : null}

{t("texts")}

{t("keysCount", { count: textsCount })} {textsTruncated ? ` (${t("showingFirst", { count: texts.length })})` : ""}.

{t("addOverwriteText")}

{texts.map((txt) => ( ))}
{t("colKey")} {t("colValue")}
{txt.key}
{texts.length === 0 ?
{t("noTexts")}
: null} {textsTruncated ? (

{t("truncatedHint", { shown: texts.length, total: textsCount })}

) : null}
); }