Skip to content

fix(frontend): wire passenger and staff pages to the API/hooks layer - #40

Merged
github-actions[bot] merged 1 commit into
masterfrom
fix/wire-frontend-to-api-hooks
Aug 30, 2026
Merged

fix(frontend): wire passenger and staff pages to the API/hooks layer#40
github-actions[bot] merged 1 commit into
masterfrom
fix/wire-frontend-to-api-hooks

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

Summary

  • lib/api.ts + lib/hooks/useApi.ts implement "real API call, fall back to mock data" — exactly what CLAUDE.md documents as the frontend/backend integration — but no page ever called them. app/page.tsx, app/staff/page.tsx, and LostItemModal each hand-rolled their own setTimeout mock simulation instead, so the hooks layer was effectively dead code and the app never actually attempted a request against a configured backend.
  • Wired all three to the existing hooks (useCurrentTrip, useTrips, useReportLostItem, useDriverNotificationsApi) so the documented fallback path actually runs, and removed the now-duplicate manual mock/timeout logic.
  • Along the way this surfaced a real, previously-dormant bug in useDriverNotificationsApi: updateNotification's optimistic setLocalData bailed out whenever localData was still null (its initial value — nothing populated it before this hook had a caller), so the first found/not-found response silently no-op'd. Fixed by falling back to the fetched/mock data as the update base.
  • Dropped the now-unreferenced mockDriverNotifications deprecated alias in mock-data.ts in favor of the canonical mockStaffNotifications it pointed to.

Test plan

  • npx tsc --noEmit — clean
  • npm run lint — 0 errors, same 3 pre-existing warnings (unchanged)
  • npm test (frontend) — 32 pass
  • npm test (reporting-service) — 27 pass
  • npm run build — succeeds
  • Manually drove both pages with a headless browser (dev server, no backend running so requests fail over to mock as intended): passenger trip list loads, report-lost flow (category → details → submit → success toast) completes end-to-end via useReportLostItem, staff notification list loads, and the found/not-found response buttons now correctly update the clicked card's status (previously broken before the hook fix, verified before/after).

🤖 Generated with Claude Code

lib/api.ts and lib/hooks/useApi.ts implement exactly the "real API with
mock fallback" behavior CLAUDE.md documents, but no page ever called
them — app/page.tsx, app/staff/page.tsx and LostItemModal each
duplicated their own setTimeout-based mock simulation instead, so the
hooks layer was dead code and the app never attempted a real request.
Wire all three to the existing hooks (useCurrentTrip, useTrips,
useReportLostItem, useDriverNotificationsApi) so the documented
fallback path actually runs.

This also surfaced a latent bug in useDriverNotificationsApi:
updateNotification's optimistic setLocalData bailed out whenever
localData was still null (its initial value, since nothing populated
it before this), silently no-oping the first status update. Fixed by
falling back to the fetched/mock data as the base to update.

Verified via a headless-browser pass of both pages, including the
report-lost and found/not-found flows, with dev talking to the
configured (but unreachable) backend and falling back to mock data as
intended.
@github-actions
github-actions Bot merged commit 86a4b03 into master Aug 30, 2026
1 check passed
@github-actions
github-actions Bot deleted the fix/wire-frontend-to-api-hooks branch August 30, 2026 04:17
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