diff --git a/src/features/common/types/plantLocation.d.ts b/src/features/common/types/plantLocation.d.ts index 529b50d57..b82693b0c 100644 --- a/src/features/common/types/plantLocation.d.ts +++ b/src/features/common/types/plantLocation.d.ts @@ -11,7 +11,6 @@ export interface PlantLocationBase { registrationDate: DateString; /** @deprecated */ plantDate: DateString; - interventionDate: DateString; interventionStartDate: DateString | null; //should be the same as interventionDate interventionEndDate: DateString | null; lastMeasurementDate: DateString | null; diff --git a/src/features/projects/components/PlantLocation/PlantLocationDetails.tsx b/src/features/projects/components/PlantLocation/PlantLocationDetails.tsx index dd781f6e1..0c2a2773c 100644 --- a/src/features/projects/components/PlantLocation/PlantLocationDetails.tsx +++ b/src/features/projects/components/PlantLocation/PlantLocationDetails.tsx @@ -207,7 +207,9 @@ export default function PlantLocationDetails({
{t('plantingDate')}
- {formatDate(plantLocation.plantDate)} + {plantLocation.interventionStartDate + ? formatDate(plantLocation.interventionStartDate) + : '-'}
{(plantLocation.type === 'sample-tree-registration' || diff --git a/src/features/projects/components/maps/PlantLocations.tsx b/src/features/projects/components/maps/PlantLocations.tsx index 839eb0678..79aa9e1af 100644 --- a/src/features/projects/components/maps/PlantLocations.tsx +++ b/src/features/projects/components/maps/PlantLocations.tsx @@ -98,8 +98,10 @@ export default function PlantLocations(): ReactElement { }; const getDateDiff = (pl: PlantLocation) => { + if (!pl.interventionStartDate) return null; + const today = new Date(); - const plantationDate = new Date(pl.plantDate?.substr(0, 10)); + const plantationDate = new Date(pl.interventionStartDate?.slice(0, 10)); const differenceInTime = today.getTime() - plantationDate.getTime(); const differenceInDays = differenceInTime / (1000 * 3600 * 24); if (differenceInDays < 1) { diff --git a/src/features/user/TreeMapper/Import/components/ReviewSubmit.tsx b/src/features/user/TreeMapper/Import/components/ReviewSubmit.tsx index faf556a09..75b409e6c 100644 --- a/src/features/user/TreeMapper/Import/components/ReviewSubmit.tsx +++ b/src/features/user/TreeMapper/Import/components/ReviewSubmit.tsx @@ -60,14 +60,16 @@ export default function ReviewSubmit({ {plantLocation.captureMode} -
-
- {tTreemapper('plantDate')} + {plantLocation.interventionStartDate !== null && ( +
+
+ {tTreemapper('plantDate')} +
+
+ {formatDate(plantLocation.interventionStartDate)} +
-
- {formatDate(plantLocation.plantDate)} -
-
+ )}
{tTreemapper('registrationDate')} diff --git a/src/features/user/TreeMapper/components/Map.tsx b/src/features/user/TreeMapper/components/Map.tsx index 80923e799..2fb213e66 100644 --- a/src/features/user/TreeMapper/components/Map.tsx +++ b/src/features/user/TreeMapper/components/Map.tsx @@ -108,24 +108,6 @@ export default function MyTreesMap({ } }; - // const getDateDiff = (pl: PlantLocation) => { - // const today = new Date(); - // const plantationDate = new Date(pl.plantDate?.substr(0, 10)); - // const differenceInTime = today.getTime() - plantationDate.getTime(); - // const differenceInDays = differenceInTime / (1000 * 3600 * 24); - // if (differenceInDays < 1) { - // return t('today'); - // } else if (differenceInDays < 2) { - // return t('yesterday'); - // } else if (differenceInDays < 30) { - // return t('daysAgo', { - // days: localizedAbbreviatedNumber(i18n.language, differenceInDays, 0), - // }); - // } else { - // return null; - // } - // }; - const zoomToLocation = (geometry: turf.AllGeoJSON) => { if (viewport.width && viewport.height && geometry) { const bbox = turf.bbox(geometry); diff --git a/src/features/user/TreeMapper/components/PlantLocationPage.tsx b/src/features/user/TreeMapper/components/PlantLocationPage.tsx index 3046773f7..95321d8c8 100644 --- a/src/features/user/TreeMapper/components/PlantLocationPage.tsx +++ b/src/features/user/TreeMapper/components/PlantLocationPage.tsx @@ -153,10 +153,14 @@ export function LocationDetails({ ) : ( [] )} -
-

{tTreemapper('plantDate')}

-
{formatDate(location.plantDate)}
-
+ {location.interventionStartDate !== null && ( +
+

{tTreemapper('plantDate')}

+
+ {formatDate(location.interventionStartDate)} +
+
+ )}

{tTreemapper('registrationDate')}