Skip to content

feat: integrate Mapbox for enhanced mapping functionality#4

Merged
kaihere14 merged 2 commits into
kaihere14:mainfrom
GURUDAS-DEV:main
Feb 14, 2026
Merged

feat: integrate Mapbox for enhanced mapping functionality#4
kaihere14 merged 2 commits into
kaihere14:mainfrom
GURUDAS-DEV:main

Conversation

@GURUDAS-DEV

@GURUDAS-DEV GURUDAS-DEV commented Feb 14, 2026

Copy link
Copy Markdown
Contributor
  • Added HomeMap component to display a Mapbox map with geolocation features.
  • Updated Home page to render the HomeMap component.
  • Introduced PrivateLayout component for consistent layout structure.
  • Updated TypeScript configuration to include additional type definitions.
  • Added Mapbox GL and related dependencies to package.json and package-lock.json.
  • Created global.d.ts for Mapbox CSS module declaration.

Summary by CodeRabbit

  • New Features
    • Interactive map with navigation controls, geolocation, live air-quality indicators, and onboarding panel.
  • User Experience
    • Streamlined home screen and refined sign-out behavior.
    • Minor UI simplification in the footer.
  • Performance
    • Improved profile image loading using optimized image handling.
  • Chores
    • Added Mapbox support and updated TypeScript typings for the client.
  • Bug Fixes
    • Simplified server error responses for more consistent failure handling.

- Added HomeMap component to display a Mapbox map with geolocation features.
- Updated Home page to render the HomeMap component.
- Introduced PrivateLayout component for consistent layout structure.
- Updated TypeScript configuration to include additional type definitions.
- Added Mapbox GL and related dependencies to package.json and package-lock.json.
- Created global.d.ts for Mapbox CSS module declaration.
@coderabbitai

coderabbitai Bot commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Home now renders a new HomeMap component with Mapbox integration; a PrivateLayout wrapper was added; Mapbox dependency and CSS typings were introduced; ProfileCard now uses Next.js Image; Footer icon import removed; tokenVerify middleware return type and return behavior were made explicit.

Changes

