refactor: convert admin pages to Tailwind and improve media uploads; fix TypeScript error in commandocentrum
This commit is contained in:
1 parent
72ef74fc87
commit
518c072491
22 files changed
+488
-430
No files matched your search
@@ -17,37 +17,36 @@ export default async function AdminEmailTemplates() {
|
||||
|
||||
return (
|
||||
<main>
|
||||
<h1>Email Templates</h1>
|
||||
<p className="muted">
|
||||
Transactional email bodies. Use <code>{"{{ placeholders }}"}</code> in the body and list
|
||||
the available ones in the variables field (comma-separated).
|
||||
</p>
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--color-primary)]/20 to-[var(--color-primary)]/5 grid place-items-center">
|
||||
<span className="text-lg">✉️</span>
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Email Templates</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).
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form
|
||||
action={createEmailTemplate}
|
||||
className="card"
|
||||
style={{ marginBottom: "1.5rem" }}
|
||||
className="admin-card mb-6"
|
||||
>
|
||||
<h3 style={{ marginTop: 0 }}>New template</h3>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.5rem",
|
||||
flexWrap: "wrap",
|
||||
marginBottom: "0.5rem",
|
||||
}}
|
||||
>
|
||||
<input name="name" placeholder="name (unique)" required style={{ minWidth: 180 }} />
|
||||
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">New template</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="subject"
|
||||
placeholder="subject"
|
||||
required
|
||||
style={{ flex: 1, minWidth: 220 }}
|
||||
className="flex-1 min-w-[220px]"
|
||||
/>
|
||||
<input name="variables" placeholder="variables (comma-separated)" style={{ minWidth: 200 }} />
|
||||
<label style={{ display: "inline-flex", alignItems: "center", gap: "0.35rem" }}>
|
||||
<input type="checkbox" name="isActive" defaultChecked style={{ width: "auto" }} />
|
||||
<span className="muted">Active</span>
|
||||
<input name="variables" placeholder="variables (comma-separated)" 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>
|
||||
</label>
|
||||
</div>
|
||||
<textarea
|
||||
@@ -55,7 +54,7 @@ export default async function AdminEmailTemplates() {
|
||||
placeholder="Email body (HTML or text)"
|
||||
required
|
||||
rows={5}
|
||||
style={{ width: "100%", resize: "vertical", marginBottom: "0.5rem" }}
|
||||
className="w-full resize-y mb-3"
|
||||
/>
|
||||
<button type="submit" className="btn btn-primary">
|
||||
Create
|
||||
@@ -66,42 +65,32 @@ export default async function AdminEmailTemplates() {
|
||||
{templates.map((t) => {
|
||||
const id = String(t.id);
|
||||
return (
|
||||
<div key={id} className="card">
|
||||
<div key={id} className="admin-card mb-4">
|
||||
<form action={updateEmailTemplate}>
|
||||
<input type="hidden" name="id" value={id} />
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.5rem",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
marginBottom: "0.5rem",
|
||||
}}
|
||||
>
|
||||
<strong style={{ minWidth: 160 }}>{t.name}</strong>
|
||||
<div className="flex gap-2 flex-wrap items-center mb-2">
|
||||
<strong className="min-w-[160px]">{t.name}</strong>
|
||||
<input
|
||||
name="subject"
|
||||
defaultValue={t.subject}
|
||||
placeholder="subject"
|
||||
required
|
||||
style={{ flex: 1, minWidth: 220 }}
|
||||
className="flex-1 min-w-[220px]"
|
||||
/>
|
||||
<input
|
||||
name="variables"
|
||||
defaultValue={t.variables ?? ""}
|
||||
placeholder="variables"
|
||||
style={{ minWidth: 180 }}
|
||||
className="min-w-[180px]"
|
||||
/>
|
||||
<label
|
||||
style={{ display: "inline-flex", alignItems: "center", gap: "0.35rem" }}
|
||||
>
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="isActive"
|
||||
defaultChecked={t.isActive}
|
||||
style={{ width: "auto" }}
|
||||
className="w-auto"
|
||||
/>
|
||||
<span className="muted">Active</span>
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">Active</span>
|
||||
</label>
|
||||
</div>
|
||||
<textarea
|
||||
@@ -109,20 +98,20 @@ export default async function AdminEmailTemplates() {
|
||||
defaultValue={t.body}
|
||||
required
|
||||
rows={6}
|
||||
style={{ width: "100%", resize: "vertical", marginBottom: "0.5rem" }}
|
||||
className="w-full resize-y mb-2"
|
||||
/>
|
||||
<div style={{ display: "flex", gap: "0.5rem", alignItems: "center" }}>
|
||||
<div className="flex gap-2 items-center">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
{t.updatedAt ? (
|
||||
<span className="muted">
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400">
|
||||
Updated {new Date(t.updatedAt).toISOString().slice(0, 16).replace("T", " ")}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
<form action={deleteEmailTemplate} style={{ marginTop: "0.5rem" }}>
|
||||
<form action={deleteEmailTemplate} className="mt-4">
|
||||
<input type="hidden" name="id" value={id} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
Delete
|
||||
@@ -132,7 +121,7 @@ export default async function AdminEmailTemplates() {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{templates.length === 0 ? <p className="muted">No email templates yet.</p> : null}
|
||||
{templates.length === 0 ? <div className="admin-empty">No email templates yet.</div> : null}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user