diff --git a/internal/tui/model.go b/internal/tui/model.go index 18d283c..2871d75 100644 --- a/internal/tui/model.go +++ b/internal/tui/model.go @@ -198,7 +198,12 @@ func NewModel(client *api.Client, serverURL string, refreshInterval time.Duratio revokeIn.CharLimit = 20 now := time.Now().UTC() - window := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC) + today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC) + weekday := int(today.Weekday()) + if weekday == 0 { + weekday = 7 // ISO: Sunday = 7 + } + window := today.AddDate(0, 0, -(weekday - 1)) return Model{ client: client, @@ -406,7 +411,7 @@ func buildScheduleDays(window time.Time, entries []api.ScheduleEntry) []schedule for _, e := range entries { entryMap[e.Date] = e } - days := make([]scheduleDay, 14) + days := make([]scheduleDay, 7) for i := range days { date := window.AddDate(0, 0, i) day := scheduleDay{date: date} diff --git a/internal/tui/update.go b/internal/tui/update.go index fa74047..bc2d84b 100644 --- a/internal/tui/update.go +++ b/internal/tui/update.go @@ -271,7 +271,7 @@ func (m Model) handleDashboardKey(msg tea.KeyMsg) (Model, tea.Cmd) { if next == sectionSchedule && len(m.scheduleDays) == 0 { m.scheduleLoading = true from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) return m, fetchScheduleCmd(m.client, from, to) } if next == sectionUsers && len(m.users) == 0 { @@ -287,7 +287,7 @@ func (m Model) handleDashboardKey(msg tea.KeyMsg) (Model, tea.Cmd) { if m.activeSection == sectionSchedule { m.scheduleLoading = true from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) return m, fetchScheduleCmd(m.client, from, to) } if m.activeSection == sectionUsers { @@ -336,7 +336,7 @@ func (m Model) handleDashboardKey(msg tea.KeyMsg) (Model, tea.Cmd) { m.scheduleWindow = m.scheduleWindow.AddDate(0, 0, -7) m.scheduleLoading = true from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) return m, fetchScheduleCmd(m.client, from, to) } return m, nil @@ -346,7 +346,7 @@ func (m Model) handleDashboardKey(msg tea.KeyMsg) (Model, tea.Cmd) { m.scheduleWindow = m.scheduleWindow.AddDate(0, 0, 7) m.scheduleLoading = true from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) return m, fetchScheduleCmd(m.client, from, to) } return m, nil @@ -558,7 +558,7 @@ func (m Model) handleConfirmKey(msg tea.KeyMsg) (Model, tea.Cmd) { m.pendingDeleteEntry = nil m.scheduleLoading = true from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) return m, deleteScheduleEntryCmd(m.client, entry.ID, from, to) case confirmDeleteUser: userID := m.selectedUser.ID @@ -625,7 +625,7 @@ func (m Model) handleUserPickerKey(msg tea.KeyMsg) (Model, tea.Cmd) { dates = []string{d.Format("2006-01-02")} } from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) m.mode = modeDashboard m.scheduleLoading = true return m, assignScheduleCmd(m.client, user.ID, dates, from, to) diff --git a/internal/tui/view.go b/internal/tui/view.go index dff81f0..6d0fa13 100644 --- a/internal/tui/view.go +++ b/internal/tui/view.go @@ -222,7 +222,7 @@ func (m Model) renderSchedule() string { // Window label from := m.scheduleWindow - to := m.scheduleWindow.AddDate(0, 0, 13) + to := m.scheduleWindow.AddDate(0, 0, 6) windowLabel := styleMuted.Render(fmt.Sprintf(" %s — %s", from.Format("Jan 02"), to.Format("Jan 02, 2006")))