Skip to content

fix: dashboard polish — current-week anchor, auto-sync, auto-generate#20

Merged
danieldiazde merged 4 commits into
devfrom
fix/dashboard-autosync-and-autogen
May 9, 2026
Merged

fix: dashboard polish — current-week anchor, auto-sync, auto-generate#20
danieldiazde merged 4 commits into
devfrom
fix/dashboard-autosync-and-autogen

Conversation

@danieldiazde
Copy link
Copy Markdown
Owner

Catch-up PR con 4 commits que no entraron a #19 antes del merge:

  1. Dashboard always shows current week — antes anclaba al insight.semana_iso cacheado. Ahora siempre hoy; insight stale → EmptyInsightCard.
  2. Surface Google Calendar errors/api/calendar/create ahora devuelve el mensaje real de Google (con hint si la API no está habilitada o si falta scope).
  3. Auto-sync Google + Canvas en cada dashboard loadsyncGoogleCalendarToDb y syncCanvasIcalToDb reusables, llamados en server component con Promise.allSettled (errores silenciosos).
  4. Auto-generate insight en EmptyInsightCard — primera carga dispara /api/insights/generate automáticamente. Spinner + título dinámico. Errores inline.

🤖 Generated with Claude Code

danieldiazde and others added 4 commits May 9, 2026 15:34
…rors

Two bugs reported on demo:

1. Dashboard header showed stale week (e.g. "27 de abril al 3 de mayo" while
   today is May 9). Cause: dashboard anchored the week to insight.semana_iso,
   so a cached insight from a previous ISO week dragged the UI back. Fix:
   always anchor to today; if the cached insight is from a different ISO week,
   treat as no-insight and render EmptyInsightCard so the user regenerates.

2. /api/calendar/create returned a generic "No se pudo crear ningún evento"
   that hid the real Google API error. Cause: createEvents only logged errors
   to the server. Fix: return per-event errors with status + message in the
   response. Also adds timeZone: "America/Monterrey" to start/end (Google
   rejects ambiguous datetimes without offset). When the first error is
   401/403 the response includes a "cierra sesión y vuelve a entrar" hint
   so the user can refresh the OAuth token if scope is the issue.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Bump error message truncation from 200 to 500 chars so the full Cloud
  Console URL Google returns isn't cut off mid-word.
- New hint logic: if the response mentions "has not been used" or "disabled"
  we tell the user to enable the API instead of pointing them to re-login.
  The previous re-login hint only made sense for actual auth failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The dashboard reads `eventos` from the DB but nothing was populating that
table on its own — the user had to manually POST to /api/calendar/sync or
/api/canvas/sync to see anything. Now we sync both right before rendering
so a fresh login or page reload shows real events without any extra step.

- lib/google/calendar.ts: extract syncGoogleCalendarToDb(supabase, userId)
  reusable from server components, so the dashboard and the existing route
  share one implementation.
- lib/ical/parser.ts: same — syncCanvasIcalToDb(supabase, userId, icalUrl)
  reads profile.canvas_ical_url and upserts entregas.
- dashboard/page.tsx: autoSyncExternalCalendars() runs both syncs in
  parallel via Promise.allSettled before loadCurrentInsight + loadWeekEventos,
  swallowing per-source errors so a stale cache is preferred over a broken
  dashboard. Skipped in demo mode (?demo=1).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the dashboard lands on EmptyInsightCard the user had to click "Generar
mi semana" to get any blocks. Now the card auto-fires the generation on
first mount (using useRef guard so React strict-mode double-render doesn't
double-trigger). Loading title + spinner reflect the in-flight call. If
generation errors, surface the server's error message inline and switch
the button to "Reintentar" without auto-retrying.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@supabase
Copy link
Copy Markdown

supabase Bot commented May 9, 2026

This pull request has been ignored for the connected project jwqffychkaczvknfgzbd because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@danieldiazde danieldiazde merged commit 73f30e6 into dev May 9, 2026
2 checks passed
@danieldiazde danieldiazde deleted the fix/dashboard-autosync-and-autogen branch May 9, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant