fix: dashboard polish — current-week anchor, auto-sync, auto-generate#20
Merged
Conversation
…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>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Catch-up PR con 4 commits que no entraron a #19 antes del merge:
insight.semana_isocacheado. Ahora siempre hoy; insight stale → EmptyInsightCard./api/calendar/createahora devuelve el mensaje real de Google (con hint si la API no está habilitada o si falta scope).syncGoogleCalendarToDbysyncCanvasIcalToDbreusables, llamados en server component conPromise.allSettled(errores silenciosos)./api/insights/generateautomáticamente. Spinner + título dinámico. Errores inline.🤖 Generated with Claude Code