From 300250a1f5940f13f681a0e983eb106eac3ce846 Mon Sep 17 00:00:00 2001 From: samshara Date: Thu, 25 Apr 2024 17:34:19 +0545 Subject: [PATCH] feat: show latest strategic plan under strategic priorities --- .changeset/new-swans-draw.md | 5 +++ .../i18n.json | 1 + .../index.tsx | 33 ++++++++++++++++++- .../RiskBarChart/i18n.json | 2 +- .../RiskBarChart/index.tsx | 2 +- 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .changeset/new-swans-draw.md diff --git a/.changeset/new-swans-draw.md b/.changeset/new-swans-draw.md new file mode 100644 index 000000000..68385e080 --- /dev/null +++ b/.changeset/new-swans-draw.md @@ -0,0 +1,5 @@ +--- +"go-web-app": minor +--- + +Show latest strategic plan of National Society under Strategic Priorities diff --git a/app/src/views/CountryNsOverviewStrategicPriorities/i18n.json b/app/src/views/CountryNsOverviewStrategicPriorities/i18n.json index 279175d34..7df383b36 100644 --- a/app/src/views/CountryNsOverviewStrategicPriorities/i18n.json +++ b/app/src/views/CountryNsOverviewStrategicPriorities/i18n.json @@ -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)", diff --git a/app/src/views/CountryNsOverviewStrategicPriorities/index.tsx b/app/src/views/CountryNsOverviewStrategicPriorities/index.tsx index 5e97994c5..567a60685 100644 --- a/app/src/views/CountryNsOverviewStrategicPriorities/index.tsx +++ b/app/src/views/CountryNsOverviewStrategicPriorities/index.tsx @@ -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, @@ -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 (
+ {(documentResponse?.results?.length ?? 0) > 0 && ( + } + > + {resolveToString( + strings.strategicPlan, + { + year: documentResponse?.results?.[0].year_text, + }, + )} + + )} {isDefined(countryPlanResponse.public_plan_file) && (