feat: auto generate placeholder nationalId for users and professors, auto calculate class end date
This commit is contained in:
@@ -9,7 +9,7 @@ const Payment = require('../payments/paymentModel');
|
||||
const AppError = require('../../utils/AppError');
|
||||
const { calculateMeta, escapeRegex, getSearchTerm } = require('../../utils/pagination');
|
||||
const { sendClassRegisteredSms } = require('../../utils/senders/smsMessages');
|
||||
const { buildClassScheduleContext, normalizeWeekdays, normalizeClockTime } = require('../../utils/classSchedule');
|
||||
const { buildClassScheduleContext, normalizeWeekdays, normalizeClockTime, calculateClassEndDate } = require('../../utils/classSchedule');
|
||||
const { resolveNotifyFlags } = require('../../utils/notifyResolver');
|
||||
const { notifyAction } = require('../../utils/actionNotify');
|
||||
const logger = require('../../utils/logger');
|
||||
@@ -18,6 +18,17 @@ const applyScheduleFields = (payload, body) => {
|
||||
if (body.days !== undefined) payload.days = normalizeWeekdays(body.days);
|
||||
if (body.startTime !== undefined) payload.startTime = normalizeClockTime(body.startTime);
|
||||
if (body.endTime !== undefined) payload.endTime = normalizeClockTime(body.endTime);
|
||||
|
||||
const startDate = payload.startDate || body.startDate;
|
||||
const days = payload.days || body.days;
|
||||
const sessions = payload.numberOfSessions || body.numberOfSessions;
|
||||
if (startDate && days?.length && sessions) {
|
||||
const computedEnd = calculateClassEndDate(startDate, days, sessions);
|
||||
if (computedEnd && (!payload.endDate || !body.endDate)) {
|
||||
payload.endDate = computedEnd;
|
||||
}
|
||||
}
|
||||
|
||||
return payload;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user