Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landing page map component #2025

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Landing page map component #2025

wants to merge 5 commits into from

Conversation

sunilsabatp
Copy link
Contributor

@sunilsabatp sunilsabatp commented Mar 31, 2024

project redesign

  • new design of landing page (visit to /version route)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a ProjectInfo component displaying a list of projects with an interactive map on the landing page.
    • Added a new map component using react-map-gl for dynamic map rendering based on device type and settings.
    • Implemented responsive styling for the map display to ensure full-width visibility and aesthetic integration.
  • Style

    • Added specific styling for the project list container to enhance visual appeal.

Copy link
Contributor

coderabbitai bot commented Mar 31, 2024

Walkthrough

The recent update integrates a new visual feature on the landing page, combining a list of projects with an interactive map. This enhancement aims to boost user engagement by offering a responsive and interactive map display that adjusts to various devices and settings, accompanied by a stylish presentation of project information.

Changes

File Path Change Summary
.../[slug]/version/index.tsx Introduced ProjectInfo component displaying projects list and a map.
.../mapsV2/LandingPageMap.tsx New React component for rendering a dynamic map with react-map-gl.
.../mapsV2/Map.module.scss Added responsive styles for the map container.
.../projectListV2/ProjectList.tsx New component ProjectList for rendering project listings in a styled container.

