Skip to content

Commit 09514f0

Browse files
authored
Merge pull request #4260 from keithamoss/production-south-australia-2026-fork
Production south australia 2026 fork
2 parents 0df7b89 + 28effb7 commit 09514f0

File tree

8 files changed

+1153
-103
lines changed

8 files changed

+1153
-103
lines changed

admin-redesign/src/app/services/elections.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,20 @@ export const electionsApi = api.injectEndpoints({
170170
}),
171171
}),
172172
getImpossibilitiesReport: builder.query<
173-
{ type: string; name: string; passed: boolean; message: string; ids: number[] }[],
173+
// Most checks can group offending IDs by election. One check
174+
// ('polling_place_noms_not_attached_to_a_polling_place') has no election
175+
// FK to traverse (the noms record is detached), so it returns a flat 'ids'
176+
// list instead. The UI discriminates on 'ids_by_election' in item.
177+
(
178+
| {
179+
type: string;
180+
name: string;
181+
passed: boolean;
182+
message: string;
183+
ids_by_election: { election_id: number; election_name: string; ids: number[] }[];
184+
}
185+
| { type: string; name: string; passed: boolean; message: string; ids: number[] }
186+
)[],
174187
void
175188
>({
176189
query: () => ({

admin-redesign/src/features/impossibilities/QualityAssuranceReport.tsx

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,79 @@ function QualityAssuranceReport() {
4242
the system.
4343
</Typography>
4444

45-
{qaReport.map((item) => (
46-
<Box
47-
key={item.type}
48-
sx={{
49-
display: 'flex',
50-
alignItems: 'center',
51-
backgroundColor: item.passed === false ? red[100] : undefined,
52-
p: 1,
53-
mb: 1,
54-
}}
55-
>
56-
<Typography variant="h4">{item.ids.length}</Typography>
45+
{qaReport.map((item) => {
46+
const isGrouped = 'ids_by_election' in item;
47+
const totalCount = isGrouped ? item.ids_by_election.reduce((sum, g) => sum + g.ids.length, 0) : item.ids.length;
5748

58-
<ListItem
59-
secondaryAction={
60-
item.passed === false && isClipboardApiSupported() === true ? (
61-
<IconButton edge="end" onClick={onCopyToClipboard(item.ids)}>
62-
<ContentCopy />
63-
</IconButton>
64-
) : undefined
65-
}
66-
sx={{ pt: 0, pb: 0 }}
49+
return (
50+
<Box
51+
key={item.type}
52+
sx={{
53+
backgroundColor: item.passed === false ? red[100] : undefined,
54+
p: 1,
55+
mb: 1,
56+
}}
6757
>
68-
<ListItemText
69-
primary={item.name}
70-
secondary={item.ids.join(', ') || 'Everything is fine 🎉'}
71-
sx={{ flexGrow: 1 }}
72-
/>
73-
</ListItem>
74-
</Box>
75-
))}
58+
{/* Header row: count + check name */}
59+
<Box sx={{ display: 'flex', alignItems: 'center' }}>
60+
<Typography variant="h4">{totalCount}</Typography>
61+
62+
{isGrouped ? (
63+
<ListItem sx={{ pt: 0, pb: 0 }}>
64+
<ListItemText primary={item.name} sx={{ flexGrow: 1 }} />
65+
</ListItem>
66+
) : (
67+
<ListItem
68+
secondaryAction={
69+
item.passed === false && isClipboardApiSupported() === true ? (
70+
<IconButton edge="end" onClick={onCopyToClipboard(item.ids)}>
71+
<ContentCopy />
72+
</IconButton>
73+
) : undefined
74+
}
75+
sx={{ pt: 0, pb: 0 }}
76+
>
77+
<ListItemText
78+
primary={item.name}
79+
secondary={item.ids.join(', ') || 'Everything is fine 🎉'}
80+
sx={{ flexGrow: 1 }}
81+
/>
82+
</ListItem>
83+
)}
84+
</Box>
85+
86+
{/* Grouped: per-election sub-rows */}
87+
{isGrouped && item.ids_by_election.length === 0 && (
88+
<Typography variant="body2" sx={{ pl: 7, pb: 0.5, color: 'text.secondary' }}>
89+
Everything is fine 🎉
90+
</Typography>
91+
)}
92+
93+
{isGrouped &&
94+
item.ids_by_election.map((group) => (
95+
<Box key={group.election_id} sx={{ display: 'flex', alignItems: 'center' }}>
96+
<ListItem
97+
secondaryAction={
98+
isClipboardApiSupported() === true ? (
99+
<IconButton edge="end" onClick={onCopyToClipboard(group.ids)}>
100+
<ContentCopy />
101+
</IconButton>
102+
) : undefined
103+
}
104+
sx={{ pt: 0.5, pb: 0.5 }}
105+
>
106+
<ListItemText
107+
primary={group.election_name}
108+
primaryTypographyProps={{ variant: 'body2' }}
109+
secondary={group.ids.join(', ')}
110+
sx={{ flexGrow: 1 }}
111+
/>
112+
</ListItem>
113+
</Box>
114+
))}
115+
</Box>
116+
);
117+
})}
76118
</PageWrapper>
77119
);
78120
}

0 commit comments

Comments
 (0)