# Task 09 — Volunteer Check-In

Volunteer marks arrival at the departure point.

## File to create

```
apps/web/src/app/volunteer/vihars/[id]/check-in/page.tsx
```

## Layout

- Title: "Check In"
- Vihar summary (date, route, time)
- Big card: "Capture your location"
  - Initial state: "Get my location" button
  - After geolocation success: green check + lat/lng + accuracy + small map pin
    overlaid on departure point pin (just two dots and a line, no actual map)
  - After geolocation denial: "Couldn't get location" + a checkbox "Continue without GPS"
- Submit button: "Confirm Check-In" — disabled until location captured OR
  "Continue without GPS" is checked

## Behavior

```ts
// Get GPS
navigator.geolocation.getCurrentPosition(
  (pos) => setCoords({ lat: pos.coords.latitude, lng: pos.coords.longitude, acc: pos.coords.accuracy }),
  (err) => setError(err.message),
  { enableHighAccuracy: true, timeout: 15000, maximumAge: 0 }
);
```

On submit, find the volunteer's allocation_id from the vihar (via the parent
page's data, or refetch `GET /api/vihars/{id}`):

```
POST /api/allocations/{allocationId}/check-in
{ latitude, longitude, accuracyMeters, withoutGps: false }
```

Or if no GPS:
```
{ withoutGps: true }
```

On success: navigate back to `/volunteer/vihars/{id}`.

## Acceptance

1. Open from "Check In" button on vihar detail.
2. Tap "Get my location" — browser permission prompt.
3. Allow — see coordinates and accuracy displayed.
4. Tap Confirm — POST fires, navigate back.
5. Detail page shows checked-in state.
6. Test denial: deny permission — error shown, "Continue without GPS" option.
7. Use without GPS — submission succeeds with `withoutGps: true`.

## Gotchas

- iOS Safari is fussy about geolocation. Always test on a real iPhone — it
  often takes 5-10 seconds to resolve, and `maximumAge: 0` forces a fresh fix.
- Don't set `maximumAge` too high — caching old positions defeats the purpose.
- `accuracy` can come back as `0` from some Android browsers — treat 0 as null.
- The button must be disabled while geolocation is loading; show a spinner.

## Out of scope

- Background location tracking — privacy nightmare and not needed
- Photo capture — Phase 2 (offering a photo of the saint at the spot)
- "I'm at the wrong place" detection — Phase 2 (compare GPS to departure pin)
