Notifications corrections
This commit is contained in:
parent
37d1089be5
commit
5ac295f3b7
@ -168,7 +168,9 @@ export function Duties() {
|
||||
}
|
||||
|
||||
// Use local date comparison to avoid timezone issues
|
||||
const taskDueDate = new Date(dueDate);
|
||||
// Leantime dates with 'Z' are actually local time, not UTC - remove Z before parsing
|
||||
const dateStrForParsing = dueDate.endsWith('Z') ? dueDate.slice(0, -1) : dueDate;
|
||||
const taskDueDate = new Date(dateStrForParsing);
|
||||
const taskYear = taskDueDate.getFullYear();
|
||||
const taskMonth = taskDueDate.getMonth();
|
||||
const taskDay = taskDueDate.getDate();
|
||||
|
||||
@ -92,11 +92,46 @@ export function useTaskNotifications() {
|
||||
}
|
||||
|
||||
// For both Leantime and Twenty CRM tasks: notification at due date time (dateToFinish)
|
||||
// Note: Twenty CRM doesn't have a separate start date field, so we use dueAt for notifications
|
||||
// Note: Leantime dates might be in MySQL format (YYYY-MM-DD HH:MM:SS) without timezone
|
||||
// We need to parse them correctly to avoid timezone issues
|
||||
let notificationDate: Date | null = null;
|
||||
|
||||
if (task.dateToFinish) {
|
||||
notificationDate = new Date(task.dateToFinish);
|
||||
const dateStr = task.dateToFinish;
|
||||
|
||||
console.log('[useTaskNotifications] 📅 Parsing date', {
|
||||
id: task.id,
|
||||
title: task.headline,
|
||||
source: task.source,
|
||||
rawDate: dateStr,
|
||||
dateFormat: dateStr.includes('T') ? 'ISO' : dateStr.includes(' ') ? 'MySQL' : 'unknown',
|
||||
});
|
||||
|
||||
// Leantime dates are often in format with 'Z' (UTC marker) but actually represent local time
|
||||
// We need to parse them correctly. If it ends with Z, remove it and treat as local time
|
||||
if (dateStr.endsWith('Z')) {
|
||||
// Remove Z and parse as local time (Leantime dates with Z are actually local time, not UTC)
|
||||
const withoutZ = dateStr.slice(0, -1);
|
||||
notificationDate = new Date(withoutZ);
|
||||
} else if (dateStr.includes('T')) {
|
||||
// ISO format without Z - treat as local time
|
||||
notificationDate = new Date(dateStr);
|
||||
} else if (dateStr.includes(' ')) {
|
||||
// MySQL format: "YYYY-MM-DD HH:MM:SS" - parse as local time
|
||||
const isoLike = dateStr.replace(' ', 'T');
|
||||
notificationDate = new Date(isoLike);
|
||||
} else {
|
||||
// Try direct parsing
|
||||
notificationDate = new Date(dateStr);
|
||||
}
|
||||
|
||||
console.log('[useTaskNotifications] 📅 Parsed date', {
|
||||
id: task.id,
|
||||
rawDate: dateStr,
|
||||
parsedDate: notificationDate.toISOString(),
|
||||
localDate: notificationDate.toLocaleString('fr-FR'),
|
||||
isValid: !isNaN(notificationDate.getTime()),
|
||||
});
|
||||
}
|
||||
|
||||
if (!notificationDate || isNaN(notificationDate.getTime())) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user