Translate admin panel to all 6 languages
This commit is contained in:
1 parent
f381aa987f
commit
befa4ec282
63 files changed
+9353
-1443
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import {
|
||||
createEmailTemplate,
|
||||
deleteEmailTemplate,
|
||||
@@ -8,6 +9,8 @@ import { prisma } from "@/lib/prisma";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function AdminEmailTemplates() {
|
||||
const t = await getTranslations("pages.admin.emailTemplates");
|
||||
|
||||
let templates: Awaited<ReturnType<typeof prisma.emailTemplates.findMany>> = [];
|
||||
try {
|
||||
templates = await prisma.emailTemplates.findMany({ orderBy: { name: "asc" } });
|
||||
@@ -22,10 +25,9 @@ export default async function AdminEmailTemplates() {
|
||||
<span className="text-lg">✉️</span>
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Email Templates</h1>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">{t("title")}</h1>
|
||||
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">
|
||||
Transactional email bodies. Use <code>{"{{ placeholders }}"}</code> in the body and list
|
||||
the available ones in the variables field (comma-separated).
|
||||
{t.rich("subtitle", { code: (chunks) => <code>{chunks}</code> })}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -34,79 +36,79 @@ export default async function AdminEmailTemplates() {
|
||||
action={createEmailTemplate}
|
||||
className="admin-card mb-6"
|
||||
>
|
||||
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">New template</h3>
|
||||
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">{t("newTemplate")}</h3>
|
||||
<div className="flex gap-2 flex-wrap items-center mb-3">
|
||||
<input name="name" placeholder="name (unique)" required className="flex-1 min-w-[180px]" />
|
||||
<input name="name" placeholder={t("form.namePlaceholder")} required className="flex-1 min-w-[180px]" />
|
||||
<input
|
||||
name="subject"
|
||||
placeholder="subject"
|
||||
placeholder={t("form.subjectPlaceholder")}
|
||||
required
|
||||
className="flex-1 min-w-[220px]"
|
||||
/>
|
||||
<input name="variables" placeholder="variables (comma-separated)" className="min-w-[200px]" />
|
||||
<input name="variables" placeholder={t("form.variablesPlaceholder")} className="min-w-[200px]" />
|
||||
<label className="flex items-center gap-2">
|
||||
<input type="checkbox" name="isActive" defaultChecked className="w-auto" />
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">Active</span>
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">{t("form.active")}</span>
|
||||
</label>
|
||||
</div>
|
||||
<textarea
|
||||
name="body"
|
||||
placeholder="Email body (HTML or text)"
|
||||
placeholder={t("form.bodyPlaceholder")}
|
||||
required
|
||||
rows={5}
|
||||
className="w-full resize-y mb-3"
|
||||
/>
|
||||
<button type="submit" className="btn btn-primary">
|
||||
Create
|
||||
{t("create")}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div className="grid">
|
||||
{templates.map((t) => {
|
||||
const id = String(t.id);
|
||||
{templates.map((template) => {
|
||||
const id = String(template.id);
|
||||
return (
|
||||
<div key={id} className="admin-card mb-4">
|
||||
<form action={updateEmailTemplate}>
|
||||
<input type="hidden" name="id" value={id} />
|
||||
<div className="flex gap-2 flex-wrap items-center mb-2">
|
||||
<strong className="min-w-[160px]">{t.name}</strong>
|
||||
<strong className="min-w-[160px]">{template.name}</strong>
|
||||
<input
|
||||
name="subject"
|
||||
defaultValue={t.subject}
|
||||
placeholder="subject"
|
||||
defaultValue={template.subject}
|
||||
placeholder={t("form.subjectPlaceholder")}
|
||||
required
|
||||
className="flex-1 min-w-[220px]"
|
||||
/>
|
||||
<input
|
||||
name="variables"
|
||||
defaultValue={t.variables ?? ""}
|
||||
placeholder="variables"
|
||||
defaultValue={template.variables ?? ""}
|
||||
placeholder={t("form.variablesPlaceholder")}
|
||||
className="min-w-[180px]"
|
||||
/>
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="isActive"
|
||||
defaultChecked={t.isActive}
|
||||
defaultChecked={template.isActive}
|
||||
className="w-auto"
|
||||
/>
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">Active</span>
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">{t("form.active")}</span>
|
||||
</label>
|
||||
</div>
|
||||
<textarea
|
||||
name="body"
|
||||
defaultValue={t.body}
|
||||
defaultValue={template.body}
|
||||
required
|
||||
rows={6}
|
||||
className="w-full resize-y mb-2"
|
||||
/>
|
||||
<div className="flex gap-2 items-center">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
Save
|
||||
{t("save")}
|
||||
</button>
|
||||
{t.updatedAt ? (
|
||||
{template.updatedAt ? (
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400">
|
||||
Updated {new Date(t.updatedAt).toISOString().slice(0, 16).replace("T", " ")}
|
||||
{t("updated", { date: new Date(template.updatedAt).toISOString().slice(0, 16).replace("T", " ") })}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -114,14 +116,14 @@ export default async function AdminEmailTemplates() {
|
||||
<form action={deleteEmailTemplate} className="mt-4">
|
||||
<input type="hidden" name="id" value={id} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
Delete
|
||||
{t("delete")}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{templates.length === 0 ? <div className="admin-empty">No email templates yet.</div> : null}
|
||||
{templates.length === 0 ? <div className="admin-empty">{t("noTemplates")}</div> : null}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user