Skip to content

Commit 5bb8b5b

Browse files
CopilotAlexLipp
andcommitted
Fix downstream impact popup: waves, tab rename, subtitle format, CSO list display
Co-authored-by: AlexLipp <10188895+AlexLipp@users.noreply.github.com> Agent-Logs-Url: https://github.com/JonnyDawe/UK-Sewage-Map/sessions/59a4f9c7-7284-475f-a1e9-1da56b041281
1 parent 7326258 commit 5bb8b5b

3 files changed

Lines changed: 42 additions & 24 deletions

File tree

src/components/DownstreamImpactPopup/DownstreamImpactPopupBody.tsx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { DownstreamImpactProperties } from './types';
1010
const BodyWrapper = styled.div`
1111
position: relative;
1212
overflow: hidden;
13-
max-width: 280px;
1413
`;
1514

1615
const BackgroundWave = styled(Wave)`
@@ -56,16 +55,6 @@ const StatRow = styled.div`
5655
gap: 8px;
5756
`;
5857

59-
const CsoList = styled.ul`
60-
margin: 4px 0 0;
61-
padding-left: 16px;
62-
list-style-type: disc;
63-
`;
64-
65-
const CsoListItem = styled.li`
66-
font-size: var(--font-size-2);
67-
`;
68-
6958
type DownstreamImpactPopupBodyProps = DownstreamImpactProperties;
7059

7160
export function DownstreamImpactPopupBody({
@@ -77,6 +66,16 @@ export function DownstreamImpactPopupBody({
7766

7867
return (
7968
<BodyWrapper>
69+
<BackgroundWave
70+
fill="var(--wave-brown)"
71+
paused={prefersReducedMotion}
72+
options={{
73+
height: 30,
74+
amplitude: 20,
75+
speed: 0.1,
76+
points: 6,
77+
}}
78+
/>
8079
<BackgroundWave
8180
fill="var(--wave-blue)"
8281
paused={prefersReducedMotion}
@@ -91,7 +90,7 @@ export function DownstreamImpactPopupBody({
9190
<Tabs.Root defaultValue="summary" aria-label="Choose which information to see:">
9291
<Tabs.List>
9392
<Tabs.Trigger value="summary">Summary</Tabs.Trigger>
94-
<Tabs.Trigger value="sources">Upstream Sources</Tabs.Trigger>
93+
<Tabs.Trigger value="spills">Upstream Spills</Tabs.Trigger>
9594
</Tabs.List>
9695
<Box pt={'3'}>
9796
<Tabs.Content value="summary">
@@ -117,21 +116,23 @@ export function DownstreamImpactPopupBody({
117116
</Text>
118117
</DataCardWrapper>
119118
</Tabs.Content>
120-
<Tabs.Content value="sources">
119+
<Tabs.Content value="spills">
121120
<DataCardWrapper>
122121
<ScrollArea type="auto" scrollbars="vertical" style={{ maxHeight: 160 }}>
123122
{CSOs.length > 0 ? (
124-
<CsoList>
125-
{CSOs.map((name, index) => (
126-
<CsoListItem key={`${index}-${name}`}>{name}</CsoListItem>
127-
))}
128-
</CsoList>
123+
<Text size="2" as="p">
124+
{CSOs.join(', ')}
125+
</Text>
129126
) : (
130-
<Text size="2" color="gray">
131-
No upstream sources recorded.
127+
<Text size="2" color="gray" as="p">
128+
No upstream spills recorded.
132129
</Text>
133130
)}
134131
</ScrollArea>
132+
<Text size="1" color="gray" mt="2" as="p">
133+
These are the names/permits of CSOs upstream of this point that have spilled in
134+
the last 48 hours.
135+
</Text>
135136
</DataCardWrapper>
136137
</Tabs.Content>
137138
</Box>

src/components/DownstreamImpactPopup/DownstreamImpactPopupHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function DownstreamImpactPopupHeader({
2424
</Heading>
2525
<Text size={'2'}>
2626
<Em>
27-
Downstream Impact - [{lon}, {lat}]
27+
Downstream Impact at ({lat}, {lon})
2828
</Em>
2929
</Text>
3030
</div>

src/components/DownstreamImpactPopup/popupfactory.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,28 @@ function getPropertiesFromGraphic(graphic: __esri.Graphic): DownstreamImpactProp
1919
const rawCSOs = attrs['CSOs'];
2020
if (Array.isArray(rawCSOs)) {
2121
CSOs = rawCSOs as string[];
22-
} else if (typeof rawCSOs === 'string') {
22+
} else if (typeof rawCSOs === 'string' && rawCSOs.trim().length > 0) {
2323
try {
24-
CSOs = JSON.parse(rawCSOs) as string[];
24+
const parsed = JSON.parse(rawCSOs) as unknown;
25+
if (Array.isArray(parsed)) {
26+
CSOs = parsed as string[];
27+
}
2528
} catch {
26-
CSOs = [];
29+
// ArcGIS may serialise Python-style lists with single quotes; normalise and retry
30+
try {
31+
const normalised = rawCSOs.replace(/'/g, '"');
32+
const parsed = JSON.parse(normalised) as unknown;
33+
if (Array.isArray(parsed)) {
34+
CSOs = parsed as string[];
35+
}
36+
} catch {
37+
// Fall back to treating the whole string as a comma-separated list
38+
CSOs = rawCSOs
39+
.replace(/^\[|\]$/g, '')
40+
.split(',')
41+
.map((s) => s.trim().replace(/^['"]|['"]$/g, ''))
42+
.filter(Boolean);
43+
}
2744
}
2845
}
2946

0 commit comments

Comments
 (0)