fix(frontend): wire passenger and staff pages to the API/hooks layer - #40
Merged
Merged
Conversation
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.
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.
Summary
lib/api.ts+lib/hooks/useApi.tsimplement "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, andLostItemModaleach hand-rolled their ownsetTimeoutmock simulation instead, so the hooks layer was effectively dead code and the app never actually attempted a request against a configured backend.useCurrentTrip,useTrips,useReportLostItem,useDriverNotificationsApi) so the documented fallback path actually runs, and removed the now-duplicate manual mock/timeout logic.useDriverNotificationsApi:updateNotification's optimisticsetLocalDatabailed out wheneverlocalDatawas stillnull(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.mockDriverNotificationsdeprecated alias inmock-data.tsin favor of the canonicalmockStaffNotificationsit pointed to.Test plan
npx tsc --noEmit— cleannpm run lint— 0 errors, same 3 pre-existing warnings (unchanged)npm test(frontend) — 32 passnpm test(reporting-service) — 27 passnpm run build— succeedsuseReportLostItem, 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