diff --git a/backend/app/routers/dashboard.py b/backend/app/routers/dashboard.py index 1a0a74e..45a6773 100644 --- a/backend/app/routers/dashboard.py +++ b/backend/app/routers/dashboard.py @@ -156,26 +156,27 @@ async def get_dashboard( async def get_upcoming( days: int = Query(default=7, ge=1, le=90), client_date: Optional[date] = Query(None, ge=date(2020, 1, 1), le=date(2099, 12, 31)), - include_past: bool = Query(default=True), db: AsyncSession = Depends(get_db), current_user: User = Depends(get_current_user), current_settings: Settings = Depends(get_current_settings), ): """Get unified list of upcoming items (todos, events, reminders) sorted by date.""" today = client_date or date.today() - now = datetime.now() cutoff_date = today + timedelta(days=days) cutoff_datetime = datetime.combine(cutoff_date, datetime.max.time()) today_start = datetime.combine(today, datetime.min.time()) + overdue_floor = today - timedelta(days=30) + overdue_floor_dt = datetime.combine(overdue_floor, datetime.min.time()) # Subquery: calendar IDs belonging to this user user_calendar_ids = select(Calendar.id).where(Calendar.user_id == current_user.id) - # Build queries — include overdue todos and snoozed reminders + # Build queries — include overdue todos (up to 30 days back) and snoozed reminders todos_query = select(Todo).where( Todo.user_id == current_user.id, Todo.completed == False, Todo.due_date.isnot(None), + Todo.due_date >= overdue_floor, Todo.due_date <= cutoff_date ) @@ -190,6 +191,7 @@ async def get_upcoming( Reminder.user_id == current_user.id, Reminder.is_active == True, Reminder.is_dismissed == False, + Reminder.remind_at >= overdue_floor_dt, Reminder.remind_at <= cutoff_datetime ) @@ -220,11 +222,6 @@ async def get_upcoming( for event in events: end_dt = event.end_datetime - # When include_past=False, filter out past events - if not include_past and end_dt: - if end_dt < now: - continue - upcoming_items.append({ "type": "event", "id": event.id, diff --git a/frontend/src/components/dashboard/UpcomingWidget.tsx b/frontend/src/components/dashboard/UpcomingWidget.tsx index 1a9ad86..56991be 100644 --- a/frontend/src/components/dashboard/UpcomingWidget.tsx +++ b/frontend/src/components/dashboard/UpcomingWidget.tsx @@ -35,7 +35,7 @@ const typeConfig: Record toast.error('Failed to complete todo'), }); // Snooze reminder @@ -87,6 +88,7 @@ export default function UpcomingWidget({ items }: UpcomingWidgetProps) { queryClient.invalidateQueries({ queryKey: ['upcoming'] }); toast.success('Reminder snoozed'); }, + onError: () => toast.error('Failed to snooze reminder'), }); // Dismiss reminder @@ -97,6 +99,7 @@ export default function UpcomingWidget({ items }: UpcomingWidgetProps) { queryClient.invalidateQueries({ queryKey: ['dashboard'] }); toast.success('Reminder dismissed'); }, + onError: () => toast.error('Failed to dismiss reminder'), }); // Filter and group items @@ -325,7 +328,7 @@ export default function UpcomingWidget({ items }: UpcomingWidgetProps) { {snoozeOpen === itemKey && ( -
+