-
Notifications
You must be signed in to change notification settings - Fork 4
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
Added a conditional dendering for the regionMap #141
Conversation
WalkthroughThe code changes involve enhancing the Changes
Assessment against linked issues
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? TipsChat with CodeRabbit Bot (
|
Apply Sweep Rules to your PR?
Type can be one of the following:
|
@OhmSpectator you mentioned that there was a lint script I have to run, where can I find it both frontend and backend are missing it. PS D:\track-your-regions\frontend> npm run lint
npm ERR! Missing script: "lint" |
@pbelokon, the script can be run from the frontend or backend directory with this command: npm run lint I've also updated the CONTRIBUTING.md file: |
@OhmSpectator Rebased it and did changes on the new files, sorry about that |
@OhmSpectator I think there is a mistake in the front-end it says that we should run since in the project we use the below: "lint": "eslint --ext .js,.jsx src",
"lint:fix": "eslint --fix --ext .js,.jsx src" |
Yep, that's true! I will fix it! Thanks for the catch! |
b070ed9
to
c0bc4d9
Compare
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: .coderabbit.yaml
Files selected for processing (1)
- frontend/src/components/RegionMap.jsx (3 hunks)
Additional comments: 5
frontend/src/components/RegionMap.jsx (5)
4-4: The import of the
Button
component is correctly added to support the new UI functionality.15-25: The modification to
fetchSelectedRegionGeometry
to include aforce
parameter aligns with the PR's goal to fetch geometry data when necessary.124-127: The new
handleForceGeometryFetch
function is implemented to trigger a forced fetch of geometry data and reinitialize the map, which is in line with the PR objectives.124-127: The sequence of calling
fetchSelectedRegionGeometry(true)
followed byinitializeMap()
inhandleForceGeometryFetch
is correct for the intended functionality of reinitializing the map with new geometry data.121-122: The
useEffect
hook is correctly used to initialize the map and provide a cleanup function to remove the map when the component unmounts or dependencies change.
{!fetchSelectedRegionGeometry() && ( | ||
<Button onClick={handleForceGeometryFetch}>Fetch Geometry</Button> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like humans are talking. I'll be quiet for now. If you need me again, just tag @coderabbitai in a new comment.
@pbelokon, I've prepared a prepopulated DB image. You can try to get it for full-setup testing. |
{!fetchSelectedRegionGeometry() && ( | ||
<Button onClick={handleForceGeometryFetch}>Fetch Geometry</Button> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like humans are talking. I'll be quiet for now. If you need me again, just tag @coderabbitai in a new comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbelokon, I would also be happy to see that the commit messages are following the template:
front: <Topic>.
<Description>
[Issue: #<GitHub Issue Number>]
It put this into doc: https://github.com/OhmSpectator/track-your-regions/blob/main/frontend/CONTRIBUTING.md
c0bc4d9
to
35f29e6
Compare
@pbelokon I've rebased the branch on top of main. So, be careful when starting working on it again: do not forget to pull the latest version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: .coderabbit.yaml
Files selected for processing (1)
- frontend/src/components/RegionMap.jsx (3 hunks)
Additional comments: 3
frontend/src/components/RegionMap.jsx (3)
4-4: The addition of the
Button
import from@mui/material
aligns with the PR objectives to enhance the UI for handling regions without geometry data.23-33: The modification of
fetchSelectedRegionGeometry
to include aforce
parameter is consistent with the PR objectives. Ensure that all calls to this function have been updated to pass this parameter when needed.#!/bin/bash # Search for calls to `fetchSelectedRegionGeometry` without the `force` parameter. ast-grep --lang javascript --pattern $'fetchSelectedRegionGeometry($_)'
- 132-134: The
handleForceGeometryFetch
function correctly callsfetchSelectedRegionGeometry
withforce
set totrue
, and then initializes the map. This aligns with the PR objectives to allow users to fetch and visualize geometry data for regions without it.
@pbelokon, I've just realized that the instructions and the scripts to create/deploy the DB are Unix-specific and unsuitable for Windows... I'll try to fix it. |
f48531f
to
6ad9de2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: .coderabbit.yaml
Files selected for processing (1)
- frontend/src/components/RegionMap.jsx (3 hunks)
Additional comments: 3
frontend/src/components/RegionMap.jsx (3)
4-4: Import of
Button
from@mui/material
is correctly added to support the new UI feature.23-33: The addition of the
force
parameter tofetchSelectedRegionGeometry
is correctly implemented to bypass the cache when needed.132-135: The
handleForceGeometryFetch
function correctly forces a geometry fetch and reinitializes the map. Ensure that the state is properly updated to reflect the new geometry data.
{!fetchSelectedRegionGeometry() && ( | ||
<Button onClick={handleForceGeometryFetch}>Fetch Geometry</Button> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional rendering logic for the "Fetch Geometry" button is incorrect as it relies on the return value of an async function. This should be based on a state variable that holds the result of fetchSelectedRegionGeometry()
.
- {!fetchSelectedRegionGeometry() && (
+ {!regionGeometry && (
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.
{!fetchSelectedRegionGeometry() && ( | |
<Button onClick={handleForceGeometryFetch}>Fetch Geometry</Button> | |
)} | |
{!regionGeometry && ( | |
<Button onClick={handleForceGeometryFetch}>Fetch Geometry</Button> | |
)} |
👋 Hey there! Just noticed this PR has been quiet for a week. We miss your updates! If there is no activity in the next week, we will need to close it for housekeeping. 😊🧹 |
👋 Hey there! Just noticed this PR has been quiet for a week. We miss your updates! If there is no activity in the next week, we will need to close it for housekeeping. 😊🧹 |
🚪 We are doing a little housekeeping and noticed this PR has been quiet for a while. We are going to close it for now. If you are ready to pick this up again, please feel free to open a new PR or reach out to us, and we will be happy to help you reopen this one! 😄👍 |
Description
Added a conditional rendering for RegionMap based on if the region has geometry data, added a button that calls getGeometry with farce set to true when there is not geometry data.
Related Issues
Closes: #51
How Was This Tested?
This will be tested by loading regions with no geometry data to see if the button appearance. Currently my db works incorrect so I will test this one I figure that out.
Checklist
Before submitting your PR, please review the following:
Additional Comments (if any):
Summary by CodeRabbit
New Features
Enhancements
Style