|
1 | 1 | import { Injectable, signal } from '@angular/core'; |
2 | 2 | import { DateTime } from 'luxon'; |
3 | | -import { Observable, map, switchMap, of, from } from 'rxjs'; |
4 | 3 | import { CalendarEvent, CalendarProject, CalendarRecurrenceType } from 'ngx-calendar-view'; |
| 4 | +import { Observable, from, map, of, switchMap } from 'rxjs'; |
5 | 5 |
|
6 | | -import { TaskDto } from '../dto/task-dto'; |
| 6 | +import { CALENDAR_CONFIG } from '../calendar.config'; |
7 | 7 | import { ProjectDto } from '../dto/project-dto'; |
8 | | -import { TaskService } from '../task/task.service'; |
| 8 | +import { TaskDto } from '../dto/task-dto'; |
9 | 9 | import { ProjectService } from '../project/project.service'; |
10 | | -import { CALENDAR_CONFIG } from '../calendar.config'; |
| 10 | +import { TaskService } from '../task/task.service'; |
11 | 11 |
|
12 | 12 | @Injectable({ |
13 | 13 | providedIn: 'root' |
@@ -47,19 +47,25 @@ export class CalendarService { |
47 | 47 | return tasks |
48 | 48 | .filter(task => !task.completed && task.dueDate) // Only incomplete tasks with dates |
49 | 49 | .map(task => { |
| 50 | + const eventDate = DateTime.fromJSDate(task.dueDate!); |
50 | 51 | const calendarEvent: CalendarEvent = { |
51 | 52 | id: task.uuid, |
52 | 53 | title: task.title, |
53 | 54 | description: task.description || undefined, |
54 | | - date: DateTime.fromJSDate(task.dueDate!), |
| 55 | + date: eventDate, |
55 | 56 | duration: CALENDAR_CONFIG.defaultDuration, |
56 | 57 | project: this.getProjectName(task), |
57 | 58 | recurrenceType: this.mapRecurrenceType(task.recurring) |
58 | 59 | }; |
59 | 60 |
|
60 | 61 | // Set time if available, otherwise it's an all-day event |
61 | 62 | if (task.dueTime) { |
62 | | - calendarEvent.time = DateTime.fromJSDate(task.dueTime); |
| 63 | + const eventTime = DateTime.fromJSDate(task.dueTime); |
| 64 | + calendarEvent.time = eventTime.set({ |
| 65 | + year: eventDate.year, |
| 66 | + month: eventDate.month, |
| 67 | + day: eventDate.day, |
| 68 | + }); |
63 | 69 | } |
64 | 70 |
|
65 | 71 | return calendarEvent; |
|
0 commit comments