Skip to content

Commit 3f076f6

Browse files
authored
Merge pull request #278 from IFRCGo/fix/per-calculation
Fix PER calculation
2 parents 663c518 + cac48eb commit 3f076f6

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

src/components/domain/PerAssessmentSummary/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function PerAssessmentSummary(props: Props) {
141141
const filteredComponents = areaResponse?.component_responses?.filter(
142142
(component) => isDefined(component?.rating_details)
143143
&& isDefined(component.rating_details.value)
144-
&& component.rating_details?.value > 1,
144+
&& component.rating_details?.value !== 0,
145145
) ?? [];
146146

147147
if (filteredComponents.length === 0) {

src/views/CountryPreparedness/index.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '@togglecorp/fujs';
1717

1818
import Button from '#components/Button';
19+
import BlockLoading from '#components/BlockLoading';
1920
import Container from '#components/Container';
2021
import Heading from '#components/Heading';
2122
import KeyFigure from '#components/KeyFigure';
@@ -196,7 +197,7 @@ export function Component() {
196197
*/
197198
const filteredComponents = componentList.filter(
198199
(component) => isDefined(component)
199-
&& isDefined(component.rating) && component.rating.value > 1,
200+
&& isDefined(component.rating) && component.rating.value !== 0,
200201
);
201202

202203
const ratingByArea = mapToList(
@@ -335,15 +336,25 @@ export function Component() {
335336
&& perOptionsResponse
336337
&& perFormAreaResponse;
337338

338-
const pending = pendingLatestPerResponse
339-
|| formAnswerPending
339+
const pending = formAnswerPending
340340
|| perOptionsPending
341341
|| perFormAreaPending
342342
|| perProcessStatusPending
343343
|| assessmentResponsePending
344344
|| prioritizationResponsePending;
345345

346-
if (isNotDefined(countryId) || (!pending && isDefined(latestPerResponseError))) {
346+
if (pendingLatestPerResponse) {
347+
return (
348+
<Message
349+
className={styles.pendingMessage}
350+
pending
351+
description={strings.componentFetchingData}
352+
/>
353+
);
354+
}
355+
356+
if (isNotDefined(countryId)
357+
|| (!pendingLatestPerResponse && isDefined(latestPerResponseError))) {
347358
return (
348359
<Message
349360
className={styles.countryPreparedness}
@@ -365,16 +376,6 @@ export function Component() {
365376
);
366377
}
367378

368-
if (pending) {
369-
return (
370-
<Message
371-
className={styles.pendingMessage}
372-
pending
373-
description={strings.componentFetchingData}
374-
/>
375-
);
376-
}
377-
378379
return (
379380
<Container
380381
className={styles.countryPreparedness}
@@ -434,6 +435,9 @@ export function Component() {
434435
</Link>
435436
</div>
436437
</div>
438+
{pending && (
439+
<BlockLoading className={styles.pendingMessage} />
440+
)}
437441
{hasRatingCounts && (
438442
<Container
439443
heading={strings.perAssessmentHeading}
@@ -480,7 +484,7 @@ export function Component() {
480484
/>
481485
</Container>
482486
)}
483-
{hasPrevAssessments && (
487+
{!pending && hasPrevAssessments && (
484488
<Container
485489
heading={strings.NSResponseHeading}
486490
withHeaderBorder
@@ -581,15 +585,15 @@ export function Component() {
581585
)}
582586
</Container>
583587
)}
584-
{!limitedAccess && !hasAssessmentStats && (
588+
{!pending && !limitedAccess && !hasAssessmentStats && (
585589
<Message
586590
className={styles.emptyMessage}
587591
icon={<AnalyzingIcon />}
588592
title={strings.componentChartNotAvailable}
589593
description={strings.componentChartNotAvailableDescription}
590594
/>
591595
)}
592-
{limitedAccess && (
596+
{!pending && limitedAccess && (
593597
<div className={styles.limitedAccess}>
594598
<PublicCountryPreparedness perId={perId} />
595599
<Message

0 commit comments

Comments
 (0)