This commit is contained in:
Ravi Gulhane 2026-11-13 13:54:28 +05:30
commit 43842eaabd
3 changed files with 16 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import {
weekdayOf,
} from './schedule.js';
import { getAppSettings } from './settings.js';
import { toDmy } from './whatsappFormat.js';
import { toCohortSessionDto } from '../utils/serialize.js';
const LIVE_STATUSES = ['confirmed', 'active'];
@ -441,7 +442,8 @@ export async function pushSession(session, reason, { notifyAdmins = false } = {}
const { notifyGroupSessionChange } = await import('./whatsapp.js');
await notifyGroupSessionChange(
cohort._id,
`The ${fromDate} session for ${cohort.name} was ${reason || 'cancelled'}. The next session will be on the next meeting day.`,
// `The ${fromDate} session for ${cohort.name} was ${reason || 'cancelled'}. The next session will be on the next meeting day.`,
`The ${toDmy(fromDate)} session for ${cohort.name} was ${reason || 'cancelled'}. The next session will be on the next meeting day.`,
);
return { cancelled: session, appended: null };
}
@ -508,7 +510,8 @@ export async function shiftApprovedLeaveSessions(prtId, startYmd, endYmd) {
const { notifyGroupSessionChange } = await import('./whatsapp.js');
await notifyGroupSessionChange(
cohort._id,
`The ${fromDate} session for ${cohort.name} was Approved PRT leave. The replacement date is ${toDate}.`,
// `The ${fromDate} session for ${cohort.name} was Approved PRT leave. The replacement date is ${toDate}.`,
`The ${toDmy(fromDate)} session for ${cohort.name} was Approved PRT leave. The replacement date is ${toDmy(toDate)}.`,
);
shifted.push({ cohortId: String(cohort._id), fromDate, toDate });
}

View File

@ -19,6 +19,7 @@ import {
reminderFireAt,
renderTemplate,
templateBody,
toDmy,
toWhatsappDigits,
} from './whatsappFormat.js';
@ -125,7 +126,8 @@ function sessionVars(session, cohort, { name = '' } = {}) {
return {
name: firstName(name),
cohort: cohort.name || '',
date: session.date || '',
// date: session.date || '',
date: toDmy(session.date),
time: session.slot || startTime || '',
meetUrl: session.meetUrl || '',
prtName: personName(prt),

View File

@ -35,9 +35,16 @@ export function groupSubject(cohort) {
return subject.length <= SUBJECT_LIMIT ? subject : subject.slice(0, SUBJECT_LIMIT).trim();
}
// "2026-11-13" to "13-11-2026" for WhatsApp messages.
export function toDmy(ymd) {
const [y, m, d] = String(ymd || '').split('-');
return y && m && d ? `${d}-${m}-${y}` : String(ymd || '');
}
export function groupDescription(cohort, startYmd = '') {
const titled = `${SUBJECT_PREFIX}${String(cohort?.name || '').trim() || 'Cohort'}`;
const parts = [titled, cohort?.slot, cohort?.language, startYmd ? `starts ${startYmd}` : '']
// const parts = [titled, cohort?.slot, cohort?.language, startYmd ? `starts ${startYmd}` : '']
const parts = [titled, cohort?.slot, cohort?.language, startYmd ? `starts ${toDmy(startYmd)}` : '']
.map((part) => String(part || '').trim())
.filter(Boolean);
return parts.join(' · ');