Skip to content

Commit d734e04

Browse files
committed
Fix rating visibility in the strategic priorities page
- Fix duplicate volunteers label in field report details page
1 parent 3fb2252 commit d734e04

File tree

4 files changed

+89
-42
lines changed

4 files changed

+89
-42
lines changed

.changeset/light-lies-flash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
- Fix duplication volunteer label in the Field Report details
6+
- Fix rating visibility in the Country > NS Overview > Strategic priorities page

app/src/views/CountryNsOverviewStrategicPriorities/index.tsx

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020

2121
import Link from '#components/Link';
2222
import WikiLink from '#components/WikiLink';
23+
import useCountry from '#hooks/domain/useCountry';
24+
import usePermissions from '#hooks/domain/usePermissions';
2325
import useDebouncedValue from '#hooks/useDebouncedValue';
2426
import { type CountryOutletContext } from '#utils/outletContext';
2527
import { useRequest } from '#utils/restRequest';
@@ -34,6 +36,20 @@ export function Component() {
3436
const { countryId, countryResponse } = useOutletContext<CountryOutletContext>();
3537
const strings = useTranslation(i18n);
3638

39+
const {
40+
isCountryPerAdmin,
41+
isSuperUser,
42+
isRegionPerAdmin,
43+
isGuestUser,
44+
} = usePermissions();
45+
46+
const countryDetails = useCountry({ id: Number(countryId) });
47+
const regionId = isDefined(countryDetails) ? Number(countryDetails?.region) : undefined;
48+
49+
const isPerAdmin = isSuperUser
50+
|| (!isGuestUser && isCountryPerAdmin(Number(countryId)))
51+
|| (!isGuestUser && isRegionPerAdmin(regionId));
52+
3753
const {
3854
pending: publicPerStatsPending,
3955
response: publicPerStatsResponse,
@@ -266,20 +282,34 @@ export function Component() {
266282
numPreferredGridContentColumns={5}
267283
>
268284
{strengthComponents?.map(
269-
(strengthComponent) => (
270-
<Container
271-
heading={strengthComponent?.component_details.title}
272-
headingLevel={5}
273-
key={strengthComponent.component}
274-
withHeaderBorder
275-
withInternalPadding
276-
icons={<CheckboxFillIcon className={styles.icon} />}
277-
withoutWrapInHeading
278-
className={styles.strengthComponent}
279-
>
280-
{strengthComponent?.rating_details?.title}
281-
</Container>
282-
),
285+
(strengthComponent) => {
286+
if (!isPerAdmin) {
287+
return (
288+
<Container
289+
key={strengthComponent.component}
290+
withInternalPadding
291+
className={styles.strengthComponent}
292+
>
293+
{strengthComponent?.component_details.title}
294+
</Container>
295+
);
296+
}
297+
298+
return (
299+
<Container
300+
heading={strengthComponent?.rating_details?.title}
301+
headingLevel={5}
302+
key={strengthComponent.component}
303+
withHeaderBorder
304+
withInternalPadding
305+
icons={<CheckboxFillIcon className={styles.icon} />}
306+
withoutWrapInHeading
307+
className={styles.strengthComponent}
308+
>
309+
{strengthComponent?.component_details.title}
310+
</Container>
311+
);
312+
},
283313
)}
284314
</Container>
285315
)}
@@ -291,20 +321,33 @@ export function Component() {
291321
numPreferredGridContentColumns={5}
292322
>
293323
{keyDevelopmentComponents?.map(
294-
(keyDevelopmentComponent) => (
295-
<Container
296-
heading={keyDevelopmentComponent?.component_details.title}
297-
headingLevel={5}
298-
key={keyDevelopmentComponent.component}
299-
withHeaderBorder
300-
withInternalPadding
301-
icons={<CheckboxFillIcon className={styles.icon} />}
302-
withoutWrapInHeading
303-
className={styles.priorityComponent}
304-
>
305-
{keyDevelopmentComponent?.rating_details?.title}
306-
</Container>
307-
),
324+
(keyDevelopmentComponent) => {
325+
if (!isPerAdmin) {
326+
return (
327+
<Container
328+
key={keyDevelopmentComponent.component}
329+
withInternalPadding
330+
className={styles.priorityComponent}
331+
>
332+
{keyDevelopmentComponent?.component_details.title}
333+
</Container>
334+
);
335+
}
336+
return (
337+
<Container
338+
heading={keyDevelopmentComponent?.rating_details?.title}
339+
headingLevel={5}
340+
key={keyDevelopmentComponent.component}
341+
withHeaderBorder
342+
withInternalPadding
343+
icons={<CheckboxFillIcon className={styles.icon} />}
344+
withoutWrapInHeading
345+
className={styles.priorityComponent}
346+
>
347+
{keyDevelopmentComponent?.component_details.title}
348+
</Container>
349+
);
350+
},
308351
)}
309352
</Container>
310353
)}

app/src/views/CountryPreparedness/PublicCountryPreparedness/index.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
Fragment,
32
useCallback,
43
useMemo,
54
} from 'react';
@@ -246,18 +245,17 @@ function PublicCountryPreparedness() {
246245
>
247246
{componentsToBeStrengthened.map(
248247
(priorityComponent) => (
249-
<Fragment key={priorityComponent.id}>
250-
<Heading
251-
className={styles.heading}
252-
level={5}
253-
>
254-
{getFormattedComponentName({
255-
component_num: priorityComponent.componentNumber,
256-
component_letter: priorityComponent.componentLetter,
257-
title: priorityComponent.label,
258-
})}
259-
</Heading>
260-
</Fragment>
248+
<Heading
249+
key={priorityComponent.id}
250+
className={styles.heading}
251+
level={5}
252+
>
253+
{getFormattedComponentName({
254+
component_num: priorityComponent.componentNumber,
255+
component_letter: priorityComponent.componentLetter,
256+
title: priorityComponent.label,
257+
})}
258+
</Heading>
261259
),
262260
)}
263261
</Container>

app/src/views/FieldReportDetails/EpidemicNumericDetails/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function EpidemicNumericDetails(props: Props) {
5050
value={value?.gov_num_assisted}
5151
/>
5252
<KeyFigure
53-
label={strings.epidemicVolunteersLabel}
53+
label={strings.epidemicLocalStaffLabel}
5454
value={value?.num_localstaff}
5555
/>
5656
<KeyFigure

0 commit comments

Comments
 (0)