Journal für abholungen
This commit is contained in:
@@ -21,6 +21,22 @@ function formatDateLabel(dateInput) {
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateOnly(dateInput) {
|
||||
try {
|
||||
const date = new Date(dateInput);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return 'unbekanntes Datum';
|
||||
}
|
||||
return date.toLocaleDateString('de-DE', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric'
|
||||
});
|
||||
} catch (_error) {
|
||||
return 'unbekanntes Datum';
|
||||
}
|
||||
}
|
||||
|
||||
async function sendNtfyNotification(adminNtfy, userNtfy, payload) {
|
||||
if (!adminNtfy?.enabled || !userNtfy?.enabled || !userNtfy.topic) {
|
||||
return;
|
||||
@@ -230,6 +246,34 @@ async function sendDormantPickupWarning({ profileId, storeName, storeId, reasonL
|
||||
});
|
||||
}
|
||||
|
||||
async function sendJournalReminderNotification({
|
||||
profileId,
|
||||
storeName,
|
||||
pickupDate,
|
||||
reminderDate,
|
||||
note
|
||||
}) {
|
||||
if (!profileId) {
|
||||
return;
|
||||
}
|
||||
const adminSettings = adminConfig.readSettings();
|
||||
const userSettings = readNotificationSettings(profileId);
|
||||
const title = `Erinnerung: Abholung bei ${storeName}`;
|
||||
const reminderLabel = formatDateOnly(reminderDate);
|
||||
const pickupLabel = formatDateOnly(pickupDate);
|
||||
const noteLine = note ? `Notiz: ${note}` : null;
|
||||
const messageLines = [
|
||||
`Geplante Abholung: ${pickupLabel}`,
|
||||
`Erinnerungstermin: ${reminderLabel}`,
|
||||
noteLine
|
||||
].filter(Boolean);
|
||||
await sendTelegramNotification(adminSettings.notifications?.telegram, userSettings.notifications?.telegram, {
|
||||
title,
|
||||
message: messageLines.join('\n'),
|
||||
priority: 'default'
|
||||
});
|
||||
}
|
||||
|
||||
async function sendAdminBookingErrorNotification({ profileId, profileEmail, storeName, storeId, pickupDate, error }) {
|
||||
const dateLabel = formatDateLabel(pickupDate);
|
||||
const storeLabel = storeName || storeId || 'Unbekannter Store';
|
||||
@@ -257,5 +301,6 @@ module.exports = {
|
||||
sendTestNotification,
|
||||
sendDesiredWindowMissedNotification,
|
||||
sendDormantPickupWarning,
|
||||
sendJournalReminderNotification,
|
||||
sendAdminBookingErrorNotification
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user