ReviewOS

stacks/wildloop

Saved trails: add UI + wire to SavedTrail endpoints

#969
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

The SavedTrail model exists with API routes, but there's no save/unsave UI (no heart handler on trail cards) and the profile 'Saved Trails' tab is a hardcoded empty state.

Acceptance

  • Save/unsave control on trail cards + detail, wired to SavedTrail endpoints (dedup per user+trail).
  • Profile 'Saved' tab loads the user's saved trails.
9 days ago

Done in 12337206.

  • Save/unsave everywhere: heart overlay on trail cards (doesn't trigger the card link), the trail detail page heart now persists through the API instead of flipping a local boolean, and the profile's Saved tab renders real bookmarks (with inline unsave) instead of the hardcoded empty state — the empty state remains as the genuine zero-bookmarks fallback.
  • Endpoints: POST /trails/{id}/save (auth, idempotent toggle, deduped per user+trail by the #972 unique index — a concurrent double-tap resolves to 'already saved'), GET /users/{id}/saved-trails (public, trail summaries batch-joined). Toggle sits in the 60/min interactive throttle tier (#980) and follows the 422 field-validation contract (#977).
  • Model fix that made it possible: SavedTrail had camelCase attrs + no FK attrs — the same silent ORM write-key trap as #982; bookmarks would have persisted as NULL-keyed rows. Renamed to snake_case and added explicit user_id/trail_id.
  • Optimistic UI with rollback via shared useSavedTrails composable; store hydrates once per session.

Verified by scripts/verify-saved-trails.ts (12 checks). All 11 suites green.

Sign in to comment on this issue.