Skip to content

Commit 1acf550

Browse files
committed
feat(surge-card): display earliest operation start date & total duration for an emergency
1 parent b686c3d commit 1acf550

File tree

4 files changed

+74
-13
lines changed

4 files changed

+74
-13
lines changed

app/src/views/ActiveSurgeDeployments/ActiveSurgeSupport/SurgeCard/i18n.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"surgeRapidResponsePersonnel": "Rapid Response Personnel",
66
"surgeDeployedERUs": "ERUs Deployed",
77
"surgeDeployedRRs": "RRs Deployed",
8-
"surgeDeployingOrganizations": "Deploying Organisation"
8+
"surgeDeployingOrganizations": "Deploying Organisation",
9+
"operationTimeline": "{startDate} ({duration})",
10+
"operationStartDate": "Operation Start Date"
911
}
1012
}

app/src/views/ActiveSurgeDeployments/ActiveSurgeSupport/SurgeCard/index.tsx

+35
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import {
55
TextOutput,
66
} from '@ifrc-go/ui';
77
import { useTranslation } from '@ifrc-go/ui/hooks';
8+
import {
9+
getDuration,
10+
maxSafe,
11+
minSafe,
12+
resolveToComponent,
13+
} from '@ifrc-go/ui/utils';
814
import {
915
_cs,
1016
isDefined,
@@ -38,11 +44,23 @@ function SurgeCard(props: Props) {
3844
deployed_personnel_count: deployedPersonnelCount,
3945
deployments,
4046
erus,
47+
appeals,
4148
},
4249
} = props;
4350

4451
const strings = useTranslation(i18n);
4552

53+
const operationStartDate = minSafe(appeals.map(
54+
(a) => a.start_date,
55+
).filter(isDefined).map((d) => new Date(d).getTime()));
56+
57+
const operationEndDate = maxSafe(appeals.map(
58+
(a) => a.end_date,
59+
).filter(isDefined).map((d) => new Date(d).getTime()));
60+
61+
const duration = isDefined(operationStartDate) && isDefined(operationEndDate)
62+
? getDuration(new Date(operationStartDate), new Date(operationEndDate)) : undefined;
63+
4664
const deployedERUTypes = useMemo(() => (
4765
joinStrings(erus.map((eru) => eru.type_display).filter(isDefined))
4866
), [erus]);
@@ -81,6 +99,20 @@ function SurgeCard(props: Props) {
8199
{emergencyName}
82100
</Link>
83101
)}
102+
headerDescriptionContainerClassName={styles.headerDescription}
103+
headerDescription={resolveToComponent(
104+
strings.operationTimeline,
105+
{
106+
startDate: (
107+
<TextOutput
108+
value={operationStartDate}
109+
label={strings.operationStartDate}
110+
valueType="date"
111+
/>
112+
),
113+
duration,
114+
},
115+
)}
84116
headingLevel={4}
85117
withInternalPadding
86118
withHeaderBorder
@@ -96,6 +128,7 @@ function SurgeCard(props: Props) {
96128
{deployedERUCount > 0 && (
97129
<Container
98130
spacing="cozy"
131+
className={styles.surge}
99132
childrenContainerClassName={styles.figures}
100133
footerContent={(
101134
<TextOutput
@@ -129,8 +162,10 @@ function SurgeCard(props: Props) {
129162
)}
130163
{deployedPersonnelCount > 0 && (
131164
<Container
165+
className={styles.surge}
132166
childrenContainerClassName={styles.figures}
133167
spacing="cozy"
168+
footerClassName={styles.footerContent}
134169
footerContent={(
135170
<TextOutput
136171
value={personnelDeployingOrganizations}

app/src/views/ActiveSurgeDeployments/ActiveSurgeSupport/SurgeCard/styles.module.css

+24-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
width: 100%;
55
overflow: auto;
66

7+
.header-description {
8+
display: flex;
9+
gap: var(--go-ui-spacing-xs);
10+
color: var(--go-ui-color-text-light);
11+
}
12+
713
.heading-container {
814
width: 100%;
915
overflow: auto;
@@ -29,24 +35,30 @@
2935
border-bottom: var(--go-ui-width-separator-thin) solid var(--go-ui-color-separator);
3036
}
3137

32-
.figures {
38+
.surge {
3339
display: flex;
3440
flex-grow: 1;
35-
gap: var(--go-ui-spacing-sm);
3641

37-
.figure {
42+
.figures {
3843
display: flex;
39-
flex-basis: 0;
40-
flex-direction: column;
44+
align-items: flex-start;
4145
flex-grow: 1;
42-
justify-content: flex-end;
43-
padding: 0;
44-
}
46+
gap: var(--go-ui-spacing-sm);
47+
48+
.figure {
49+
display: flex;
50+
flex-basis: 0;
51+
flex-direction: column;
52+
flex-grow: 1;
53+
justify-content: flex-end;
54+
padding: 0;
55+
}
4556

46-
.separator {
47-
flex-shrink: 0;
48-
background-color: var(--go-ui-color-separator);
49-
width: var(--go-ui-width-separator-sm);
57+
.separator {
58+
flex-shrink: 0;
59+
background-color: var(--go-ui-color-separator);
60+
width: var(--go-ui-width-separator-sm);
61+
}
5062
}
5163
}
5264
}

translationMigrations/000022-1742971344419.json renamed to translationMigrations/000022-1742989829568.json

+12
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@
163163
"namespace": "activeSurgeDeployments",
164164
"value": "Emergency Start Date"
165165
},
166+
{
167+
"action": "add",
168+
"key": "operationStartDate",
169+
"namespace": "activeSurgeDeployments",
170+
"value": "Operation Start Date"
171+
},
172+
{
173+
"action": "add",
174+
"key": "operationTimeline",
175+
"namespace": "activeSurgeDeployments",
176+
"value": "{startDate} ({duration})"
177+
},
166178
{
167179
"action": "add",
168180
"key": "personnelLabel",

0 commit comments

Comments
 (0)