Skip to content

Commit fe8ba3c

Browse files
authored
Merge pull request #1951 from IFRCGo/feature/add-crisis-category-history
feat(emergency): add last updated date for crisis categorization
2 parents 51a9510 + 039c488 commit fe8ba3c

File tree

10 files changed

+134
-11
lines changed

10 files changed

+134
-11
lines changed

.changeset/solid-clubs-care.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"go-web-app": minor
3+
---
4+
5+
- Added updated date for crisis categorization in emergency page.
6+
- Added consent checkbox over situational overview in field report form.

app/src/components/domain/HighlightedOperations/OperationCard/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function OperationCard(props: Props) {
5454
id,
5555
name,
5656
ifrc_severity_level,
57+
ifrc_severity_level_update_date,
5758
ifrc_severity_level_display,
5859
updated_at,
5960
appeals,
@@ -139,15 +140,26 @@ function OperationCard(props: Props) {
139140
<Tooltip
140141
description={(
141142
<>
142-
<TextOutput
143-
label={(
144-
<SeverityIndicator
145-
level={ifrc_severity_level}
143+
<div className={styles.severityContainer}>
144+
<TextOutput
145+
label={(
146+
<SeverityIndicator
147+
level={ifrc_severity_level}
148+
/>
149+
)}
150+
value={ifrc_severity_level_display}
151+
withoutLabelColon
152+
/>
153+
{ifrc_severity_level_update_date && ','}
154+
{ifrc_severity_level_update_date && (
155+
<TextOutput
156+
className={styles.date}
157+
value={ifrc_severity_level_update_date}
158+
valueType="date"
159+
withoutLabelColon
146160
/>
147161
)}
148-
value={ifrc_severity_level_display}
149-
withoutLabelColon
150-
/>
162+
</div>
151163
<TextOutput
152164
label={<FocusLineIcon />}
153165
value={countriesInfoDisplay}

app/src/components/domain/HighlightedOperations/OperationCard/styles.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@
4040
}
4141
}
4242
}
43+
44+
.severity-container {
45+
display: flex;
46+
47+
.date {
48+
padding-left: var(--go-ui-spacing-xs);
49+
}
50+
}
51+

app/src/views/EmergencyDetails/i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"situationalOverviewTitle": "Situational Overview",
1515
"linksTitle": "Links",
1616
"emergencyMapTitle": "Affected Provinces",
17+
"severityLevelUpdateDateLabel": "Updated date",
1718
"exportMap": "Export",
1819
"contactsTitle": "Contacts",
1920
"sourceLabel": "Source {source}"

app/src/views/EmergencyDetails/index.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useOutletContext } from 'react-router-dom';
33
import {
44
Container,
55
HtmlOutput,
6+
InfoPopup,
67
KeyFigure,
78
TextOutput,
89
} from '@ifrc-go/ui';
@@ -193,6 +194,20 @@ export function Component() {
193194
<SeverityIndicator
194195
level={emergencyResponse.ifrc_severity_level}
195196
/>
197+
{emergencyResponse.ifrc_severity_level_update_date && (
198+
<InfoPopup
199+
description={(
200+
<TextOutput
201+
label={strings.severityLevelUpdateDateLabel}
202+
value={
203+
emergencyResponse
204+
.ifrc_severity_level_update_date
205+
}
206+
valueType="date"
207+
/>
208+
)}
209+
/>
210+
)}
196211
</>
197212
)}
198213
valueClassName={styles.disasterCategoryValue}

app/src/views/FieldReportForm/SituationFields/i18n.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
"fieldsStep2SituationFieldsEVTMissingDescription": "Number of people missing.",
4848
"fieldsStep2SituationFieldsEVTMissingLabel": "Missing",
4949
"fieldsStep2SourceOfFiguresLabel": "Source (of figures)",
50-
"fieldReportFormNumericDetails": "Numeric Details (People)"
50+
"fieldReportFormNumericDetails": "Numeric Details (People)",
51+
"fieldReportOverviewConsentLabel": "All content published on IFRC platforms must adhere to the {fundamentalPrinciples} and align with the relevant Movement language and communications guidelines. Where content does not meet these standards, the IFRC will collaborate with the respective National Society to revise it accordingly.",
52+
"fieldReportFundamentalPrinciplesLabel": "Fundamental Principles"
5153
}
5254
}
5355

