From 00275248fa1f7489239c55c9f3b37e0713eb6d1e Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Fri, 8 Nov 2024 10:58:09 +0530
Subject: [PATCH 01/14] feat: enhance date formatting function to handle string
cleanup and zero-padding
---
src/utils/countryCurrency/getFormattedDate.ts | 39 +++++++++++--------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/utils/countryCurrency/getFormattedDate.ts b/src/utils/countryCurrency/getFormattedDate.ts
index d2c075c990..a0c59bbb27 100644
--- a/src/utils/countryCurrency/getFormattedDate.ts
+++ b/src/utils/countryCurrency/getFormattedDate.ts
@@ -3,23 +3,30 @@ import parseISO from 'date-fns/parseISO';
import { localeMapForDate } from '../language/getLanguageName';
export default function formatDate(date: number | Date | string) {
- if (date) {
- try {
- if (typeof date === 'string') {
- return format(parseISO(date), 'LLLL d, yyyy', {
- locale: localeMapForDate[localStorage.getItem('language') || 'en'],
- });
- }
- else {
- return format(date, 'LLLL d, yyyy', {
- locale: localeMapForDate[localStorage.getItem('language') || 'en'],
- });
- }
- } catch (error) {
- console.log(error);
- return '';
+ if (!date) {
+ return '';
+ }
+
+ try {
+ if (typeof date === 'string') {
+ // Clean up date string
+ const cleanDateString = date.split(' ')[0]; // Remove time portion
+ // Zero-padding month and day if needed
+ const [year, month, day] = cleanDateString.split('-');
+ const isoDateString = `${year}-${month.padStart(2, '0')}-${day.padStart(
+ 2,
+ '0'
+ )}`;
+ return format(parseISO(isoDateString), 'LLLL d, yyyy', {
+ locale: localeMapForDate[localStorage.getItem('language') || 'en'],
+ });
+ } else {
+ return format(date, 'LLLL d, yyyy', {
+ locale: localeMapForDate[localStorage.getItem('language') || 'en'],
+ });
}
- } else {
+ } catch (error) {
+ console.log(error);
return '';
}
}
From afac8f625dae4f8b85d35309f360506317b302ec Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Fri, 8 Nov 2024 10:59:41 +0530
Subject: [PATCH 02/14] feat: simplify conditional rendering in KeyInfo
component for project details
---
.../ProjectDetails/components/KeyInfo.tsx | 162 +++++++++---------
1 file changed, 79 insertions(+), 83 deletions(-)
diff --git a/src/features/projectsV2/ProjectDetails/components/KeyInfo.tsx b/src/features/projectsV2/ProjectDetails/components/KeyInfo.tsx
index 6c1e9b5a85..3c1b90dce9 100644
--- a/src/features/projectsV2/ProjectDetails/components/KeyInfo.tsx
+++ b/src/features/projectsV2/ProjectDetails/components/KeyInfo.tsx
@@ -35,102 +35,98 @@ const KeyInfo = ({
const tProjectDetails = useTranslations('ProjectDetails');
const locale = useLocale();
- const addZeroToDate = (val: string) => {
- const arr = val.split('-');
- const newDateArr = [arr[0]];
- if (arr[1].length === 1) {
- newDateArr.push(`0${arr[1]}`);
- } else {
- newDateArr.push(arr[1]);
- }
- if (arr[2].length === 1) {
- newDateArr.push(`0${arr[2]}`);
- } else {
- newDateArr.push(arr[2]);
- }
- return newDateArr.join('-');
- };
+ const showAbandonmentInfo = abandonment !== null && abandonment > 0;
+ const showProtectionStarted =
+ startingProtectionYear !== null && startingProtectionYear > 0;
+ const showPlantingDensity = plantingDensity !== null && plantingDensity > 0;
+ const showEmployees = employees !== null && employees > 0;
+ const showDegradationYear = degradationYear !== null && degradationYear > 0;
+ const showActivitySeasons =
+ activitySeasons !== null && activitySeasons.length > 0;
+ const showPlantingSeasons =
+ plantingSeasons !== null && plantingSeasons.length > 0;
+ const restorationDate = firstTreePlanted ? formatDate(firstTreePlanted) : '';
return (
-
- {abandonment && (
-
- {tProjectDetails('abandonment')}
-
-
- {tProjectDetails('yearAbandonedInfo')}
-
-
-
- }
- >
-
- {tCommon('approx')} {abandonment}
-
-
- )}
- {firstTreePlanted && (
-
-
-
- )}
- {startingProtectionYear && (
-
-
-
- )}
-
+ {(showAbandonmentInfo ||
+ restorationDate.length > 0 ||
+ showProtectionStarted) && (
+
+ {showAbandonmentInfo && (
+
+ {tProjectDetails('abandonment')}
+
+
+ {tProjectDetails('yearAbandonedInfo')}
+
+
+
+ }
+ >
+
+ {tCommon('approx')} {abandonment}
+
+
+ )}
+ {restorationDate.length > 0 && (
+
+
+
+ )}
+ {showProtectionStarted && (
+
+
+
+ )}
+
+ )}
-
- {plantingDensity && (
-
- <>
- {getFormattedNumber(locale, plantingDensity)}
- {maxPlantingDensity !== null
- ? `-${getFormattedNumber(
- locale,
- maxPlantingDensity
- )} ${tProjectDetails('treePerHa')}`
- : ` ${tProjectDetails('treePerHa')}`}
- >
-
- )}
- {employees && (
-
- {employees}
-
- )}
-
+ {(showPlantingDensity || showEmployees) && (
+
+ {showPlantingDensity && (
+
+ <>
+ {getFormattedNumber(locale, plantingDensity)}
+ {maxPlantingDensity !== null
+ ? `-${getFormattedNumber(
+ locale,
+ maxPlantingDensity
+ )} ${tProjectDetails('treePerHa')}`
+ : ` ${tProjectDetails('treePerHa')}`}
+ >
+
+ )}
+ {showEmployees && (
+
+ {employees}
+
+ )}
+
+ )}
-
- {degradationYear && (
+ {showDegradationYear && (
+
+
+ )}
- {activitySeasons && activitySeasons.length > 0 && (
+ {showActivitySeasons && (
)}
- {plantingSeasons && plantingSeasons.length > 0 && (
+ {showPlantingSeasons && (
From 838dd27263ef4f7350297ec20acbc9b36e7f7d2c Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Fri, 8 Nov 2024 11:18:08 +0530
Subject: [PATCH 03/14] fix: minor alignment correction for site
dropdown/explore buttons
---
.../Layout/ProjectsLayout/ProjectsLayout.module.scss | 2 +-
.../ProjectSiteDropDown/SiteDropdown.module.scss | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/features/common/Layout/ProjectsLayout/ProjectsLayout.module.scss b/src/features/common/Layout/ProjectsLayout/ProjectsLayout.module.scss
index d29b89e84c..be2720c0a2 100644
--- a/src/features/common/Layout/ProjectsLayout/ProjectsLayout.module.scss
+++ b/src/features/common/Layout/ProjectsLayout/ProjectsLayout.module.scss
@@ -49,7 +49,7 @@ $layoutPaddingBottom: 30px;
.mapFeatureExplorerOverlay {
position: absolute;
- top: calc($layoutPaddingTop + 8px);
+ top: calc($layoutPaddingTop + 10px);
right: calc($layoutPaddingSide + 10px);
z-index: 1;
}
diff --git a/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/SiteDropdown.module.scss b/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/SiteDropdown.module.scss
index e01505b4e3..05e9dd760a 100644
--- a/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/SiteDropdown.module.scss
+++ b/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/SiteDropdown.module.scss
@@ -1,5 +1,8 @@
@import '../../../../theme/theme';
+$layoutPaddingTop: 24px;
+$layoutPaddingSide: 20px;
+
.dropdownButton {
display: flex;
border-radius: 12px;
@@ -12,8 +15,8 @@
gap: 18px;
position: absolute;
z-index: 2;
- top: 35px;
- right: 30px;
+ top: calc($layoutPaddingTop + 10px);
+ right: calc($layoutPaddingSide + 10px);
}
.siteIconAndTextContainer {
display: flex;
From faddf5bbfd87514bf1bb15195a71624e188873d9 Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Fri, 8 Nov 2024 15:13:39 +0530
Subject: [PATCH 04/14] fix: allows project details to overflow
---
.../projectsV2/ProjectDetails/ProjectDetails.module.scss | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/features/projectsV2/ProjectDetails/ProjectDetails.module.scss b/src/features/projectsV2/ProjectDetails/ProjectDetails.module.scss
index 7a03e87d4a..e41cbb3982 100644
--- a/src/features/projectsV2/ProjectDetails/ProjectDetails.module.scss
+++ b/src/features/projectsV2/ProjectDetails/ProjectDetails.module.scss
@@ -2,7 +2,8 @@
.projectDetailsContainer {
width: 100%;
- height: 100%;
+ height: calc(100% + 30px);
+ padding-bottom: 30px;
overflow-y: auto;
overflow-x: hidden;
padding-right: 10px;
From 24d0ee36b1743d1fe500a9e50f3fb53f96d84ef9 Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Fri, 8 Nov 2024 17:28:52 +0530
Subject: [PATCH 05/14] fix: ensure map resizes as per container dimensions
---
.../ProjectsMap/MultipleProjectsView.tsx | 17 ++++-------
.../ProjectsMap/ProjectsMap.module.scss | 19 +++++++++++++
.../ProjectsMap/SingleProjectView.tsx | 17 +++++++----
src/features/projectsV2/ProjectsMap/index.tsx | 14 ++++++++--
.../projectsV2/ProjectsMapContext.tsx | 28 +++++++++++++++----
src/utils/mapsV2/zoomToLocation.tsx | 9 +++---
.../mapsV2/zoomToPolygonPlantLocation.tsx | 12 ++++----
src/utils/mapsV2/zoomToProjectSite.ts | 14 +++++-----
8 files changed, 88 insertions(+), 42 deletions(-)
diff --git a/src/features/projectsV2/ProjectsMap/MultipleProjectsView.tsx b/src/features/projectsV2/ProjectsMap/MultipleProjectsView.tsx
index 0984050b18..e282902818 100644
--- a/src/features/projectsV2/ProjectsMap/MultipleProjectsView.tsx
+++ b/src/features/projectsV2/ProjectsMap/MultipleProjectsView.tsx
@@ -1,26 +1,21 @@
import type { CategorizedProjects } from './ProjectMarkers';
-import type { SetState } from '../../common/types/common';
-import type { ViewState } from 'react-map-gl-v7/maplibre';
import type { MapRef } from '../../common/types/projectv2';
import { useEffect, useMemo } from 'react';
import ProjectMarkers from './ProjectMarkers';
import { useProjects } from '../ProjectsContext';
+import { useProjectsMap } from '../ProjectsMapContext'; // Add this import
import { getProjectCategory } from '../../../utils/projectV2';
import { zoomOutMap } from '../../../utils/mapsV2/zoomToProjectSite';
interface MultipleProjectsViewProps {
- setViewState: SetState
;
mapRef: MapRef;
page: 'project-list' | 'project-details';
}
-const MultipleProjectsView = ({
- setViewState,
- mapRef,
- page,
-}: MultipleProjectsViewProps) => {
+const MultipleProjectsView = ({ mapRef, page }: MultipleProjectsViewProps) => {
const { projects, isLoading, isError, filteredProjects } = useProjects();
+ const { handleViewStateChange } = useProjectsMap();
if (isLoading || isError || !projects) {
return null;
}
@@ -34,11 +29,10 @@ const MultipleProjectsView = ({
? mapRef.current.getMap()
: mapRef.current;
zoomOutMap(map, () => {
- setViewState((prevState) => ({
- ...prevState,
+ handleViewStateChange({
...map.getCenter(),
zoom: map.getZoom(),
- }));
+ });
});
}
});
@@ -68,6 +62,7 @@ const MultipleProjectsView = ({
}
);
}, [projects, filteredProjects, isLoading, isError]);
+
return (
);
diff --git a/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss b/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss
index 38ef95c5d6..68597e5e69 100644
--- a/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss
+++ b/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss
@@ -60,6 +60,25 @@
.mapContainer {
width: 100%;
height: 100%;
+ position: relative;
+ overflow: hidden;
+
+ :global {
+ .maplibregl-map {
+ width: 100% !important;
+ height: 100% !important;
+ }
+
+ .maplibregl-canvas-container {
+ width: 100% !important;
+ height: 100% !important;
+
+ canvas {
+ width: 100% !important;
+ height: 100% !important;
+ }
+ }
+ }
}
.android :global(.maplibregl-control-container .maplibregl-ctrl-bottom-right) {
diff --git a/src/features/projectsV2/ProjectsMap/SingleProjectView.tsx b/src/features/projectsV2/ProjectsMap/SingleProjectView.tsx
index 9a2ece1dab..98d07e376f 100644
--- a/src/features/projectsV2/ProjectsMap/SingleProjectView.tsx
+++ b/src/features/projectsV2/ProjectsMap/SingleProjectView.tsx
@@ -21,7 +21,7 @@ const SingleProjectView = ({ mapRef }: Props) => {
useProjects();
if (singleProject === null) return null;
- const { isSatelliteView, setViewState, setIsSatelliteView } =
+ const { isSatelliteView, handleViewStateChange, setIsSatelliteView } =
useProjectsMap();
const router = useRouter();
@@ -48,13 +48,13 @@ const SingleProjectView = ({ mapRef }: Props) => {
zoomToPolygonPlantLocation(
polygonCoordinates,
mapRef,
- setViewState,
+ handleViewStateChange,
4000
);
} else if (isPointLocation) {
const [lon, lat] = coordinates;
if (typeof lon === 'number' && typeof lat === 'number') {
- zoomToLocation(setViewState, lon, lat, 20, 4000, mapRef);
+ zoomToLocation(handleViewStateChange, lon, lat, 20, 4000, mapRef);
}
}
}, [selectedPlantLocation, router.isReady]);
@@ -67,7 +67,7 @@ const SingleProjectView = ({ mapRef }: Props) => {
mapRef,
sitesGeojson,
selectedSite,
- setViewState,
+ handleViewStateChange,
4000
);
} else {
@@ -75,7 +75,14 @@ const SingleProjectView = ({ mapRef }: Props) => {
if (typeof latitude === 'number' && typeof longitude === 'number') {
// Zoom into the project location that has no site
- zoomToLocation(setViewState, longitude, latitude, 10, 4000, mapRef);
+ zoomToLocation(
+ handleViewStateChange,
+ longitude,
+ latitude,
+ 10,
+ 4000,
+ mapRef
+ );
}
}
}, [selectedSite, sitesGeojson, router.isReady, selectedPlantLocation]);
diff --git a/src/features/projectsV2/ProjectsMap/index.tsx b/src/features/projectsV2/ProjectsMap/index.tsx
index 7d7ac9f10b..f75e514760 100644
--- a/src/features/projectsV2/ProjectsMap/index.tsx
+++ b/src/features/projectsV2/ProjectsMap/index.tsx
@@ -1,3 +1,4 @@
+import type { ViewStateChangeEvent } from 'react-map-gl-v7/maplibre';
import type { ViewMode } from '../../common/Layout/ProjectsLayout/MobileProjectsLayout';
import type { SetState } from '../../common/types/common';
import type { PlantLocationSingle } from '../../common/types/plantLocation';
@@ -37,7 +38,8 @@ export type ProjectsMapProps = ProjectsMapMobileProps | ProjectsMapDesktopProps;
function ProjectsMap(props: ProjectsMapProps) {
// const [mobileOS, setMobileOS] = useState(null);
const mapRef: MapRef = useRef(null);
- const { viewState, setViewState, mapState, mapOptions } = useProjectsMap();
+ const { viewState, handleViewStateChange, mapState, mapOptions } =
+ useProjectsMap();
const {
plantLocations,
setHoveredPlantLocation,
@@ -93,6 +95,13 @@ function ProjectsMap(props: ProjectsMapProps) {
mobileOS,
};
+ const onMove = useCallback(
+ (evt: ViewStateChangeEvent) => {
+ handleViewStateChange(evt.viewState);
+ },
+ [handleViewStateChange]
+ );
+
const onMouseMove = useCallback(
(e) => {
if (props.page !== 'project-details') return;
@@ -150,7 +159,6 @@ function ProjectsMap(props: ProjectsMapProps) {
};
const multipleProjectsViewProps = {
mapRef,
- setViewState,
page: props.page,
};
const mapContainerClass = `${styles.mapContainer} ${
@@ -163,7 +171,7 @@ function ProjectsMap(props: ProjectsMapProps) {
{scientificName && (
-
+
{tProjectDetails('scientificName')}
{scientificName}
diff --git a/src/features/projectsV2/ProjectDetails/styles/PlantLocationInfo.module.scss b/src/features/projectsV2/ProjectDetails/styles/PlantLocationInfo.module.scss
index 695d38daa9..d7ef64f5c9 100644
--- a/src/features/projectsV2/ProjectDetails/styles/PlantLocationInfo.module.scss
+++ b/src/features/projectsV2/ProjectDetails/styles/PlantLocationInfo.module.scss
@@ -177,4 +177,8 @@
display: flex;
flex-direction: column;
gap: 12px;
+
+ .scientificName .data {
+ font-style: italic;
+ }
}
From a6ed9e274067382a9d9511e54be883e7221b5562 Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Mon, 11 Nov 2024 13:12:37 +0530
Subject: [PATCH 10/14] fix: show locale formatted values for site area
---
.../ProjectSiteDropDown/ProjectSiteList.tsx | 7 ++++++-
.../ProjectsMap/ProjectSiteDropDown/index.tsx | 13 +++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/ProjectSiteList.tsx b/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/ProjectSiteList.tsx
index 64e00cefa5..500633e98e 100644
--- a/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/ProjectSiteList.tsx
+++ b/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/ProjectSiteList.tsx
@@ -1,3 +1,5 @@
+import { useLocale } from 'next-intl';
+import { getFormattedRoundedNumber } from '../../../../utils/getFormattedNumber';
import type { SetState } from '../../../common/types/common';
import type {
PlantLocation,
@@ -27,6 +29,7 @@ const ProjectSiteList = ({
setSelectedPlantLocation,
setSelectedSamplePlantLocation,
}: ProjectSiteListProps) => {
+ const locale = useLocale();
const handleSiteSelection = (index: number) => {
setSelectedPlantLocation(null);
setSelectedSamplePlantLocation(null);
@@ -46,7 +49,9 @@ const ProjectSiteList = ({
key={index}
>
{site.siteName}
-
{Math.round(site.siteArea)}ha
+
+ {getFormattedRoundedNumber(locale, site.siteArea, 0)} ha
+
);
})}
diff --git a/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/index.tsx b/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/index.tsx
index 533d291465..3f45f911e8 100644
--- a/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/index.tsx
+++ b/src/features/projectsV2/ProjectsMap/ProjectSiteDropDown/index.tsx
@@ -6,7 +6,7 @@ import type {
} from '../../../common/types/plantLocation';
import { useState, useMemo, useCallback } from 'react';
-import { useTranslations } from 'next-intl';
+import { useLocale, useTranslations } from 'next-intl';
import { useRouter } from 'next/router';
import { area } from '@turf/turf';
import SiteIcon from '../../../../../public/assets/images/icons/projectV2/SiteIcon';
@@ -15,6 +15,7 @@ import DropdownUpArrow from '../../../../temp/icons/DropdownUpArrow';
import DropdownDownArrow from '../../../../temp/icons/DropdownDownArrow';
import ProjectSiteList from './ProjectSiteList';
import { truncateString } from '../../../../utils/getTruncatedString';
+import { getFormattedRoundedNumber } from '../../../../utils/getFormattedNumber';
export interface SiteProperties {
lastUpdated: {
@@ -52,6 +53,7 @@ const ProjectSiteDropdown = ({
}: Props) => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const tProjectDetails = useTranslations('ProjectDetails');
+ const locale = useLocale();
const router = useRouter();
const { query } = router;
const siteList = useMemo(() => {
@@ -93,7 +95,14 @@ const ProjectSiteDropdown = ({
})}
•
-
{Math.round(selectedSiteData?.siteArea)} ha
+
+ {getFormattedRoundedNumber(
+ locale,
+ selectedSiteData?.siteArea,
+ 0
+ )}{' '}
+ ha
+
{truncateString(selectedSiteData?.siteName, 40)}
From 2492c34b55ef443a47161ca845e441c9eb40ebb8 Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Mon, 11 Nov 2024 13:33:06 +0530
Subject: [PATCH 11/14] fix: enhance date formatting validation and error
handling
---
src/utils/countryCurrency/getFormattedDate.ts | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/utils/countryCurrency/getFormattedDate.ts b/src/utils/countryCurrency/getFormattedDate.ts
index a0c59bbb27..57c41a63f2 100644
--- a/src/utils/countryCurrency/getFormattedDate.ts
+++ b/src/utils/countryCurrency/getFormattedDate.ts
@@ -11,8 +11,20 @@ export default function formatDate(date: number | Date | string) {
if (typeof date === 'string') {
// Clean up date string
const cleanDateString = date.split(' ')[0]; // Remove time portion
+ if (!cleanDateString.includes('-')) {
+ return '';
+ }
// Zero-padding month and day if needed
const [year, month, day] = cleanDateString.split('-');
+ if (!year || !month || !day) {
+ return '';
+ }
+ // Validate ranges
+ const monthNum = parseInt(month, 10);
+ const dayNum = parseInt(day, 10);
+ if (monthNum < 1 || monthNum > 12 || dayNum < 1 || dayNum > 31) {
+ return '';
+ }
const isoDateString = `${year}-${month.padStart(2, '0')}-${day.padStart(
2,
'0'
@@ -26,7 +38,10 @@ export default function formatDate(date: number | Date | string) {
});
}
} catch (error) {
- console.log(error);
+ console.error('Date formatting failed:', {
+ input: date,
+ error: error instanceof Error ? error.message : String(error),
+ });
return '';
}
}
From 5196518e6baa2fb8ee0be3fc1e77b9fea193419b Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Mon, 11 Nov 2024 14:45:22 +0530
Subject: [PATCH 12/14] feat: format species tree count with locale-specific
number formatting
---
.../components/microComponents/SpeciesPlanted.tsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/features/projectsV2/ProjectDetails/components/microComponents/SpeciesPlanted.tsx b/src/features/projectsV2/ProjectDetails/components/microComponents/SpeciesPlanted.tsx
index 82f0ee9139..ab8e465282 100644
--- a/src/features/projectsV2/ProjectDetails/components/microComponents/SpeciesPlanted.tsx
+++ b/src/features/projectsV2/ProjectDetails/components/microComponents/SpeciesPlanted.tsx
@@ -2,7 +2,8 @@ import type { PlantedSpecies } from '../../../../common/types/plantLocation';
import { useCallback } from 'react';
import styles from '../../styles/PlantLocationInfo.module.scss';
-import { useTranslations } from 'next-intl';
+import { useLocale, useTranslations } from 'next-intl';
+import { getFormattedNumber } from '../../../../../utils/getFormattedNumber';
interface Props {
totalTreesCount: number;
@@ -11,6 +12,7 @@ interface Props {
const SpeciesPlanted = ({ totalTreesCount, plantedSpecies }: Props) => {
const tProjectDetails = useTranslations('ProjectDetails');
+ const locale = useLocale();
const getPlantedTreePercentage = useCallback(
(treeCount: number) => {
const result = (treeCount / totalTreesCount) * 100;
@@ -33,7 +35,7 @@ const SpeciesPlanted = ({ totalTreesCount, plantedSpecies }: Props) => {
{species.scientificName}
-
{species.treeCount}
+
{getFormattedNumber(locale, species.treeCount)}
{`${getPlantedTreePercentage(species.treeCount)}%`}
From 269860844303397de3ac604bb60bcc293d164d6b Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Mon, 11 Nov 2024 14:55:27 +0530
Subject: [PATCH 13/14] fix: adjust mobile bottom positioning for satellite
layer toggle & zoom controls
---
src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss b/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss
index beda0eadfb..d05ac62296 100644
--- a/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss
+++ b/src/features/projectsV2/ProjectsMap/ProjectsMap.module.scss
@@ -50,11 +50,11 @@
}
.layerToggleAndroid {
- bottom: 162px;
+ bottom: 182px;
}
.layerToggleIos {
- bottom: 225px;
+ bottom: 240px;
}
.mapContainer {
@@ -86,7 +86,7 @@
}
.ios :global(.maplibregl-control-container .maplibregl-ctrl-bottom-right) {
- bottom: 130px;
+ bottom: 165px;
}
// Plant Location Styles
From 625587d059dc21ab9f91a69ddd999903c5a06e64 Mon Sep 17 00:00:00 2001
From: mohitb35 <44917347+mohitb35@users.noreply.github.com>
Date: Tue, 12 Nov 2024 13:16:51 +0530
Subject: [PATCH 14/14] fix: ensure planting density is always passed to
PlantingDetails component for multi-tree-registration
---
.../ProjectDetails/components/MultiPlantLocationInfo.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/features/projectsV2/ProjectDetails/components/MultiPlantLocationInfo.tsx b/src/features/projectsV2/ProjectDetails/components/MultiPlantLocationInfo.tsx
index 823422bd98..141f28c004 100644
--- a/src/features/projectsV2/ProjectDetails/components/MultiPlantLocationInfo.tsx
+++ b/src/features/projectsV2/ProjectDetails/components/MultiPlantLocationInfo.tsx
@@ -90,7 +90,7 @@ const MultiPlantLocationInfo = ({
>,
,
isMultiTreeRegistration && plantLocationInfo.plantedSpecies.length > 0 && (