Cohort / File(s) Summary
Mapbox integration
client/components/home/HomeMap.tsx, client/package.json, client/tsconfig.json, client/types/global.d.ts
Adds a new HomeMap component that initializes Mapbox (token check, load, controls, geolocation fly-to, marker, resize handling, overlays and onboarding UI). Adds mapbox-gl dependency, allows importing Mapbox CSS via ambient declaration, and includes **/*.d.ts in tsconfig.
Private route layout & page
client/app/(private)/layout.tsx, client/app/(private)/home/page.tsx
Adds PrivateLayout component and simplifies the private home page to render HomeMap, removing prior inline home UI and logout handler.
UI component tweaks
client/components/landing/Footer.tsx, client/components/profile/ProfileCard.tsx
Removes unused Leaf icon import from Footer; replaces avatar <img> with Next.js Image in ProfileCard.
Middleware typing change
server/src/middleware/tokenVerify.ts
Updates tokenVerify signature to return `Response

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Browser
participant HomeMapComponent as HomeMap
participant MapboxGL as Mapbox
participant GeolocationAPI as Geolocation
Browser->>HomeMap: mount / check NEXT_PUBLIC_MAPBOX_TOKEN
alt token present
HomeMap->>MapboxGL: initialize map instance
MapboxGL-->>HomeMap: load events (load, error)
HomeMap->>GeolocationAPI: request current position
GeolocationAPI-->>HomeMap: position or error
alt position obtained
HomeMap->>MapboxGL: flyTo(position) + add marker
HomeMap->>Browser: show onboarding/search UI
else geolocation failed
HomeMap->>MapboxGL: flyTo(world view fallback)
HomeMap->>Browser: show error message
end
Browser->>HomeMap: user interactions (move, resize)
HomeMap->>MapboxGL: handle movestart/moveend, resize, cleanup on unmount
else token missing
HomeMap->>Browser: render token-missing UI
end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped in code where maps now bloom,
Tokens lit the viewport's room.
A marker winked where users roam,
Private doors guard the cozy home,
I thump in joy — the map feels like home!

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: integration of Mapbox mapping functionality as the primary feature added across the changeset.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
client/components/profile/ProfileCard.tsx (1)

28-33: ⚠️ Potential issue | 🔴 Critical

Next.js Image component is missing required width/height or fill prop — this will error at runtime.

The Next.js Image component requires either explicit width and height props, or the fill prop (with a positioned parent). Without one of these, Next.js throws a runtime error at runtime. Your next.config.ts already has remotePatterns configured for lh3.googleusercontent.com, so external image loading is handled.

🐛 Proposed fix
-              <Image
-                src={user.picture}
-                alt={user.name}
-                className="h-28 w-28 rounded-2xl border-4 border-white object-cover shadow-lg"
-                referrerPolicy="no-referrer"
-              />
+              <Image
+                src={user.picture}
+                alt={user.name}
+                width={112}
+                height={112}
+                className="h-28 w-28 rounded-2xl border-4 border-white object-cover shadow-lg"
+                referrerPolicy="no-referrer"
+              />

Alternatively, wrap the Image in a relatively positioned container and use fill prop.

🤖 Fix all issues with AI agents
In `@client/components/home/HomeMap.tsx`:
- Around line 40-46: The Mapbox map is being initialized with
attributionControl: false (in the mapboxgl.Map call that creates the map
variable), which hides required attribution; change the initialization to either
set attributionControl: true or add a Mapbox attribution control explicitly
(e.g., add map.addControl(new mapboxgl.AttributionControl(...)) or a custom
control that includes the required Mapbox attribution text) so the map always
displays the Mapbox attribution in compliance with Terms of Service.
- Around line 78-104: The geolocation success/error callbacks from
navigator.geolocation.getCurrentPosition may run after the component unmounts
and attempt to call map.flyTo or add a mapboxgl.Marker to a destroyed map; add
an isCancelled (or isMounted) boolean captured by the effect to early-return
from both success and error callbacks, only calling map.flyTo, creating/adding
the marker, or calling setGeoError when isCancelled is false, and in the effect
cleanup set isCancelled = true and also remove the marker if it was created
(store marker in a ref or outer variable so cleanup can call marker.remove());
update uses of getCurrentPosition, map.flyTo, marker, and setGeoError
accordingly.

In `@server/src/middleware/tokenVerify.ts`:
- Around line 20-22: In tokenVerify's catch block remove the raw error from the
JSON response to avoid leaking internals: keep logging the error server-side
(e.g., console.error or processLogger in tokenVerify) but return only a generic
message/status like { errorMsg: "Internal server error" } and appropriate status
500; ensure the change is applied in the tokenVerify middleware catch branch
where res.status(500).json(...) is called so only non-sensitive information is
sent to clients.
🧹 Nitpick comments (2)
client/components/home/HomeMap.tsx (1)

131-309: Large component — consider extracting the static onboarding panel.

The JSX is ~180 lines with two distinct UI regions: a search card (Lines 157–228) and an onboarding panel (Lines 231–305). Extracting the onboarding panel into its own component would improve readability and make each piece independently testable.

client/tsconfig.json (1)

31-32: The **/*.d.ts pattern is redundant.

The existing **/*.ts glob already matches .d.ts files since they end with .ts. Adding **/*.d.ts is harmless but unnecessary.

Comment thread client/components/home/HomeMap.tsx
Comment thread client/components/home/HomeMap.tsx
Comment thread server/src/middleware/tokenVerify.ts Outdated
Comment on lines 20 to 22
} catch (error) {
console.log("Error in tokenVerify:", error);
return res.status(500).json({ errorMsg: "Internal server error", error });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid leaking internal error details in the response.

Line 22 serializes the raw error object into the JSON response. In production, this could expose stack traces, internal paths, or library internals to the client.

Proposed fix
   } catch (error) {
     console.log("Error in tokenVerify:", error);
-    return res.status(500).json({ errorMsg: "Internal server error", error });
+    return res.status(500).json({ errorMsg: "Internal server error" });
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
console.log("Error in tokenVerify:", error);
return res.status(500).json({ errorMsg: "Internal server error", error });
} catch (error) {
console.log("Error in tokenVerify:", error);
return res.status(500).json({ errorMsg: "Internal server error" });
}
🤖 Prompt for AI Agents
In `@server/src/middleware/tokenVerify.ts` around lines 20 - 22, In tokenVerify's
catch block remove the raw error from the JSON response to avoid leaking
internals: keep logging the error server-side (e.g., console.error or
processLogger in tokenVerify) but return only a generic message/status like {
errorMsg: "Internal server error" } and appropriate status 500; ensure the
change is applied in the tokenVerify middleware catch branch where
res.status(500).json(...) is called so only non-sensitive information is sent to
clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants