@@ -1,4 +1,4 @@
|
||||
import { Users, GitFork, FolderOpen, BookText, ListCheck, ShieldCheck, Megaphone, Bell, Trophy, Mail } from "lucide-react";
|
||||
import { Users, GitFork, FolderOpen, BookText, ListCheck, ShieldCheck, Megaphone, Bell, Trophy } from "lucide-react";
|
||||
|
||||
export const ADMIN_SECTIONS = [
|
||||
{
|
||||
@@ -41,7 +41,6 @@ export const ADMIN_SECTIONS = [
|
||||
{ key: "advertisements", label: "Advertisements", icon: Megaphone, link: "/admin/advertisements" },
|
||||
{ key: "notifications", label: "Notifications", icon: Bell, link: "/admin/notifications" },
|
||||
{ key: "achievements", label: "Achievements", icon: Trophy, link: "/admin/achievements" },
|
||||
{ key: "email-templates", label: "Email Templates", icon: Mail, link: "/admin/email-templates" },
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -1,10 +0,0 @@
|
||||
export const EMAIL_BROADCAST_STATUSES = [
|
||||
{ value: "queued", label: "Queued", badgeClass: "bg-muted text-muted-foreground border-border" },
|
||||
{ value: "sending", label: "Sending", badgeClass: "bg-blue-100 text-blue-700 border-blue-400 dark:bg-blue-900/40 dark:text-blue-400 dark:border-blue-700" },
|
||||
{ value: "completed", label: "Completed", badgeClass: "bg-emerald-100 text-emerald-700 border-emerald-400 dark:bg-emerald-900/40 dark:text-emerald-400 dark:border-emerald-700" },
|
||||
{ value: "canceled", label: "Canceled", badgeClass: "bg-muted text-muted-foreground border-border" },
|
||||
];
|
||||
|
||||
export const EMAIL_BROADCAST_STATUS_MAP = Object.fromEntries(
|
||||
EMAIL_BROADCAST_STATUSES.map((s) => [s.value, s])
|
||||
);
|
||||
@@ -1,46 +0,0 @@
|
||||
import { Megaphone, BadgePercent, Shield, Tag } from "lucide-react";
|
||||
|
||||
// Purely organizational — lets admins tell at a glance what an email template
|
||||
// is for. Independent of `is_system` (which is about whether the type/row can
|
||||
// be renamed or deleted, not what it's used for).
|
||||
export const EMAIL_TEMPLATE_CATEGORIES = [
|
||||
{
|
||||
value: "announcement",
|
||||
label: "Announcement",
|
||||
description: "Platform news, updates, or broadcast-style messages to users.",
|
||||
icon: Megaphone,
|
||||
badgeClass: "bg-blue-100 text-blue-700 border-blue-400 dark:bg-blue-900/40 dark:text-blue-400 dark:border-blue-700",
|
||||
},
|
||||
{
|
||||
value: "advertisement",
|
||||
label: "Advertisement",
|
||||
description: "Promotional or marketing content (offers, plans, campaigns).",
|
||||
icon: BadgePercent,
|
||||
badgeClass: "bg-amber-100 text-amber-700 border-amber-400 dark:bg-amber-900/40 dark:text-amber-400 dark:border-amber-700",
|
||||
},
|
||||
{
|
||||
value: "system",
|
||||
label: "System",
|
||||
description: "Account and transactional emails triggered by platform events.",
|
||||
icon: Shield,
|
||||
badgeClass: "bg-slate-100 text-slate-700 border-slate-400 dark:bg-slate-800/60 dark:text-slate-300 dark:border-slate-600",
|
||||
},
|
||||
{
|
||||
value: "other",
|
||||
label: "Other",
|
||||
description: "Anything that doesn't fit the categories above.",
|
||||
icon: Tag,
|
||||
badgeClass: "bg-purple-100 text-purple-700 border-purple-400 dark:bg-purple-900/40 dark:text-purple-400 dark:border-purple-700",
|
||||
},
|
||||
];
|
||||
|
||||
export const getEmailTemplateCategory = (value) =>
|
||||
EMAIL_TEMPLATE_CATEGORIES.find((c) => c.value === value) ?? EMAIL_TEMPLATE_CATEGORIES[3];
|
||||
|
||||
// Mirrors BROADCASTABLE_CATEGORIES in controllers/admin/email_broadcasts.controller.js —
|
||||
// only these categories make sense to blast to real recipients. System/transactional
|
||||
// templates are triggered per-user by app events, never mass-sent.
|
||||
export const BROADCASTABLE_CATEGORIES = ["announcement", "advertisement"];
|
||||
|
||||
export const isBroadcastable = (template) =>
|
||||
BROADCASTABLE_CATEGORIES.includes(template?.category) && template?.status === "sent";
|
||||
@@ -1,14 +0,0 @@
|
||||
// Reference-only registry of {{placeholder}} tokens available per system email
|
||||
// type. Purely informational for the admin editor — the backend derives the
|
||||
// real substitution data from wherever sendEmail({ type, data }) is called in
|
||||
// code, this just tells the admin what's actually available to reference.
|
||||
export const EMAIL_TEMPLATE_PLACEHOLDERS = {
|
||||
OTP: ["otp", "expiryMinutes"],
|
||||
WELCOME: ["name"],
|
||||
PASSWORD_CHANGED: [],
|
||||
ADDED_TO_GROUP: ["groupName"],
|
||||
TASK_ASSIGNED: ["taskTitle", "dueDate"],
|
||||
BAN_LIFTED: ["name", "email", "date"],
|
||||
BANNED: ["name", "email", "date", "reason", "duration_word", "duration_label", "suspension_note"],
|
||||
ADD_STAFF: ["name", "email", "password", "expiryHours"],
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
// A template is "sent" once it has live subject/html_body — that's the only
|
||||
// content services/email.service.js's sendEmail() ever reads on the backend.
|
||||
// Editing a sent template writes to draft_subject/draft_html_body instead, so
|
||||
// "pending changes" means there's a draft sitting on top of the live version.
|
||||
export const hasPendingChanges = (t) =>
|
||||
t?.status === "sent" && (t?.draft_subject != null || t?.draft_html_body != null);
|
||||
|
||||
export const STATUS_META = {
|
||||
draft: { label: "Draft", badgeClass: "bg-muted text-muted-foreground border-border" },
|
||||
sent: { label: "Sent", badgeClass: "bg-emerald-100 text-emerald-700 border-emerald-400 dark:bg-emerald-900/40 dark:text-emerald-400 dark:border-emerald-700" },
|
||||
};
|
||||
Reference in New Issue
Block a user