Restrict ULPIN generation to India using reverse geocoding#7
Restrict ULPIN generation to India using reverse geocoding#7theripper-1920 wants to merge 4 commits intoBitForge95:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the frontend map-based ULPIN flow to only generate ULPINs for locations that reverse-geocode to India, aligning the UI behavior with the intended geographic restriction.
Changes:
- Extend reverse-geocoding results to include
country, and gate ULPIN generation on the resolved country being India. - Update the side-panel UI to show either the generated ULPIN + “Fill Register Form” action (India) or an “India only” informational message (non-India).
- Update
package-lock.jsonto include Leaflet and (as part of lockfile regeneration) bump several other dependencies.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| frontend-ui/src/components/Mapview.jsx | Adds country to reverse geocode output and restricts ULPIN generation/UI to India-only selections. |
| frontend-ui/package-lock.json | Adds Leaflet and includes additional dependency/version churn from lockfile regeneration. |
Files not reviewed (1)
- frontend-ui/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const geo = await reverseGeocode(lat, lng, abortRef.current.signal); | ||
| // Discard if a newer click already superseded this one | ||
| if (thisReq !== reqIdRef.current) return; | ||
| setGeocode(geo); | ||
| setUlpin(generateUlpin(geo, lat, lng)); | ||
| if (geo.country === 'India') { | ||
| setIsIndia(true); | ||
| setUlpin(generateUlpin(geo, lat, lng)); | ||
| } else { | ||
| setIsIndia(false); | ||
| setUlpin(''); | ||
| } |
There was a problem hiding this comment.
The India check relies on an exact string match (geo.country === 'India'). Nominatim's address.country can vary by localization/casing/spacing, which can incorrectly block ULPIN generation for valid Indian locations. Prefer using address.country_code (ISO-3166, typically in) and/or normalizing (trim + case-insensitive) before comparing, and expose that field from reverseGeocode so the check is stable.
| {!loading && geocode && ( | ||
| <div className="card" style={{ padding: '16px 18px' }}> | ||
| <div className="card-title" style={{ marginBottom: 13 }}> | ||
| <span>⊞</span> Generated ULPIN | ||
| </div> | ||
| <div className="card-title" style={{ marginBottom: 13 }}> | ||
| <span>⊞</span> Generated ULPIN | ||
| </div> | ||
|
|
||
| <div style={{ | ||
| background: 'var(--navy-pale)', | ||
| border: '1.5px solid var(--border-active)', | ||
| borderRadius: 5, | ||
| padding: '11px 14px', | ||
| marginBottom: 14, | ||
| }}> | ||
| <span style={{ | ||
| fontFamily: 'var(--font-mono)', | ||
| fontSize: 14, | ||
| fontWeight: 700, | ||
| color: 'var(--navy)', | ||
| letterSpacing: '0.05em', | ||
| {isIndia ? ( | ||
| <> | ||
| <div style={{ | ||
| background: 'var(--navy-pale)', | ||
| border: '1.5px solid var(--border-active)', | ||
| borderRadius: 5, | ||
| padding: '11px 14px', | ||
| marginBottom: 14, | ||
| }}> | ||
| {ulpin} | ||
| </span> | ||
| </div> | ||
|
|
||
| <p style={{ fontSize: 11.5, color: 'var(--text-muted)', lineHeight: 1.6, marginBottom: 14 }}> | ||
| Tap below to open the Register form with ULPIN and GPS pre-filled. | ||
| <span style={{ | ||
| fontFamily: 'var(--font-mono)', | ||
| fontSize: 14, | ||
| fontWeight: 700, | ||
| color: 'var(--navy)', | ||
| letterSpacing: '0.05em', | ||
| }}> | ||
| {ulpin} | ||
| </span> | ||
| </div> | ||
|
|
||
| <p style={{ fontSize: 11.5, color: 'var(--text-muted)', marginBottom: 14 }}> | ||
| Tap below to open the Register form with ULPIN and GPS pre-filled. | ||
| </p> | ||
|
|
||
| <button className="btn btn-primary" style={{ width: '100%' }} onClick={handleFillRegister}> | ||
| Fill Register Form | ||
| </button> | ||
| </> | ||
| ) : ( | ||
| <p style={{ fontSize: 12, color: 'var(--text-muted)' }}> | ||
| ULPIN generation is only available for locations within India. | ||
| </p> |
There was a problem hiding this comment.
This panel is titled "Generated ULPIN" even when the selected location is outside India and no ULPIN is shown. Consider adjusting the title/content conditionally (e.g., show the card only when isIndia is true, or rename the header / add an "India only" label) to avoid misleading UI.
| "license": "MIT" | ||
| }, | ||
| "node_modules/axios": { | ||
| "version": "1.13.6", | ||
| "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.6.tgz", | ||
| "integrity": "sha512-ChTCHMouEe2kn713WHbQGcuYrr6fXTBiu460OTwWrWob16g1bXn4vtz07Ope7ewMozJAnEquLk5lWQWtBig9DQ==", | ||
| "version": "1.14.0", | ||
| "resolved": "https://registry.npmjs.org/axios/-/axios-1.14.0.tgz", | ||
| "integrity": "sha512-3Y8yrqLSwjuzpXuZ0oIYZ/XGgLwUIBU3uLvbcpb0pidD9ctpShJd43KSlEEkVQg6DS0G9NKyzOvBfUtDKEyHvQ==", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "follow-redirects": "^1.15.11", | ||
| "form-data": "^4.0.5", | ||
| "proxy-from-env": "^1.1.0" | ||
| "proxy-from-env": "^2.1.0" | ||
| } |
There was a problem hiding this comment.
The lockfile includes a large set of dependency version bumps (e.g., axios 1.13.6 -> 1.14.0, vite 8.0.0 -> 8.0.3, multiple rolldown bindings) in addition to adding Leaflet. If these upgrades aren't intentional, consider reverting the unrelated lockfile churn to reduce regression risk; otherwise, please call out the dependency upgrades explicitly in the PR (and ideally update package.json constraints if the newer versions are required).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- frontend-ui/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.