Skip to content

Commit

Permalink
Add consideration guildance for all per components
Browse files Browse the repository at this point in the history
  • Loading branch information
barshathakuri committed Sep 13, 2024
1 parent 886317c commit a34a362
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function primaryBlueColorShadeselector(_: unknown, i: number) {
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
const noOp = () => {};
const noOp = () => { };

// eslint-disable-next-line import/prefer-default-export
function PrivateCountryPreparedness() {
Expand Down Expand Up @@ -453,6 +453,14 @@ function PrivateCountryPreparedness() {
[countryId, perId],
);

const topRatedComponentsByArea = assessmentStats?.topRatedComponents?.reduce(
(acc, component) => {
acc[component.area.area_num] = component;
return acc;
},
{},
);

return (
<Container
className={styles.privateCountryPreparedness}
Expand Down Expand Up @@ -664,9 +672,7 @@ function PrivateCountryPreparedness() {
</Heading>
<div className={styles.separator} />
{Object.entries(areaColorShades).map(([areaNum, color]) => {
const area = assessmentStats?.topRatedComponents.find(
(component) => component.area.area_num === Number(areaNum),
);
const area = topRatedComponentsByArea?.[Number(areaNum)];

if (!area) {
return null;
Expand All @@ -675,7 +681,7 @@ function PrivateCountryPreparedness() {
return (
<LegendItem
key={areaNum}
label={`${strings.areaLegend} ${areaNum}
label={`${strings.areaLegend} ${areaNum}
${getFormattedComponentName(area.area)}`}
color={color}
/>
Expand Down
18 changes: 7 additions & 11 deletions app/src/views/PerAssessmentForm/AreaInput/ComponentInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,7 @@ function ComponentInput(props: Props) {
withoutPadding
title={strings.epiConsiderationTitle}
description={(
<ul className={styles.description}>
<li>
<HtmlOutput value={value?.epi_considerations_guidance} />
</li>
</ul>
<HtmlOutput value={component?.epi_considerations_guidance} />
)}
>
<TextArea
Expand All @@ -305,7 +301,9 @@ function ComponentInput(props: Props) {
<InputSection
withoutPadding
title={strings.urbanConsiderationTitle}
description={value?.urban_considerations_guidance}
description={(
<HtmlOutput value={component?.urban_considerations_guidance} />
)}
>
<TextArea
name="urban_considerations"
Expand All @@ -323,11 +321,9 @@ function ComponentInput(props: Props) {
withoutPadding
title={strings.environmentConsiderationTitle}
description={(
<ul className={styles.description}>
<li>
{value?.climate_environmental_considerations_guidance}
</li>
</ul>
<HtmlOutput
value={component?.climate_environmental_considerations_guidance}
/>
)}
>
<TextArea
Expand Down
14 changes: 10 additions & 4 deletions app/src/views/PerExport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ export function Component() {
|| assessmentResponsePending
|| perFetching;

const topRatedComponentsByArea = assessmentStats?.topRatedComponents?.reduce(
(acc, component) => {
acc[component.area.area_num] = component;
return acc;
},
{},
);

return (
<div className={styles.perExport}>
<Container childrenContainerClassName={styles.pageTitleSection}>
Expand Down Expand Up @@ -558,9 +566,7 @@ export function Component() {
{strings.typeOfOperation}
</Heading>
{Object.entries(areaColorShades).map(([areaNum, color]) => {
const area = assessmentStats?.topRatedComponents.find(
(component) => component.area.area_num === Number(areaNum),
);
const area = topRatedComponentsByArea?.[Number(areaNum)];

if (!area) {
return null;
Expand All @@ -569,7 +575,7 @@ export function Component() {
return (
<LegendItem
key={areaNum}
label={`${strings.areaLegend} ${areaNum}
label={`${strings.areaLegend} ${areaNum}
${getFormattedComponentName(area.area)}`}
color={color}
/>
Expand Down

0 comments on commit a34a362

Please sign in to comment.