Skip to content

Commit

Permalink
Fix rating visibility in the strategic priorities page
Browse files Browse the repository at this point in the history
- Fix duplicate volunteers label in field report details page
  • Loading branch information
frozenhelium committed Aug 20, 2024
1 parent 3fb2252 commit d734e04
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 42 deletions.
6 changes: 6 additions & 0 deletions .changeset/light-lies-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"go-web-app": patch
---

- Fix duplication volunteer label in the Field Report details
- Fix rating visibility in the Country > NS Overview > Strategic priorities page
99 changes: 71 additions & 28 deletions app/src/views/CountryNsOverviewStrategicPriorities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {

import Link from '#components/Link';
import WikiLink from '#components/WikiLink';
import useCountry from '#hooks/domain/useCountry';
import usePermissions from '#hooks/domain/usePermissions';
import useDebouncedValue from '#hooks/useDebouncedValue';
import { type CountryOutletContext } from '#utils/outletContext';
import { useRequest } from '#utils/restRequest';
Expand All @@ -34,6 +36,20 @@ export function Component() {
const { countryId, countryResponse } = useOutletContext<CountryOutletContext>();
const strings = useTranslation(i18n);

const {
isCountryPerAdmin,
isSuperUser,
isRegionPerAdmin,
isGuestUser,
} = usePermissions();

const countryDetails = useCountry({ id: Number(countryId) });
const regionId = isDefined(countryDetails) ? Number(countryDetails?.region) : undefined;

const isPerAdmin = isSuperUser
|| (!isGuestUser && isCountryPerAdmin(Number(countryId)))
|| (!isGuestUser && isRegionPerAdmin(regionId));

const {
pending: publicPerStatsPending,
response: publicPerStatsResponse,
Expand Down Expand Up @@ -266,20 +282,34 @@ export function Component() {
numPreferredGridContentColumns={5}
>
{strengthComponents?.map(
(strengthComponent) => (
<Container
heading={strengthComponent?.component_details.title}
headingLevel={5}
key={strengthComponent.component}
withHeaderBorder
withInternalPadding
icons={<CheckboxFillIcon className={styles.icon} />}
withoutWrapInHeading
className={styles.strengthComponent}
>
{strengthComponent?.rating_details?.title}
</Container>
),
(strengthComponent) => {
if (!isPerAdmin) {
return (
<Container
key={strengthComponent.component}
withInternalPadding
className={styles.strengthComponent}
>
{strengthComponent?.component_details.title}
</Container>
);
}

return (
<Container
heading={strengthComponent?.rating_details?.title}
headingLevel={5}
key={strengthComponent.component}
withHeaderBorder
withInternalPadding
icons={<CheckboxFillIcon className={styles.icon} />}
withoutWrapInHeading
className={styles.strengthComponent}
>
{strengthComponent?.component_details.title}
</Container>
);
},
)}
</Container>
)}
Expand All @@ -291,20 +321,33 @@ export function Component() {
numPreferredGridContentColumns={5}
>
{keyDevelopmentComponents?.map(
(keyDevelopmentComponent) => (
<Container
heading={keyDevelopmentComponent?.component_details.title}
headingLevel={5}
key={keyDevelopmentComponent.component}
withHeaderBorder
withInternalPadding
icons={<CheckboxFillIcon className={styles.icon} />}
withoutWrapInHeading
className={styles.priorityComponent}
>
{keyDevelopmentComponent?.rating_details?.title}
</Container>
),
(keyDevelopmentComponent) => {
if (!isPerAdmin) {
return (
<Container
key={keyDevelopmentComponent.component}
withInternalPadding
className={styles.priorityComponent}
>
{keyDevelopmentComponent?.component_details.title}
</Container>
);
}
return (
<Container
heading={keyDevelopmentComponent?.rating_details?.title}
headingLevel={5}
key={keyDevelopmentComponent.component}
withHeaderBorder
withInternalPadding
icons={<CheckboxFillIcon className={styles.icon} />}
withoutWrapInHeading
className={styles.priorityComponent}
>
{keyDevelopmentComponent?.component_details.title}
</Container>
);
},
)}
</Container>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Fragment,
useCallback,
useMemo,
} from 'react';
Expand Down Expand Up @@ -246,18 +245,17 @@ function PublicCountryPreparedness() {
>
{componentsToBeStrengthened.map(
(priorityComponent) => (
<Fragment key={priorityComponent.id}>
<Heading
className={styles.heading}
level={5}
>
{getFormattedComponentName({
component_num: priorityComponent.componentNumber,
component_letter: priorityComponent.componentLetter,
title: priorityComponent.label,
})}
</Heading>
</Fragment>
<Heading
key={priorityComponent.id}
className={styles.heading}
level={5}
>
{getFormattedComponentName({
component_num: priorityComponent.componentNumber,
component_letter: priorityComponent.componentLetter,
title: priorityComponent.label,
})}
</Heading>
),
)}
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function EpidemicNumericDetails(props: Props) {
value={value?.gov_num_assisted}
/>
<KeyFigure
label={strings.epidemicVolunteersLabel}
label={strings.epidemicLocalStaffLabel}
value={value?.num_localstaff}
/>
<KeyFigure
Expand Down

0 comments on commit d734e04

Please sign in to comment.