diff --git a/public/static/locales/en/treemapperAnalytics.json b/public/static/locales/en/treemapperAnalytics.json index 8d7d41d9ea..bb2d5abd10 100644 --- a/public/static/locales/en/treemapperAnalytics.json +++ b/public/static/locales/en/treemapperAnalytics.json @@ -28,7 +28,7 @@ "dec": "Dec", "exportColumnHeaders": { "hid": "Human Readable ID for a plant location", - "plantDate": "Planted Date", + "interventionStartDate": "Starting date of intervention (e.g. Tree planting date)", "species": "Name of the species planted", "treeCount": "", "geometry": "GeoJson Co-ordinate of the polygon", diff --git a/src/features/common/types/dataExplorer.d.ts b/src/features/common/types/dataExplorer.d.ts index f0e18e9240..96c914f24c 100644 --- a/src/features/common/types/dataExplorer.d.ts +++ b/src/features/common/types/dataExplorer.d.ts @@ -34,7 +34,7 @@ export interface ISpeciesPlanted { export interface IExportData { hid: string; - plant_date: Date; + intervention_start_date: Date; species: string; tree_count: number; geometry: string; diff --git a/src/features/common/types/plantLocation.d.ts b/src/features/common/types/plantLocation.d.ts index 529b50d57b..b82693b0c0 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 dd781f6e19..0c2a2773c2 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 839eb06783..79aa9e1aff 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/Analytics/components/Export/index.tsx b/src/features/user/TreeMapper/Analytics/components/Export/index.tsx index 2d26301cfb..70d5667a95 100644 --- a/src/features/user/TreeMapper/Analytics/components/Export/index.tsx +++ b/src/features/user/TreeMapper/Analytics/components/Export/index.tsx @@ -78,8 +78,8 @@ export const Export = () => { description: t('exportColumnHeaders.hid'), }, { - title: 'plant_date', - description: t('exportColumnHeaders.plantDate'), + title: 'intervention_start_date', + description: t('exportColumnHeaders.interventionStartDate'), }, { title: 'species', @@ -142,6 +142,7 @@ export const Export = () => { }; const extractDataToXlsx = (data: IExportData[]) => { + console.log('Data for export:', data[0]); const worksheet = utils.json_to_sheet(data); const workbook = utils.book_new(); @@ -173,6 +174,7 @@ export const Export = () => { const handleExport = async () => { if (localProject) { const res = await makeRequest(); + console.log('Data received from API:', res?.data[0]); if (res) { const { data } = res; diff --git a/src/features/user/TreeMapper/Import/components/ReviewSubmit.tsx b/src/features/user/TreeMapper/Import/components/ReviewSubmit.tsx index faf556a09f..75b409e6c7 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 80923e7999..2fb213e662 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 3046773f7d..95321d8c87 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')}