Skip to content

Commit

Permalink
feat: show latest strategic plan under strategic priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara committed Apr 26, 2024
1 parent 92260f8 commit 300250a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-swans-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"go-web-app": minor
---

Show latest strategic plan of National Society under Strategic Priorities
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"strings": {
"nsStrategicPrioritiesHeading": "NS Strategic Priorities",
"countryPlanPeopleTargeted": "People Targeted",
"strategicPlan": "NS Strategic Plan ({year})",
"countryPlan": "IFRC Network Plan",
"countryPlanInternal": "Unified Plan",
"countryPlanKeyFigureRequestedAmount": "Federation-Wide Requested Amount (CHF)",
Expand Down
33 changes: 32 additions & 1 deletion app/src/views/CountryNsOverviewStrategicPriorities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TextOutput,
} from '@ifrc-go/ui';
import { useTranslation } from '@ifrc-go/ui/hooks';
import { resolveToString } from '@ifrc-go/ui/utils';
import {
compareNumber,
isDefined,
Expand Down Expand Up @@ -141,13 +142,27 @@ export function Component() {
},
});

const {
response: documentResponse,
pending: documentResponsePending,
} = useRequest({
url: '/api/v2/country-document/',
skip: isNotDefined(countryId),
query: {
country: isDefined(countryId) ? Number(countryId) : undefined,
document_type: 'Our Strategic Plan',
ordering: '-end_year',
},
preserveResponse: true,
});

const hasStrengthComponents = isDefined(strengthComponents) && strengthComponents.length > 0;
const hasKeyDevelopmentComponents = isDefined(keyDevelopmentComponents)
&& keyDevelopmentComponents.length > 0;
const perContentsDefined = hasStrengthComponents || hasKeyDevelopmentComponents;

const hasCountryPlan = countryResponse?.has_country_plan;
const pending = useDebouncedValue(countryPlanPending || perPending);
const pending = useDebouncedValue(countryPlanPending || perPending || documentResponsePending);

return (
<Container
Expand Down Expand Up @@ -175,6 +190,22 @@ export function Component() {
>
<div className={styles.downloadLinksAndKeyFigures}>
<div className={styles.countryPlanDownloadLink}>
{(documentResponse?.results?.length ?? 0) > 0 && (
<Link
variant="secondary"
href={documentResponse?.results?.[0].url}
external
className={styles.downloadLink}
icons={<DownloadLineIcon className={styles.icon} />}
>
{resolveToString(
strings.strategicPlan,
{
year: documentResponse?.results?.[0].year_text,
},
)}
</Link>
)}
{isDefined(countryPlanResponse.public_plan_file) && (
<Link
variant="secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"currentYearTooltipLabel": "Year {currentYear}",
"averageTooltipLabel": "Average (2003-{currentYear})",
"minMaxLabel": "Min-Max (2003-{currentYear})",
"source": "Source",
"sourceLabel": "Source",
"ifrcMontandon": "IFRC Montandon, Global Crisis Data Bank"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function RiskBarChart(props: Props) {
withGridViewInFilter
footerActions={(
<TextOutput
label={strings.source}
label={strings.sourceLabel}
value={strings.ifrcMontandon}
strongValue
/>
Expand Down

0 comments on commit 300250a

Please sign in to comment.