feat: wire location discovery + guide me there #8

Merged
forgejo_admin merged 2 commits from 7-wire-location-discovery-on-home-page-get into main 2026-03-17 08:07:23 +00:00
Contributor

Summary

Home page now fetches nearby McDonald's via GPS and the GET /locations/nearby endpoint 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: Added nearbyLocations state, 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: Added guideMeThere() function that opens Google Maps directions URL. Button rendered between location header and slot status, only visible when coordinates exist. Uses existing btn btn-success btn-block classes.

Test Plan

  • Grant GPS permission on home page -- "Nearby McDonald's" section appears with locations sorted by distance
  • Deny GPS permission -- section shows "Location access denied" message, no crash
  • Tap a nearby location with saved_match -- navigates to /locations/{id} detail page
  • Unsaved nearby locations show name, address, and distance inline (no link)
  • On location detail, "Guide me there" button opens Google Maps with correct destination
  • "Near Me" button refreshes the nearby discovery section
  • Search bar filters both nearby discovery and saved locations
  • Build passes: npx vite build (verified)
  • All 41 tests pass: npm test (verified)

Review Checklist

  • Passed automated review-fix loop
  • No secrets committed
  • No unnecessary file changes
  • Commit messages are descriptive
## Summary Home page now fetches nearby McDonald's via GPS and the `GET /locations/nearby` endpoint 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`: Added `nearbyLocations` state, `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`: Added `guideMeThere()` function that opens Google Maps directions URL. Button rendered between location header and slot status, only visible when coordinates exist. Uses existing `btn btn-success btn-block` classes. ## Test Plan - [ ] Grant GPS permission on home page -- "Nearby McDonald's" section appears with locations sorted by distance - [ ] Deny GPS permission -- section shows "Location access denied" message, no crash - [ ] Tap a nearby location with `saved_match` -- navigates to `/locations/{id}` detail page - [ ] Unsaved nearby locations show name, address, and distance inline (no link) - [ ] On location detail, "Guide me there" button opens Google Maps with correct destination - [ ] "Near Me" button refreshes the nearby discovery section - [ ] Search bar filters both nearby discovery and saved locations - [ ] Build passes: `npx vite build` (verified) - [ ] All 41 tests pass: `npm test` (verified) ## Review Checklist - [x] Passed automated review-fix loop - [x] No secrets committed - [x] No unnecessary file changes - [x] Commit messages are descriptive ## Related - Closes #7 - Forgejo issue: forgejo_admin/mcd-tracker-app#7
feat: wire location discovery + "Guide me there" navigation
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
78ac3626f5
Home page now fetches nearby McDonald's via GPS + GET /locations/nearby
on mount. New users see results immediately instead of an empty page.
Location detail gets a "Guide me there" button that opens Google Maps
with turn-by-turn directions.

Closes #7

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fix: guard division-by-zero in slot display + add noopener to window.open
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2dedac72f4
Review-fix loop: wrap nearby slot progress in zero-total guard to
prevent NaN when both active_codes and available_slots are 0. Add
noopener,noreferrer to guideMeThere window.open for security.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Contributor

QA Review -- PR #8

Findings (self-review, fixed in 2dedac7)

  1. Division by zero in slot progress (bug, fixed) -- In the nearby discovery section, when active_codes and available_slots are both 0, the division active_codes / (active_codes + available_slots) produces NaN. Fixed by wrapping the slot display in a {#if total > 0} guard.

  2. Missing noopener,noreferrer on window.open (security, fixed) -- guideMeThere() used window.open(url, '_blank') without the third argument. Added 'noopener,noreferrer' to prevent the opened page from accessing window.opener.

  3. 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

  • Build: passes (npx vite build)
  • Tests: 41/41 pass (npm test)

VERDICT: APPROVE

## QA Review -- PR #8 ### Findings (self-review, fixed in 2dedac7) 1. **Division by zero in slot progress (bug, fixed)** -- In the nearby discovery section, when `active_codes` and `available_slots` are both 0, the division `active_codes / (active_codes + available_slots)` produces `NaN`. Fixed by wrapping the slot display in a `{#if total > 0}` guard. 2. **Missing `noopener,noreferrer` on `window.open` (security, fixed)** -- `guideMeThere()` used `window.open(url, '_blank')` without the third argument. Added `'noopener,noreferrer'` to prevent the opened page from accessing `window.opener`. 3. **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 - Build: passes (`npx vite build`) - Tests: 41/41 pass (`npm test`) **VERDICT: APPROVE**
forgejo_admin deleted branch 7-wire-location-discovery-on-home-page-get 2026-03-17 08:07:23 +00:00
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/mcd-tracker-app!8
No description provided.