feat: wire location discovery + guide me there #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "7-wire-location-discovery-on-home-page-get"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Home page now fetches nearby McDonald's via GPS and the
GET /locations/nearbyendpoint on mount, so new users see results immediately instead of an empty page. Location detail page gets a "Guide me there" button that opens Google Maps with turn-by-turn directions.Changes
src/routes/home/+page.svelte: AddednearbyLocationsstate,fetchNearby()function that requests GPS and calls/locations/nearby, and a "Nearby McDonald's" section rendered above saved locations. Saved matches link to/locations/{id}with slot progress bars; unsaved locations show name/address/distance inline. GPS denial handled gracefully. Distance converted from meters to miles. "Near Me" button also refreshes nearby discovery.src/routes/locations/[id]/+page.svelte: AddedguideMeThere()function that opens Google Maps directions URL. Button rendered between location header and slot status, only visible when coordinates exist. Uses existingbtn btn-success btn-blockclasses.Test Plan
saved_match-- navigates to/locations/{id}detail pagenpx vite build(verified)npm test(verified)Review Checklist
Related
QA Review -- PR #8
Findings (self-review, fixed in
2dedac7)Division by zero in slot progress (bug, fixed) -- In the nearby discovery section, when
active_codesandavailable_slotsare both 0, the divisionactive_codes / (active_codes + available_slots)producesNaN. Fixed by wrapping the slot display in a{#if total > 0}guard.Missing
noopener,noreferreronwindow.open(security, fixed) --guideMeThere()usedwindow.open(url, '_blank')without the third argument. Added'noopener,noreferrer'to prevent the opened page from accessingwindow.opener.Double GPS prompt possible (minor, not fixed) --
fetchNearby()runs on mount and also when "Near Me" is tapped. If the user taps "Near Me" while the initial GPS prompt is still pending, two concurrent geolocation requests can fire. Cosmetic issue only -- no data corruption risk. Deferred.Verification
npx vite build)npm test)VERDICT: APPROVE