app/src/views/FieldReportForm/SituationFields/index.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo } from 'react';
22
import {
3+
Checkbox,
34
Container,
45
DateInput,
56
InputSection,
@@ -8,12 +9,14 @@ import {
89
TextArea,
910
} from '@ifrc-go/ui';
1011
import { useTranslation } from '@ifrc-go/ui/hooks';
12+
import { resolveToComponent } from '@ifrc-go/ui/utils';
1113
import {
1214
type EntriesAsList,
1315
type Error,
1416
getErrorObject,
1517
} from '@togglecorp/toggle-form';
1618

19+
import Link from '#components/Link';
1720
import RichTextArea from '#components/RichTextArea';
1821
import useGlobalEnums from '#hooks/domain/useGlobalEnums';
1922
import { type ReportType } from '#utils/constants';
@@ -53,6 +56,20 @@ function SituationFields(props: Props) {
5356

5457
const sectionHeading = strings.fieldReportFormNumericDetails;
5558

59+
const overviewConsentLabel = resolveToComponent(
60+
strings.fieldReportOverviewConsentLabel,
61+
{
62+
fundamentalPrinciples: (
63+
<Link
64+
href="https://www.ifrc.org/who-we-are/international-red-cross-and-red-crescent-movement/fundamental-principles"
65+
external
66+
>
67+
{strings.fieldReportFundamentalPrinciplesLabel}
68+
</Link>
69+
),
70+
},
71+
);
72+
5673
if (reportType === 'COVID') {
5774
return (
5875
<Container
@@ -500,12 +517,20 @@ function SituationFields(props: Props) {
500517
title={strings.fieldsStep2DescriptionEVTLabel}
501518
description={strings.fieldsStep2DescriptionEVTDescription}
502519
>
520+
<Checkbox
521+
label={overviewConsentLabel}
522+
name="situationalOverviewConsented"
523+
value={value.situationalOverviewConsented}
524+
onChange={onValueChange}
525+
disabled={disabled}
526+
error={error?.situationalOverviewConsented}
527+
/>
503528
<RichTextArea
504529
name="description"
505530
value={value.description}
506531
onChange={onValueChange}
507532
error={error?.description}
508-
disabled={disabled}
533+
disabled={disabled || !value.situationalOverviewConsented}
509534
placeholder={strings.fieldsStep2DescriptionEVTPlaceholder}
510535
/>
511536
</InputSection>

app/src/views/FieldReportForm/common.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { type DeepReplace } from '@ifrc-go/ui/utils';
22
import {
33
isDefined,
44
isNotDefined,
5+
isTruthyString,
6+
type Maybe,
57
} from '@togglecorp/fujs';
68
import {
79
addCondition,
@@ -31,6 +33,12 @@ import {
3133
} from '#utils/form';
3234
import { type GoApiResponse } from '#utils/restRequest';
3335

36+
function isTrueValue(value: Maybe<boolean>) {
37+
// FIXME: use translations
38+
return (isNotDefined(value) || value === false)
39+
? 'This field must be consented to if situational overview is filled.'
40+
: undefined;
41+
}
3442
// FORM
3543

3644
type FieldReportResponse = GoApiResponse<'/api/v2/field-report/{id}/'>;
@@ -50,6 +58,8 @@ export type FormValue = Omit<
5058
// FIXME: Why do we need to change countries to country
5159
// Fix this in the server later
5260
country: number,
61+
// NOTE: This is not sent to server, only used from frontend validation
62+
situationalOverviewConsented: boolean,
5363
};
5464

5565
export type PartialFormValue = PurgeNull<PartialForm<FormValue, 'uuid' | 'ctype' | 'organization'>>;
@@ -155,6 +165,7 @@ const fieldsInContext = [
155165
] satisfies (keyof PartialFormValue)[];
156166
const fieldsInSituation = [
157167
'affected_pop_centres',
168+
'situationalOverviewConsented',
158169
'description',
159170
'epi_cases',
160171
'epi_cases_since_last_fr',
@@ -314,6 +325,7 @@ export const reportSchema: FormSchema = {
314325
const situationFields = [
315326
'affected_pop_centres',
316327
'description',
328+
'situationalOverviewConsented',
317329
'epi_cases',
318330
'epi_cases_since_last_fr',
319331
'epi_confirmed_cases',
@@ -354,13 +366,15 @@ export const reportSchema: FormSchema = {
354366
baseSchema = addCondition(
355367
baseSchema,
356368
value,
357-
['status', 'is_covid_report', 'dtype'],
369+
['status', 'is_covid_report', 'dtype', 'description'],
358370
situationFields,
359371
(val): SituationSchema => {
360372
const reportType = getReportType(val?.status, val?.is_covid_report, val?.dtype);
373+
const consentRequired = isTruthyString(val?.description);
361374

362375
const baseSchemaTwo: SituationSchema = {
363376
description: {},
377+
situationalOverviewConsented: {},
364378
other_sources: {},
365379

366380
affected_pop_centres: { forceValue: nullValue },
@@ -402,6 +416,11 @@ export const reportSchema: FormSchema = {
402416
if (reportType === 'EW') {
403417
return {
404418
...baseSchemaTwo,
419+
situationalOverviewConsented: {
420+
validations: [
421+
consentRequired ? isTrueValue : undefined,
422+
].filter(isDefined),
423+
},
405424
num_potentially_affected: { validations: [positiveIntegerCondition] },
406425
gov_num_potentially_affected: { validations: [positiveIntegerCondition] },
407426
other_num_potentially_affected: { validations: [positiveIntegerCondition] },
@@ -443,6 +462,11 @@ export const reportSchema: FormSchema = {
443462
// SITUATION - EVT
444463
return {
445464
...baseSchemaTwo,
465+
situationalOverviewConsented: {
466+
validations: [
467+
consentRequired ? isTrueValue : undefined,
468+
].filter(isDefined),
469+
},
446470
num_injured: { validations: [positiveIntegerCondition] },
447471
gov_num_injured: { validations: [positiveIntegerCondition] },
448472
other_num_injured: { validations: [positiveIntegerCondition] },

app/src/views/FieldReportForm/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useTranslation } from '@ifrc-go/ui/hooks';
2121
import {
2222
isDefined,
2323
isNotDefined,
24+
isTruthyString,
2425
listToGroupList,
2526
} from '@togglecorp/fujs';
2627
import {
@@ -210,7 +211,12 @@ export function Component() {
210211
: [],
211212
);
212213
setDistrictOptions(response?.districts_details);
213-
onValueSet(formValue);
214+
// NOTE: We are setting situationalOverviewConsented here because its only-client
215+
// value and if the field it filled it means that user consented to it
216+
onValueSet({
217+
...formValue,
218+
situationalOverviewConsented: isTruthyString(formValue.description),
219+
});
214220
},
215221
});
216222

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"parent": "000042-1754038716022.json",
3+
"actions": [
4+
{
5+
"action": "add",
6+
"key": "severityLevelUpdateDateLabel",
7+
"namespace": "emergencyDetails",
8+
"value": "Updated date"
9+
},
10+
{
11+
"action": "add",
12+
"key": "fieldReportFundamentalPrinciplesLabel",
13+
"namespace": "fieldReportForm",
14+
"value": "Fundamental Principles"
15+
},
16+
{
17+
"action": "add",
18+
"key": "fieldReportOverviewConsentLabel",
19+
"namespace": "fieldReportForm",
20+
"value": "All content published on IFRC platforms must adhere to the {fundamentalPrinciples} and align with the relevant Movement language and communications guidelines. Where content does not meet these standards, the IFRC will collaborate with the respective National Society to revise it accordingly."
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)