Skip to content

Commit f9e053e

Browse files
committed
fix: use /eru-readiness-type/ api for eru type filtering
1 parent f1999b1 commit f9e053e

File tree

8 files changed

+100
-93
lines changed

8 files changed

+100
-93
lines changed

app/src/views/ActiveSurgeDeployments/OngoingERUDeployments/i18n.json

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"namespace": "activeSurgeDeployments",
3+
"strings": {
4+
"eruHeading": "Ongoing ERU Deployments",
5+
"eruEmergency": "Emergency / Name",
6+
"eruOrganisation": "Organisation",
7+
"eruName": "Name",
8+
"eruViewAll": "View All",
9+
"eruTypes": "ERU Types",
10+
"ongoingEmergencyStartDate": "Emergency Start Date",
11+
"ongoingEmergencyEndDate": "Emergency End Date",
12+
"eruStartDate": "Deployment Start Date",
13+
"eruEndDate": "Deployment End Date",
14+
"eruEmergencyTimeline": "Emergency Timeline",
15+
"eruDeploymentTimeline": "Deployment Timeline"
16+
}
17+
}

app/src/views/ActiveSurgeDeployments/OngoingERUDeployments/index.tsx renamed to app/src/views/ActiveSurgeDeployments/OngoingEruDeployments/index.tsx

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ import styles from './styles.module.css';
4747

4848
type DeploymentsEruTypeEnum = components<'read'>['schemas']['DeploymentsEruTypeEnum'];
4949

50-
type GetERUDeploymentsResponse = GoApiResponse<'/api/v2/deployed_eru_by_event/'>;
51-
type ERUDeploymentListItem = NonNullable<GetERUDeploymentsResponse['results']>[number];
52-
type ActiveERUListItem = NonNullable<ERUDeploymentListItem['active_erus']>[number];
50+
type GetEruByEventResponse = GoApiResponse<'/api/v2/deployed_eru_by_event/'>;
51+
type EruByEvent = NonNullable<GetEruByEventResponse['results']>[number];
52+
type EruListItem = NonNullable<EruByEvent['active_erus']>[number];
5353

54-
const eruResponsesKeySelector = (item: ERUDeploymentListItem) => item.id;
54+
const deployedEruKeySelector = (item: EruByEvent) => item.id;
5555

5656
const emergencyResponseUnitTypeKeySelector = (item: DeploymentsEruTypeEnum) => item.key;
5757
const emergencyResponseUnitTypeLabelSelector = (item: DeploymentsEruTypeEnum) => item.value ?? '?';
5858

5959
const PAGE_SIZE = 5;
6060

