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

Hotfix/map zoom out #2352

Open
wants to merge 7 commits into
base: hotfix/plantlocation-render-issue
Choose a base branch
from
Prev Previous commit
Next Next commit
refactor: refactor satellite view logic in useEffect
- simplified the logic for setting satellite view based on `singleProject.purpose` and `plantLocations`.
- consolidated conditions to set `isSatelliteView` directly based on project purpose and plant location availability.
sunilsabatp committed Jan 14, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 340019afec5b02f3671506e60d6df191f1c62bdc
17 changes: 7 additions & 10 deletions src/features/projectsV2/ProjectsMap/SingleProjectView.tsx
Original file line number Diff line number Diff line change
@@ -108,15 +108,12 @@ const SingleProjectView = ({ mapRef }: Props) => {
]);

useEffect(() => {
if (plantLocations === null) return;
const hasNoPlantLocations = !plantLocations?.length;
const isSingleProjectLocation = hasNoPlantLocations && hasNoSites;
// Satellite view will be:
// - false if there are no plant locations and no sites (i.e., a single project location only)
// - true if there are no plant locations but there are multiple sites
setIsSatelliteView(!isSingleProjectLocation && hasNoPlantLocations);
}, [plantLocations, hasNoSites]);

setIsSatelliteView(
singleProject.purpose === 'conservation' ||
(singleProject.purpose === 'trees' &&
(!plantLocations || plantLocations.length === 0))
);
}, [plantLocations, singleProject.purpose]);
return (
<>
{hasNoSites ? (
@@ -131,7 +128,7 @@ const SingleProjectView = ({ mapRef }: Props) => {
isSatelliteView={isSatelliteView}
geoJson={sitesGeojson}
/>
{isSatelliteView && plantLocations !== null && <SatelliteLayer />}
{isSatelliteView && <SatelliteLayer />}
</>
)}