Skip to content

Commit 6c04b5b

Browse files
committed
feat: exclude sub-components from the PER components filter in Operational Learning
1 parent 9be0355 commit 6c04b5b

File tree

3 files changed

+23
-30
lines changed

3 files changed

+23
-30
lines changed

app/src/views/OperationalLearning/Stats/OperationalLearningMap/index.tsx

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ interface ClickedPoint {
5353
lngLat: mapboxgl.LngLatLike;
5454
}
5555

56-
const LEARNING_COUNT_LOW_COLOR = '#E0E3E7';
56+
const LEARNING_COUNT_LOW_COLOR = '#AEB7C2';
5757
const LEARNING_COUNT_HIGH_COLOR = '#011E41';
58-
// const bluePointCirclePaint = getPointCirclePaint(COLOR_BLUE);
5958

6059
interface Props {
6160
className?: string;
@@ -129,7 +128,7 @@ function OperationalLearningMap(props: Props) {
129128
'circle-opacity': 0.9,
130129
'circle-color': [
131130
'interpolate',
132-
['exponential', 1],
131+
['linear'],
133132
['number', ['get', 'learningCount']],
134133
0,
135134
LEARNING_COUNT_LOW_COLOR,
@@ -140,28 +139,8 @@ function OperationalLearningMap(props: Props) {
140139
'interpolate',
141140
['linear'],
142141
['zoom'],
143-
3, [
144-
'interpolate',
145-
['exponential', 1],
146-
['number', ['get', 'learningCount']],
147-
0,
148-
0,
149-
1,
150-
5,
151-
maxScaleValue,
152-
20,
153-
],
154-
8, [
155-
'interpolate',
156-
['exponential', 1],
157-
['number', ['get', 'learningCount']],
158-
0,
159-
0,
160-
1,
161-
10,
162-
maxScaleValue,
163-
30,
164-
],
142+
3, 10,
143+
8, 15,
165144
],
166145
};
167146
}, [learningByCountry]);

app/src/views/OperationalLearning/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"here": "here",
2323
"beta": "beta",
2424
"failedToFetchSummary": "Failed to fetch operational learning summary",
25-
"failedToFetchLearning": "Failed to fetch operational learning"
25+
"failedToFetchLearning": "Failed to fetch operational learning",
26+
"failedToFetchPerComponents": "Failed to fetch PER components"
2627
}
2728
}

app/src/views/OperationalLearning/index.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { type components } from '#generated/types';
4747
import useCountry from '#hooks/domain/useCountry';
4848
import useDisasterTypes, { type DisasterType } from '#hooks/domain/useDisasterType';
4949
import useGlobalEnums from '#hooks/domain/useGlobalEnums';
50-
import usePerComponent from '#hooks/domain/usePerComponent';
5150
import useSecondarySector from '#hooks/domain/useSecondarySector';
5251
import useAlert from '#hooks/useAlert';
5352
import useFilterState from '#hooks/useFilterState';
@@ -132,7 +131,21 @@ export function Component() {
132131
const countryList = useCountry({ region: rawFilter.region });
133132
const disasterTypeOptions = useDisasterTypes();
134133
const secondarySectorOptions = useSecondarySector();
135-
const perComponentOptions = usePerComponent();
134+
const {
135+
response: perComponentsResponse,
136+
} = useRequest({
137+
url: '/api/v2/per-formcomponent/',
138+
query: {
139+
exclude_subcomponents: true,
140+
},
141+
preserveResponse: true,
142+
onFailure: () => {
143+
alert.show(
144+
strings.failedToFetchPerComponents,
145+
{ variant: 'danger' },
146+
);
147+
},
148+
});
136149

137150
const {
138151
pending: opsLearningSummaryPending,
@@ -361,7 +374,7 @@ export function Component() {
361374
onChange={onFilterChange}
362375
disasterTypeOptions={disasterTypeOptions}
363376
secondarySectorOptions={secondarySectorOptions}
364-
perComponentOptions={perComponentOptions}
377+
perComponentOptions={perComponentsResponse?.results}
365378
organizationTypeOptions={opsLearningOrganizationTypes?.results}
366379
perLearningTypeOptions={perLearningTypeOptions}
367380
organizationTypePending={opsLearningOrganizationTypePending}
@@ -415,7 +428,7 @@ export function Component() {
415428
name="perComponents"
416429
onDismiss={onFilterChange}
417430
value={rawFilter.perComponents}
418-
options={perComponentOptions}
431+
options={perComponentsResponse?.results}
419432
labelSelector={getFormattedComponentName}
420433
keySelector={numericIdSelector}
421434
/>

0 commit comments

Comments
 (0)