61-
function OngoingERUDeployments() {
61+
function OngoingEruDeployments() {
6262
const strings = useTranslation(i18n);
6363

6464
const {
@@ -80,11 +80,11 @@ function OngoingERUDeployments() {
8080
deployments_eru_type: eruTypes,
8181
} = useGlobalEnums();
8282

83-
const [expandedRow, setExpandedRow] = useState<ERUDeploymentListItem | undefined>();
83+
const [expandedRow, setExpandedRow] = useState<EruByEvent | undefined>();
8484

8585
const {
86-
pending: deployedERUResponsePending,
87-
response: deployedERUResponse,
86+
pending: deployedEruResponsePending,
87+
response: deployedEruResponse,
8888
} = useRequest({
8989
url: '/api/v2/deployed_eru_by_event/',
9090
preserveResponse: true,
@@ -96,11 +96,11 @@ function OngoingERUDeployments() {
9696
});
9797

9898
const eruEventDates = useMemo(() => {
99-
if (isNotDefined(deployedERUResponse)) {
99+
if (isNotDefined(deployedEruResponse)) {
100100
return undefined;
101101
}
102-
return getEruEventDates(deployedERUResponse.results);
103-
}, [deployedERUResponse]);
102+
return getEruEventDates(deployedEruResponse.results);
103+
}, [deployedEruResponse]);
104104

105105
const timelineDateRange = useMemo(() => {
106106
if (isNotDefined(eruEventDates)) {
@@ -117,7 +117,7 @@ function OngoingERUDeployments() {
117117
}, [eruEventDates]);
118118

119119
const handleExpandClick = useCallback(
120-
(row: ERUDeploymentListItem) => {
120+
(row: EruByEvent) => {
121121
setExpandedRow(
122122
(prevValue) => (prevValue?.id === row.id ? undefined : row),
123123
);
@@ -127,9 +127,9 @@ function OngoingERUDeployments() {
127127

128128
const columns = useMemo(
129129
() => ([
130-
createLinkColumn<ERUDeploymentListItem, number>(
130+
createLinkColumn<EruByEvent, number>(
131131
'name',
132-
strings.deployedERUEmergency,
132+
strings.eruEmergency,
133133
(item) => item.name,
134134
(item) => ({
135135
to: 'emergenciesLayout',
@@ -138,13 +138,13 @@ function OngoingERUDeployments() {
138138
},
139139
}),
140140
),
141-
createStringColumn<ERUDeploymentListItem, number>(
141+
createStringColumn<EruByEvent, number>(
142142
'organisation',
143-
strings.deployedERUOrganisation,
143+
strings.eruOrganisation,
144144
() => '',
145145
{ columnClassName: styles.organisation },
146146
),
147-
createMultiTimelineColumn<ERUDeploymentListItem, number>(
147+
createMultiTimelineColumn<EruByEvent, number>(
148148
'timeline',
149149
timelineDateRange,
150150
(item) => {
@@ -154,15 +154,15 @@ function OngoingERUDeployments() {
154154
endDate: itemDateRange?.appealEndDate,
155155
highlightedStartDate: itemDateRange?.eruStartDate,
156156
highlightedEndDate: itemDateRange?.eruEndDate,
157-
startDateLabel: strings.deployedAppealStartDate,
158-
endDateLabel: strings.deployedAppealEndDate,
159-
highlightedStartDateLabel: strings.deployedERUStartDate,
160-
highlightedEndDateLabel: strings.deployedERUEndDate,
157+
startDateLabel: strings.ongoingEmergencyStartDate,
158+
endDateLabel: strings.ongoingEmergencyEndDate,
159+
highlightedStartDateLabel: strings.eruStartDate,
160+
highlightedEndDateLabel: strings.eruEndDate,
161161
};
162162
},
163163
{ columnClassName: styles.timeline },
164164
),
165-
createExpandColumn<ERUDeploymentListItem, number>(
165+
createExpandColumn<EruByEvent, number>(
166166
'expandRow',
167167
'',
168168
(row) => ({
@@ -175,28 +175,28 @@ function OngoingERUDeployments() {
175175
handleExpandClick,
176176
expandedRow,
177177
timelineDateRange,
178-
strings.deployedERUEmergency,
179-
strings.deployedERUOrganisation,
180-
strings.deployedAppealStartDate,
181-
strings.deployedAppealEndDate,
182-
strings.deployedERUStartDate,
183-
strings.deployedERUEndDate,
178+
strings.eruEmergency,
179+
strings.eruOrganisation,
180+
strings.ongoingEmergencyStartDate,
181+
strings.ongoingEmergencyEndDate,
182+
strings.eruStartDate,
183+
strings.eruEndDate,
184184
],
185185
);
186186

187187
const eruColumns = useMemo(
188188
() => ([
189-
createStringColumn<ActiveERUListItem, number>(
189+
createStringColumn<EruListItem, number>(
190190
'name',
191-
strings.deployedERUName,
191+
strings.eruName,
192192
(item) => item?.type_display,
193193
),
194-
createStringColumn<ActiveERUListItem, number>(
194+
createStringColumn<EruListItem, number>(
195195
'society_name',
196-
strings.deployedERUOrganisation,
196+
strings.eruOrganisation,
197197
(item) => item?.eru_owner_details?.national_society_country_details.society_name,
198198
),
199-
createTimelineColumn<ActiveERUListItem, number>(
199+
createTimelineColumn<EruListItem, number>(
200200
'timeline',
201201
timelineDateRange,
202202
(item) => ({
@@ -205,17 +205,17 @@ function OngoingERUDeployments() {
205205
}),
206206
{ columnClassName: styles.timeline },
207207
),
208-
createEmptyColumn<ActiveERUListItem, number>(),
208+
createEmptyColumn<EruListItem, number>(),
209209
]),
210210
[
211211
timelineDateRange,
212-
strings.deployedERUOrganisation,
213-
strings.deployedERUName,
212+
strings.eruOrganisation,
213+
strings.eruName,
214214
],
215215
);
216216

217217
const rowModifier = useCallback(
218-
({ row, datum }: RowOptions<ERUDeploymentListItem, number>) => {
218+
({ row, datum }: RowOptions<EruByEvent, number>) => {
219219
if (datum.id !== expandedRow?.id) {
220220
return row;
221221
}
@@ -243,12 +243,12 @@ function OngoingERUDeployments() {
243243
return (
244244
<Container
245245
className={styles.ongoingEruDeployments}
246-
heading={strings.deployedERUHeading}
246+
heading={strings.eruHeading}
247247
withHeaderBorder
248248
footerActions={(
249249
<Pager
250250
activePage={page}
251-
itemsCount={deployedERUResponse?.count ?? 0}
251+
itemsCount={deployedEruResponse?.count ?? 0}
252252
maxItemsPerPage={limit}
253253
onActivePageChange={setPage}
254254
/>
@@ -259,12 +259,12 @@ function OngoingERUDeployments() {
259259
withLinkIcon
260260
withUnderline
261261
>
262-
{strings.deployedERUViewAll}
262+
{strings.eruViewAll}
263263
</Link>
264264
)}
265265
filters={(
266266
<SelectInput
267-
placeholder={strings.deployedERUTypes}
267+
placeholder={strings.eruTypes}
268268
name="type"
269269
value={rawFilter.type}
270270
onChange={setFilterField}
@@ -276,11 +276,11 @@ function OngoingERUDeployments() {
276276
footerContent={(
277277
<>
278278
<LegendItem
279-
label={strings.deploymentsERUEmergencyTimeline}
279+
label={strings.eruEmergencyTimeline}
280280
color={COLOR_LIGHT_GREY}
281281
/>
282282
<LegendItem
283-
label={strings.deploymentsERUDates}
283+
label={strings.eruDeploymentTimeline}
284284
color={COLOR_PRIMARY_RED}
285285
/>
286286
</>
@@ -289,16 +289,16 @@ function OngoingERUDeployments() {
289289
<SortContext.Provider value={sortState}>
290290
<Table
291291
className={styles.table}
292-
pending={deployedERUResponsePending}
292+
pending={deployedEruResponsePending}
293293
columns={columns}
294294
rowModifier={rowModifier}
295-
keySelector={eruResponsesKeySelector}
296-
data={deployedERUResponse?.results}
295+
keySelector={deployedEruKeySelector}
296+
data={deployedEruResponse?.results}
297297
filtered={filtered}
298298
/>
299299
</SortContext.Provider>
300300
</Container>
301301
);
302302
}
303303

304-
export default OngoingERUDeployments;
304+
export default OngoingEruDeployments;

app/src/views/ActiveSurgeDeployments/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Container } from '@ifrc-go/ui';
22

33
import ActiveRapidResponseTable from './ActiveRapidResponseTable';
44
import ActiveSurgeSupport from './ActiveSurgeSupport';
5-
import OngoingERUDeployments from './OngoingERUDeployments';
5+
import OngoingEruDeployments from './OngoingEruDeployments';
66
import OngoingRapidResponseDeployments from './OngoingRapidResponseDeployments';
77
import SurgeMap from './SurgeMap';
88

@@ -22,7 +22,7 @@ export function Component() {
2222
<ActiveSurgeSupport />
2323
<ActiveRapidResponseTable />
2424
<OngoingRapidResponseDeployments />
25-
<OngoingERUDeployments />
25+
<OngoingEruDeployments />
2626
</Container>
2727
);
2828
}

app/src/views/SurgeOverview/EmergencyResponseUnit/EmergencyResponseUnitReadiness/EmergencyResponseUnitCard/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function getReadinessColor(rank: number | undefined) {
2323
return styles.grayIcon;
2424
}
2525

26-
type GetEruReadinessResponse = GoApiResponse<'/api/v2/eru-readiness/'>;
26+
type GetEruReadinessResponse = GoApiResponse<'/api/v2/eru-readiness-type/'>;
2727

28-
export type ReadinessList = Array<NonNullable<NonNullable<GetEruReadinessResponse['results']>[0]>['eru_types'][0] & {
29-
eruOwner: NonNullable<NonNullable<GetEruReadinessResponse['results']>[0]>['eru_owner_details'];
30-
updatedAt: NonNullable<NonNullable<GetEruReadinessResponse['results']>[0]>['updated_at'];
28+
export type ReadinessList = Array<NonNullable<NonNullable<GetEruReadinessResponse['results']>[0]> & {
29+
eruOwner: NonNullable<NonNullable<NonNullable<GetEruReadinessResponse['results']>[0]>['eru_readiness']>[0]['eru_owner_details'];
30+
updatedAt: NonNullable<NonNullable<NonNullable<GetEruReadinessResponse['results']>[0]>['eru_readiness']>[0]['updated_at'];
3131
}>
3232

3333
interface Props {

0 commit comments

Comments
 (0)