Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
mudeerapi.abasa.com
/
nodetest-backup30April26
/
src
/
template
/
Filename :
notificationTemplates.js
back
Copy
export const loginNotificationTemplate = (employeeName, employeeRole, department, loginTime) => { const roleDisplay = employeeRole === 'department_head' ? 'Department Head' : 'Employee'; const departmentText = department ? ` from ${department}` : ''; return { title: `${roleDisplay} Login Alert`, body: `${employeeName}${departmentText} has logged in at ${loginTime}`, type: 'login_notification', category: 'login_activity', data: { type: 'login_notification', employeeName: employeeName, employeeRole: employeeRole, department: department || '', loginTime: loginTime, timestamp: new Date().toISOString() } }; }; export const departmentHeadLoginTemplate = (headName, department, loginTime) => { return { title: `Department Head Login Alert`, body: `${headName} (Head of ${department}) has logged in at ${loginTime}`, type: 'login_notification', category: 'login_activity', data: { type: 'department_head_login', headName: headName, department: department, loginTime: loginTime, timestamp: new Date().toISOString() } }; }; export const manualNotificationTemplate = (title, body, senderName, customData = {}) => { return { title, body, type: 'manual_notification', category: 'admin_message', data: { type: 'manual_notification', sender: senderName, customData, timestamp: new Date().toISOString() } }; }; export const systemAlertTemplate = (title, body, alertType = 'info', customData = {}) => { return { title, body, type: 'system_alert', category: 'system', data: { type: 'system_alert', alertType, customData, timestamp: new Date().toISOString() } }; }; export const departmentAnnouncementTemplate = (title, body, department, senderName) => { return { title: `Department Announcement: ${title}`, body, type: 'department_announcement', category: 'department', data: { type: 'department_announcement', department, sender: senderName, originalTitle: title, timestamp: new Date().toISOString() } }; }; export const attendanceAlertTemplate = (employeeName, alertType, details) => { const titles = { 'late_arrival': 'Late Arrival Alert', 'early_departure': 'Early Departure Alert', 'missed_checkin': 'Missed Check-in Alert', 'missed_checkout': 'Missed Check-out Alert' }; return { title: titles[alertType] || 'Attendance Alert', body: `${employeeName}: ${details}`, type: 'attendance_alert', category: 'attendance', data: { type: 'attendance_alert', alertType, employeeName, details, timestamp: new Date().toISOString() } }; }; export const reminderTemplate = (title, body, reminderType, dueDate = null) => { return { title: `Reminder: ${title}`, body, type: 'reminder', category: 'personal', data: { type: 'reminder', reminderType, dueDate, originalTitle: title, timestamp: new Date().toISOString() } }; }; export const hierarchicalLoginTemplate = (userName, userRole, departmentName, loginTime, minutesLate = null) => { const roleDisplay = { 'employee': 'Employee', 'department_head': 'Department Head', 'admin': 'Admin', 'super_admin': 'Super Admin' }[userRole] || 'User'; const departmentText = departmentName ? ` from ${departmentName}` : ''; const lateText = minutesLate != null && minutesLate > 0 ? ` (${minutesLate} minutes late)` : ''; return { title: `${roleDisplay} Login Alert`, body: `${userName}${departmentText} has logged in at ${loginTime}${lateText}`, type: 'login_notification', category: 'login_activity', data: { type: 'login_notification', userName: userName, userRole: userRole, department: departmentName || '', loginTime: loginTime, minutesLate: minutesLate != null ? String(minutesLate) : undefined, timestamp: new Date().toISOString() } }; }; export const checkoutNotificationTemplate = (userName, userRole, departmentName, checkoutTime, workingHoursSeconds) => { const roleDisplay = { 'employee': 'Employee', 'department_head': 'Department Head', 'admin': 'Admin', 'super_admin': 'Super Admin' }[userRole] || 'User'; const departmentText = departmentName ? ` from ${departmentName}` : ''; const hoursDisplay = workingHoursSeconds != null && typeof workingHoursSeconds === 'number' ? (workingHoursSeconds / 3600).toFixed(2) : null; const hoursText = hoursDisplay ? ` (${hoursDisplay} hours worked)` : ''; return { title: `${roleDisplay} Checkout Alert`, body: `${userName}${departmentText} has checked out at ${checkoutTime}${hoursText}`, type: 'checkout_notification', category: 'attendance', data: { type: 'checkout_notification', userName: userName, userRole: userRole, department: departmentName || '', checkoutTime: checkoutTime, workingHours: workingHoursSeconds ?? null, timestamp: new Date().toISOString() } }; }; export const lateArrivalNotificationTemplate = (userName, userRole, departmentName, expectedStartTime, minutesLate) => { const roleDisplay = { 'employee': 'Employee', 'department_head': 'Department Head', 'admin': 'Admin', 'super_admin': 'Super Admin' }[userRole] || 'User'; const departmentText = departmentName ? ` from ${departmentName}` : ''; return { title: `Late Employee`, body: `${userName}${departmentText} has not checked in yet. Expected at ${expectedStartTime}`, type: 'late_notification', category: 'attendance', data: { type: 'late_notification', userName: userName, userRole: userRole, department: departmentName || '', expectedStartTime: expectedStartTime, minutesLate: String(minutesLate), timestamp: new Date().toISOString() } }; }; export const roleChangeNotificationTemplate = (action, oldRole, newRole, departmentName) => { const messages = { 'promoted': `You have been promoted to Department Head of ${departmentName}`, 'demoted': `You have been removed as Department Head of ${departmentName}. You remain an employee.`, 'head_changed': `The department head of ${departmentName} has been changed` }; return { title: 'Role Change', body: messages[action] || 'Your role has been updated', type: 'system_alert', category: 'system', data: { type: 'role_change', action, oldRole, newRole, department: departmentName, timestamp: new Date().toISOString() } }; }; export const leaveRequestSubmittedTemplate = (employeeName, startDate, endDate, leaveType, leaveRequestId) => { return { title: 'New Leave Request', body: `${employeeName} requested ${leaveType} from ${startDate} to ${endDate}`, type: 'leave_request_submitted', category: 'leave_management', data: { type: 'leave_request_submitted', employeeName, startDate, endDate, leaveType, leaveRequestId, timestamp: new Date().toISOString() } }; }; export const leaveRequestApprovedTemplate = (employeeName, startDate, endDate, leaveType, leaveRequestId, approverName) => { return { title: 'Leave Request Accepted', body: `Your ${leaveType} request (${startDate} to ${endDate}) was accepted by ${approverName}`, type: 'leave_request_approved', category: 'leave_management', data: { type: 'leave_request_approved', employeeName, startDate, endDate, leaveType, leaveRequestId, approverName, timestamp: new Date().toISOString() } }; }; export const leaveRequestRejectedTemplate = (employeeName, startDate, endDate, leaveType, leaveRequestId, approverName, rejectionReason) => { return { title: 'Leave Request Rejected', body: `Your ${leaveType} request (${startDate} to ${endDate}) was rejected by ${approverName}`, type: 'leave_request_rejected', category: 'leave_management', data: { type: 'leave_request_rejected', employeeName, startDate, endDate, leaveType, leaveRequestId, approverName, rejectionReason: rejectionReason || '', timestamp: new Date().toISOString() } }; }; export const leaveRequestCancelledTemplate = (employeeName, startDate, endDate, leaveType, leaveRequestId) => { return { title: 'Leave Request Cancelled', body: `${employeeName} cancelled a ${leaveType} request (${startDate} to ${endDate})`, type: 'leave_request_cancelled', category: 'leave_management', data: { type: 'leave_request_cancelled', employeeName, startDate, endDate, leaveType, leaveRequestId, timestamp: new Date().toISOString() } }; }; export const invoiceGeneratedTemplate = (employeeName, monthYear, amount, invoiceId) => { return { title: 'Invoice Generated', body: `Invoice for ${employeeName} – ${monthYear} ($${amount})`, type: 'invoice_generated', category: 'billing', data: { type: 'invoice_generated', employeeName, monthYear, amount, invoiceId, timestamp: new Date().toISOString() } }; }; export const invoiceCommentTemplate = (employeeName, commenterName, monthYear, invoiceId) => { return { title: 'New Comment on Invoice', body: `${commenterName} commented on ${employeeName}'s invoice (${monthYear})`, type: 'invoice_commented', category: 'billing', data: { type: 'invoice_commented', employeeName, commenterName, monthYear, invoiceId, timestamp: new Date().toISOString() } }; }; export const invoicePaidTemplate = (employeeName, monthYear, invoiceId) => { return { title: 'Invoice Marked as Paid', body: `Invoice for ${employeeName} – ${monthYear} has been marked as paid`, type: 'invoice_paid', category: 'billing', data: { type: 'invoice_paid', employeeName, monthYear, invoiceId, timestamp: new Date().toISOString() } }; };