feat: add employee timing system, notification templates, and professor class plan sms
This commit is contained in:
@@ -61,6 +61,8 @@ const toPublicTemplates = (storedMap, notificationMap = {}) => {
|
||||
return {
|
||||
key: def.key,
|
||||
label: def.label,
|
||||
category: entry.category || def.category || 'اطلاعرسانی',
|
||||
text: entry.text || def.defaultText || '',
|
||||
enabled: isEnabled,
|
||||
templateId: resolveTemplateId(entry, def),
|
||||
availableSlots: (def.slots || []).map((slot) => ({
|
||||
@@ -115,7 +117,7 @@ const getSettings = async () => {
|
||||
const getSmsTemplate = async (key) => {
|
||||
const def = SMS_TEMPLATE_DEFS.find((item) => item.key === key);
|
||||
if (!def) {
|
||||
return { templateId: '', variables: [], enabled: true };
|
||||
return { templateId: '', variables: [], enabled: true, text: '', category: 'اطلاعرسانی' };
|
||||
}
|
||||
const doc = await Setting.findOne({ key: SETTINGS_KEY }).lean();
|
||||
const entry = normalizeStoredEntry(readStoredMap(doc)[key], def);
|
||||
@@ -128,6 +130,8 @@ const getSmsTemplate = async (key) => {
|
||||
return {
|
||||
enabled: isEnabled,
|
||||
templateId: resolveTemplateId(entry, def),
|
||||
category: entry.category || def.category || 'اطلاعرسانی',
|
||||
text: entry.text || def.defaultText || '',
|
||||
variables: resolveVariablesList(def, entry.variables)
|
||||
};
|
||||
};
|
||||
@@ -140,12 +144,14 @@ const getSmsTemplateId = async (key) => {
|
||||
const parseIncomingEntry = (raw) => {
|
||||
if (raw == null) return null;
|
||||
if (typeof raw === 'string' || typeof raw === 'number') {
|
||||
return { templateId: raw, variables: undefined, enabled: undefined };
|
||||
return { templateId: raw, variables: undefined, enabled: undefined, text: undefined, category: undefined };
|
||||
}
|
||||
if (typeof raw !== 'object') return null;
|
||||
return {
|
||||
enabled: raw.enabled !== undefined ? Boolean(raw.enabled) : undefined,
|
||||
templateId: raw.templateId,
|
||||
category: raw.category,
|
||||
text: raw.text,
|
||||
variables: raw.variables
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user