diff options
Diffstat (limited to 'internal/handlers/timeline.go')
| -rw-r--r-- | internal/handlers/timeline.go | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go index b923d3e..ce0e831 100644 --- a/internal/handlers/timeline.go +++ b/internal/handlers/timeline.go @@ -8,6 +8,15 @@ import ( "task-dashboard/internal/models" ) +// TimelineData holds grouped timeline items for the template +type TimelineData struct { + TodayItems []models.TimelineItem + TomorrowItems []models.TimelineItem + LaterItems []models.TimelineItem + Start time.Time + Days int +} + // HandleTimeline renders the timeline view func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) { // Parse query params @@ -45,15 +54,21 @@ func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) { return } - data := struct { - Items []models.TimelineItem - Start time.Time - Days int - }{ - Items: items, + // Group items by day section + data := TimelineData{ Start: start, Days: days, } + for _, item := range items { + switch item.DaySection { + case models.DaySectionToday: + data.TodayItems = append(data.TodayItems, item) + case models.DaySectionTomorrow: + data.TomorrowItems = append(data.TomorrowItems, item) + case models.DaySectionLater: + data.LaterItems = append(data.LaterItems, item) + } + } HTMLResponse(w, h.templates, "timeline-tab", data) } |
