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

SW-6450 Add biomass observation detail view #3637

Merged
merged 4 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
779 changes: 707 additions & 72 deletions src/api/types/generated-schema.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export enum APP_PATHS {
OBSERVATION_DETAILS = '/observations/:plantingSiteId/results/:observationId',
OBSERVATION_PLANTING_ZONE_DETAILS = '/observations/:plantingSiteId/results/:observationId/zone/:plantingZoneId',
OBSERVATION_MONITORING_PLOT_DETAILS = '/observations/:plantingSiteId/results/:observationId/zone/:plantingZoneId/plot/:monitoringPlotId',
OBSERVATION_BIOMASS_MEASSUREMENTS_DETAILS = '/observations/:plantingSiteId/results/:observationId/biomassMeassurements/:monitoringPlotId',
OPT_IN = '/opt-in',
ORGANIZATION_EDIT = '/organization/edit',
ORGANIZATION = '/organization',
Expand Down
5 changes: 4 additions & 1 deletion src/scenes/ObservationsRouter/BiomassMeasurement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { useAppSelector } from 'src/redux/store';
import strings from 'src/strings';
import { PlantingSite } from 'src/types/Tracking';

import BiomassMeasurementRenderer from './BiomassMeasurementRenderer';

export type BiomassMeasurementProps = {
selectedPlantingSite?: PlantingSite;
};
Expand All @@ -35,7 +37,7 @@ export default function BiomassMeasurement({ selectedPlantingSite }: BiomassMeas
const columns = (): TableColumnType[] => {
return [
{
key: 'plotNumber',
key: 'monitoringPlotNumber',
name: strings.PLOT,
type: 'string',
},
Expand Down Expand Up @@ -81,6 +83,7 @@ export default function BiomassMeasurement({ selectedPlantingSite }: BiomassMeas
columns={columns}
rows={adHocObservationsResults || []}
orderBy='startDate'
Renderer={BiomassMeasurementRenderer}
/>
) : (
<EmptyStateContent
Expand Down
47 changes: 47 additions & 0 deletions src/scenes/ObservationsRouter/BiomassMeasurementRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';

import Link from 'src/components/common/Link';
import CellRenderer, { TableRowType } from 'src/components/common/table/TableCellRenderer';
import { RendererProps } from 'src/components/common/table/types';
import { APP_PATHS } from 'src/constants';

export default function BiomassMeasurementRenderer(props: RendererProps<TableRowType>): JSX.Element {
const { column, row, value, index } = props;

const textStyles = {
fontSize: '16px',
'& > p': {
fontSize: '16px',
},
};

const createLinkToPlot = (iValue: React.ReactNode | unknown[]) => {
const biomassPlotUrl = APP_PATHS.OBSERVATION_BIOMASS_MEASSUREMENTS_DETAILS;

const to = biomassPlotUrl
.replace(':monitoringPlotId', row.adHocPlot?.monitoringPlotId?.toString())
.replace(':observationId', row.observationId?.toString())
.replace(':plantingSiteId', row.plantingSiteId?.toString());

return (
<Link fontSize='16px' to={to}>
{iValue as React.ReactNode}
</Link>
);
};

if (column.key === 'monitoringPlotNumber') {
return (
<CellRenderer
index={index}
column={column}
value={createLinkToPlot(row.adHocPlot.monitoringPlotNumber)}
row={row}
sx={textStyles}
title={value as string}
/>
);
}

return <CellRenderer {...props} sx={textStyles} />;
}
Loading