🐇✨
In the land of code and sun,
A new journey has begun.
Maps and lists, side by side,
In harmony, they now reside.
With every zoom and project glance,
We invite you to join the dance.
🌍💚

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Mar 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
planet-webapp ✅ Ready (Inspect) Visit Preview Apr 2, 2024 11:50am
planet-webapp-multi-tenancy-setup ✅ Ready (Inspect) Visit Preview Apr 2, 2024 11:50am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
planet-webapp-temp ⬜️ Ignored (Inspect) Visit Preview Apr 2, 2024 11:50am

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d76156e and 8d51d9d.
Files ignored due to path filters (1)
  • tsconfig.json is excluded by !**/*.json
Files selected for processing (4)
  • pages/sites/[slug]/version/index.tsx (1 hunks)
  • src/features/projects/components/mapsV2/LandingPageMap.tsx (1 hunks)
  • src/features/projects/components/mapsV2/Map.module.scss (1 hunks)
  • src/features/projects/components/projectListV2/ProjectList.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/features/projects/components/projectListV2/ProjectList.tsx
Additional Context Used
GitHub Check Runs (1)
CodeFactor failure (3)

src/features/projects/components/mapsV2/LandingPageMap.tsx: [warning] 46-46: src/features/projects/components/mapsV2/LandingPageMap.tsx#L46
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)


src/features/projects/components/mapsV2/LandingPageMap.tsx: [warning] 45-45: src/features/projects/components/mapsV2/LandingPageMap.tsx#L45
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)


src/features/projects/components/mapsV2/LandingPageMap.tsx: [notice] 14-14: src/features/projects/components/mapsV2/LandingPageMap.tsx#L14
'setIsMobile' is assigned a value but never used. Allowed unused vars must match /^_/u. (@typescript-eslint/no-unused-vars)

Additional comments not posted (3)
src/features/projects/components/mapsV2/Map.module.scss (1)

1-9: The styling for the .mapContainer class looks good and is responsive, ensuring that the map is displayed in a visually appealing manner on the landing page.

pages/sites/[slug]/version/index.tsx (1)

4-22: The ProjectInfo component integrates the ProjectList and LandingPageMap components effectively. Consider moving the inline styles to a CSS module for better maintainability and consistency with the rest of the project's styling approach.

src/features/projects/components/mapsV2/LandingPageMap.tsx (1)

14-14: The setIsMobile state setter is defined but never used. Is there a plan to implement mobile-specific logic that hasn't been completed yet?

Comment on lines 45 to 46
const _onStateChange = (state: any) => setMapState({ ...state });
const _onViewportChange = (view: any) => setViewPort({ ...view });
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider specifying more precise types instead of any for the parameters of _onStateChange and _onViewportChange functions to improve type safety.

- const _onStateChange = (state: any) => setMapState({ ...state });
- const _onViewportChange = (view: any) => setViewPort({ ...view });
+ const _onStateChange = (state: MapState) => setMapState({ ...state });
+ const _onViewportChange = (view: ViewPort) => setViewPort({ ...view });

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.

Suggested change
const _onStateChange = (state: any) => setMapState({ ...state });
const _onViewportChange = (view: any) => setViewPort({ ...view });
const _onStateChange = (state: MapState) => setMapState({ ...state });
const _onViewportChange = (view: ViewPort) => setViewPort({ ...view });

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8d51d9d and 8508a6b.
Files selected for processing (10)
  • app/cool/layout.tsx (1 hunks)
  • app/cool/page.tsx (1 hunks)
  • next-env.d.ts (1 hunks)
  • pages/sites/[slug]/version/index.tsx (1 hunks)
  • src/features/projects/components/maps/Home.tsx (3 hunks)
  • src/features/projects/components/maps/Markers.tsx (8 hunks)
  • src/features/projects/components/mapsV2/HomePage/Home.tsx (1 hunks)
  • src/features/projects/components/mapsV2/HomePage/microComponent/Markers.tsx (1 hunks)
  • src/features/projects/components/mapsV2/Map.tsx (1 hunks)
  • src/features/projects/components/mapsV2/styles/Map.module.scss (1 hunks)
Files skipped from review due to trivial changes (3)
  • app/cool/layout.tsx
  • next-env.d.ts
  • src/features/projects/components/mapsV2/styles/Map.module.scss
Files skipped from review as they are similar to previous changes (1)
  • pages/sites/[slug]/version/index.tsx
Additional Context Used
GitHub Check Runs (1)
CodeFactor failure (6)

src/features/projects/components/maps/Markers.tsx: [notice] 29-29: src/features/projects/components/maps/Markers.tsx#L29
'setPopupData' is defined but never used. Allowed unused args must match /^_/u. (@typescript-eslint/no-unused-vars)


src/features/projects/components/maps/Markers.tsx: [notice] 30-30: src/features/projects/components/maps/Markers.tsx#L30
'popupData' is defined but never used. Allowed unused args must match /^_/u. (@typescript-eslint/no-unused-vars)


src/features/projects/components/mapsV2/Map.tsx: [warning] 57-57: src/features/projects/components/mapsV2/Map.tsx#L57
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)


src/features/projects/components/mapsV2/Map.tsx: [notice] 17-17: src/features/projects/components/mapsV2/Map.tsx#L17
'PopupData' is defined but never used. Allowed unused vars must match /^_/u. (@typescript-eslint/no-unused-vars)


src/features/projects/components/mapsV2/Map.tsx: [notice] 24-24: src/features/projects/components/mapsV2/Map.tsx#L24
'setIsMobile' is assigned a value but never used. Allowed unused vars must match /^_/u. (@typescript-eslint/no-unused-vars)


src/features/projects/components/mapsV2/Map.tsx: [warning] 56-56: src/features/projects/components/mapsV2/Map.tsx#L56
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)

Additional comments not posted (9)
app/cool/page.tsx (1)

1-8: The DemoPage component is simple and correctly implemented.

Could you clarify the purpose of this component within the application? It seems quite minimal at this stage.

src/features/projects/components/maps/Home.tsx (3)

1-1: Removing the React import and using useEffect directly is a good practice in functional components when you don't need the entire React namespace.


49-59: The introduction of a useEffect hook for setting up the viewport is a clean way to initialize component state based on props. Ensure that dependencies of this effect are correctly managed to avoid unnecessary re-renders.


29-34: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [30-45]

Filtering projects based on their approval status and donation allowance is a clear and concise way to categorize projects. Consider extracting these filtering functions into separate utility functions if they are used in multiple places, to adhere to the DRY principle.

src/features/projects/components/mapsV2/HomePage/Home.tsx (3)

1-1: Using useEffect directly and removing unnecessary imports helps keep the code clean and focused on what's being used.


47-58: The useEffect hook for setting the viewport based on the default map center and zoom level is well-implemented. It's important to ensure that the dependencies of this effect are correctly managed.


30-45: The logic for filtering projects is clear and straightforward. If this logic is reused across different components, consider extracting it into a utility function to avoid code duplication.

src/features/projects/components/maps/Markers.tsx (1)

37-37: The introduction of popupDataX state is a significant change. Ensure that this new state management aligns with the component's intended functionality and that the naming convention (popupDataX) is clear and consistent with the rest of the codebase.

src/features/projects/components/mapsV2/HomePage/microComponent/Markers.tsx (1)

1-181: The Markers micro-component is well-structured and follows similar patterns to the main Markers component. Ensure that the popup data handling and event listeners are optimized for performance, especially for components that might render many markers.

import { useTranslation } from 'next-i18next';
import { useTenant } from '../../../common/Layout/TenantContext';
import Home from './HomePage/Home';
import { PopupData } from '../maps/Markers';
Copy link
Contributor

Choose a reason for hiding this comment

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

The PopupData import is unused in this file. Consider removing it to keep the codebase clean.

- import { PopupData } from '../maps/Markers';

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.

Suggested change
import { PopupData } from '../maps/Markers';

maxZoom: 25,
});

const _onStateChange = (state: any) => setMapState({ ...state });
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of any type for the state change handlers (_onStateChange and _onViewportChange) is not recommended. Specify a more precise type to improve type safety and code readability.

Consider defining an interface for the state and viewport objects.

Also applies to: 57-57

Comment on lines 1 to 5
import { useRouter } from 'next/router';
import React, { ReactElement } from 'react';
import React, { ReactElement, useState } from 'react';
import { Marker, Popup } from 'react-map-gl';
import PopupProject from '../PopupProject';
import styles from '../../styles/ProjectsMap.module.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [29-30]

The setPopupData and popupData props are defined but never used in this component. If these props are no longer needed, consider removing them to clean up the component interface.

-  setPopupData: SetState<PopupData>;
-  popupData: PopupData;

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8508a6b and 3934c0f.
Files selected for processing (3)
  • src/features/projects/components/PopupProject.tsx (1 hunks)
  • src/features/projects/components/mapsV2/Map.tsx (1 hunks)
  • src/features/projects/components/mapsV2/styles/Map.module.scss (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/features/projects/components/PopupProject.tsx
Files skipped from review as they are similar to previous changes (1)
  • src/features/projects/components/mapsV2/styles/Map.module.scss
Additional Context Used
GitHub Check Runs (1)
CodeFactor failure (5)

src/features/projects/components/mapsV2/Map.tsx: [warning] 57-57: src/features/projects/components/mapsV2/Map.tsx#L57
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)


src/features/projects/components/mapsV2/Map.tsx: [notice] 24-24: src/features/projects/components/mapsV2/Map.tsx#L24
'setIsMobile' is assigned a value but never used. Allowed unused vars must match /^_/u. (@typescript-eslint/no-unused-vars)


src/features/projects/components/mapsV2/Map.tsx: [warning] 56-56: src/features/projects/components/mapsV2/Map.tsx#L56
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)

Additional comments not posted (3)
src/features/projects/components/mapsV2/Map.tsx (3)

58-67: The useEffect hook for loading the default map style is well-implemented. However, consider handling potential errors that might arise from the getMapStyle call to improve the robustness of your component.

While the current implementation checks for the result's existence before setting the state, adding error handling could prevent unforeseen issues and improve the user experience in case of failures.


69-90: Fetching all projects within a useEffect hook is a critical operation for this component. The implementation correctly fetches project data based on the tenant configuration and currency. However, the error handling in the catch block could be enhanced.

Currently, the catch block only logs a generic message to the console. Consider providing more detailed error information or implementing a user-facing error state to inform users when project data cannot be loaded.


92-116: The rendering logic for the LandingPageMap component is clear and well-structured. The use of the MapGL component along with the Home and NavigationControl components is appropriate for the intended functionality.

Ensure that the responsive design requirements are met, especially considering the isMobile state's current unused status. Testing across different devices and screen sizes will be crucial to validate the layout and functionality.

const { tenantConfig } = useTenant();
const mapRef = useRef<MapRef>(null);
const { i18n } = useTranslation();
const [isMobile, setIsMobile] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the static analysis hint and the existing comment, it's clear that setIsMobile is defined but never used. This aligns with the previous feedback, suggesting that the detection of mobile devices might not be required for this component.

- const [isMobile, setIsMobile] = useState(false);
+ const [isMobile] = useState(false); // If isMobile is needed

Alternatively, if the isMobile state is not utilized within the component, consider removing it entirely.


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.

Suggested change
const [isMobile, setIsMobile] = useState(false);
const [isMobile] = useState(false); // If isMobile is needed

Comment on lines +55 to +56
const _onStateChange = (state: any) => setMapState({ ...state });
const _onViewportChange = (view: any) => setViewPort({ ...view });
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of any type for the state change handlers (_onStateChange and _onViewportChange) is not recommended due to the lack of type safety. This concern was previously raised and is supported by the static analysis hints.

Consider defining more precise types for these functions to enhance code readability and safety. For example, you could define interfaces for the state and viewport objects based on the properties you expect to manipulate.

Also applies to: 57-57

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

Successfully merging this pull request may close these issues.

3 participants