Skip to content

Commit e13838e

Browse files
authored
Merge pull request #509 from IFRCGo/fix/dref-application-imminent
Fix/dref application imminent
2 parents 544c624 + 7ce11d0 commit e13838e

File tree

8 files changed

+82
-18
lines changed

8 files changed

+82
-18
lines changed

src/components/domain/PerAssessmentSummary/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ function PerAssessmentSummary(props: Props) {
135135
areaResponses ?? [],
136136
(areaResponse) => areaResponse?.area ?? -1,
137137
(areaResponse) => {
138-
/* NOTE: The calculation of the average rating is done omitting null or
139-
* "0"(not - reviewed") component values
140-
*/
138+
// NOTE: do we take the average of only rated components or of all the
139+
// components?
141140
const filteredComponents = areaResponse?.component_responses?.filter(
142141
(component) => isDefined(component?.rating_details)
143142
&& isDefined(component.rating_details.value)

src/utils/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export const DREF_TYPE_ASSESSMENT = 1 satisfies TypeOfDrefEnum;
9797
export const DREF_TYPE_RESPONSE = 2 satisfies TypeOfDrefEnum;
9898
export const DREF_TYPE_LOAN = 3 satisfies TypeOfDrefEnum;
9999

100+
type TypeOfOnsetEnum = components<'read'>['schemas']['TypeValidatedEnum'];
101+
export const ONSET_SLOW = 1 satisfies TypeOfOnsetEnum;
102+
100103
// Subscriptions
101104
type SubscriptionRecordTypeEnum = components<'read'>['schemas']['RtypeEnum'];
102105
export const SUBSCRIPTION_SURGE_ALERT = 3 satisfies SubscriptionRecordTypeEnum;

src/views/DrefApplicationExport/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"eventDescriptionSectionHeading": "Description of the Event",
2626
"approximateDateOfImpactHeading": "Approximate date of impact",
2727
"whatWhereWhenSectionHeading": "What happened, where and when?",
28-
"dateWhenTheTriggerWasMetHeading": "Date of event / Date when the trigger was met",
28+
"dateOfEventSlowHeading": "Date of event",
29+
"dateWhenTriggerWasMetHeading": "Date when the trigger was met",
2930
"situationUpdateSectionHeading": "Provide any updates in the situation since the field report and explain what is expected to happen.",
3031
"anticipatoryActionsHeading": "Why your National Society is acting now and what criteria is used to launch this operation.",
3132
"scopeAndScaleSectionHeading": "Scope and Scale",

src/views/DrefApplicationExport/index.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
DISASTER_CATEGORY_YELLOW,
2424
DREF_TYPE_ASSESSMENT,
2525
DREF_TYPE_IMMINENT,
26+
ONSET_SLOW,
2627
DisasterCategory,
2728
} from '#utils/constants';
2829
import {
@@ -179,11 +180,14 @@ export function Component() {
179180
&& isTruthyString(drefResponse?.anticipatory_actions?.trim());
180181
const eventDateDefined = drefResponse?.type_of_dref !== DREF_TYPE_IMMINENT
181182
&& isDefined(drefResponse?.event_date);
183+
const eventTextDefined = drefResponse?.type_of_dref === DREF_TYPE_IMMINENT
184+
&& isDefined(drefResponse?.event_text);
182185
const showEventDescriptionSection = eventDescriptionDefined
183186
|| eventScopeDefined
184187
|| imagesFileDefined
185188
|| anticipatoryActionsDefined
186189
|| eventDateDefined
190+
|| eventTextDefined
187191
|| isDefined(drefResponse?.event_map_file?.file);
188192

189193
const lessonsLearnedDefined = isTruthyString(drefResponse?.lessons_learned?.trim());
@@ -478,18 +482,24 @@ export function Component() {
478482
</Link>
479483
</Container>
480484
)}
481-
{isDefined(drefResponse)
482-
&& drefResponse.type_of_dref === DREF_TYPE_IMMINENT
483-
&& isTruthyString(drefResponse.event_text) && (
484-
<Container
485-
heading={strings.approximateDateOfImpactHeading}
486-
headingLevel={3}
487-
>
485+
{eventTextDefined && (
486+
<Container heading={strings.approximateDateOfImpactHeading}>
488487
<DescriptionText>
489488
{drefResponse.event_text}
490489
</DescriptionText>
491490
</Container>
492491
)}
492+
{eventDateDefined && (
493+
<Container
494+
heading={drefResponse?.type_of_onset === ONSET_SLOW
495+
? strings.dateWhenTriggerWasMetHeading
496+
: strings.dateOfEventSlowHeading}
497+
>
498+
<DateOutput
499+
value={drefResponse?.event_date}
500+
/>
501+
</Container>
502+
)}
493503
{isTruthyString(drefResponse?.event_map_file?.file) && (
494504
<Container>
495505
<Image
@@ -498,13 +508,6 @@ export function Component() {
498508
/>
499509
</Container>
500510
)}
501-
{eventDateDefined && (
502-
<Container heading={strings.dateWhenTheTriggerWasMetHeading}>
503-
<DateOutput
504-
value={drefResponse?.event_date}
505-
/>
506-
</Container>
507-
)}
508511
{eventDescriptionDefined && (
509512
<Container
510513
heading={drefResponse?.type_of_dref === DREF_TYPE_IMMINENT

src/views/DrefFinalReportExport/i18n.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
"additionalAllocationRequestedLabel": "Additional Allocation Requested",
2626
"targetedAreasLabel": "Targeted Areas",
2727
"eventDescriptionSectionHeading": "Description of the Event",
28+
"approximateDateOfImpactHeading": "Approximate date of impact",
2829
"whatWhereWhenSectionHeading": "What happened, where and when?",
30+
"dateOfEventSlowHeading": "Date of event",
31+
"dateWhenTriggerWasMetHeading": "Date when the trigger was met",
32+
2933
"situationUpdateSectionHeading": "Provide any updates in the situation since the field report and explain what is expected to happen.",
3034
"anticipatoryActionsHeading": "Why your National Society is acting now and what criteria is used to launch this operation.",
3135
"scopeAndScaleSectionHeading": "Scope and Scale",

src/views/DrefFinalReportExport/index.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Image from '#components/printable/Image';
1414
import Heading from '#components/printable/Heading';
1515
import Link from '#components/printable/Link';
1616

17+
import DateOutput from '#components/DateOutput';
1718
import DescriptionText from '#components/printable/DescriptionText';
1819
import NumberOutput from '#components/NumberOutput';
1920
import useTranslation from '#hooks/useTranslation';
@@ -25,6 +26,7 @@ import {
2526
DREF_TYPE_ASSESSMENT,
2627
DREF_TYPE_IMMINENT,
2728
DisasterCategory,
29+
ONSET_SLOW,
2830
} from '#utils/constants';
2931
import {
3032
identifiedNeedsAndGapsOrder,
@@ -144,9 +146,15 @@ export function Component() {
144146
const imagesFileDefined = isDefined(drefResponse)
145147
&& isDefined(drefResponse.images_file)
146148
&& drefResponse.images_file.length > 0;
149+
const eventDateDefined = drefResponse?.type_of_dref !== DREF_TYPE_IMMINENT
150+
&& isDefined(drefResponse?.event_date);
151+
const eventTextDefined = drefResponse?.type_of_dref === DREF_TYPE_IMMINENT
152+
&& isDefined(drefResponse?.event_text);
147153
const showEventDescriptionSection = eventDescriptionDefined
148154
|| eventScopeDefined
149155
|| imagesFileDefined
156+
|| eventDateDefined
157+
|| eventTextDefined
150158
|| isDefined(drefResponse?.event_map_file?.file);
151159

152160
const ifrcActionsDefined = isTruthyString(drefResponse?.ifrc?.trim());
@@ -394,6 +402,24 @@ export function Component() {
394402
/>
395403
</Container>
396404
)}
405+
{eventTextDefined && (
406+
<Container heading={strings.approximateDateOfImpactHeading}>
407+
<DescriptionText>
408+
{drefResponse.event_text}
409+
</DescriptionText>
410+
</Container>
411+
)}
412+
{eventDateDefined && (
413+
<Container
414+
heading={drefResponse?.type_of_onset === ONSET_SLOW
415+
? strings.dateWhenTriggerWasMetHeading
416+
: strings.dateOfEventSlowHeading}
417+
>
418+
<DateOutput
419+
value={drefResponse?.event_date}
420+
/>
421+
</Container>
422+
)}
397423
{eventDescriptionDefined && (
398424
<Container
399425
heading={drefResponse?.type_of_dref === DREF_TYPE_IMMINENT

src/views/DrefOperationalUpdateExport/i18n.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
"situationUpdateSectionHeading": "Provide any updates in the situation since the field report and explain what is expected to happen.",
3030
"anticipatoryActionsHeading": "Why your National Society is acting now and what criteria is used to launch this operation.",
3131
"scopeAndScaleSectionHeading": "Scope and Scale",
32+
"approximateDateOfImpactHeading": "Approximate date of impact",
33+
"dateOfEventSlowHeading": "Date of event",
34+
"dateWhenTriggerWasMetHeading": "Date when the trigger was met",
3235

3336
"summaryOfChangesSectionHeading": "Summary of Changes",
3437
"changingTimeFrameLabel":"Are you changing the timeframe of the operation",

src/views/DrefOperationalUpdateExport/index.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
DISASTER_CATEGORY_YELLOW,
2626
DREF_TYPE_ASSESSMENT,
2727
DREF_TYPE_IMMINENT,
28+
ONSET_SLOW,
2829
DisasterCategory,
2930
} from '#utils/constants';
3031
import {
@@ -163,12 +164,18 @@ export function Component() {
163164
const imagesFileDefined = isDefined(drefResponse)
164165
&& isDefined(drefResponse.images_file)
165166
&& drefResponse.images_file.length > 0;
167+
const eventDateDefined = drefResponse?.type_of_dref !== DREF_TYPE_IMMINENT
168+
&& isDefined(drefResponse?.event_date);
169+
const eventTextDefined = drefResponse?.type_of_dref === DREF_TYPE_IMMINENT
170+
&& isDefined(drefResponse?.event_text);
166171
const anticipatoryActionsDefined = drefResponse?.type_of_dref === DREF_TYPE_IMMINENT
167172
&& isTruthyString(drefResponse?.anticipatory_actions?.trim());
168173
const showEventDescriptionSection = eventDescriptionDefined
169174
|| eventScopeDefined
170175
|| imagesFileDefined
171176
|| anticipatoryActionsDefined
177+
|| eventDateDefined
178+
|| eventTextDefined
172179
|| isDefined(drefResponse?.event_map_file?.file);
173180

174181
const ifrcActionsDefined = isTruthyString(drefResponse?.ifrc?.trim());
@@ -458,6 +465,24 @@ export function Component() {
458465
/>
459466
</Container>
460467
)}
468+
{eventTextDefined && (
469+
<Container heading={strings.approximateDateOfImpactHeading}>
470+
<DescriptionText>
471+
{drefResponse.event_text}
472+
</DescriptionText>
473+
</Container>
474+
)}
475+
{eventDateDefined && (
476+
<Container
477+
heading={drefResponse?.type_of_onset === ONSET_SLOW
478+
? strings.dateWhenTriggerWasMetHeading
479+
: strings.dateOfEventSlowHeading}
480+
>
481+
<DateOutput
482+
value={drefResponse?.event_date}
483+
/>
484+
</Container>
485+
)}
461486
{eventDescriptionDefined && (
462487
<Container
463488
heading={drefResponse?.type_of_dref === DREF_TYPE_IMMINENT

0 commit comments

Comments
 (0)