From b4af4c0e2ee0f5fa255374c5b6cb1a327629976c Mon Sep 17 00:00:00 2001 From: puranban Date: Thu, 7 Dec 2023 10:40:49 +0545 Subject: [PATCH 1/7] Add sorted action list in application export --- src/views/DrefApplicationExport/index.tsx | 238 +++++++++++++++------- 1 file changed, 160 insertions(+), 78 deletions(-) diff --git a/src/views/DrefApplicationExport/index.tsx b/src/views/DrefApplicationExport/index.tsx index 897796d4b..ab0c20ade 100644 --- a/src/views/DrefApplicationExport/index.tsx +++ b/src/views/DrefApplicationExport/index.tsx @@ -1,4 +1,4 @@ -import { Fragment, useState } from 'react'; +import { Fragment, useMemo, useState } from 'react'; import { useParams } from 'react-router-dom'; import { _cs, @@ -14,6 +14,7 @@ import Heading from '#components/printable/Heading'; import DescriptionText from '#components/printable/DescriptionText'; import Link from '#components/Link'; import DateOutput from '#components/DateOutput'; +import { components } from '#generated/types'; import useTranslation from '#hooks/useTranslation'; import { useRequest } from '#utils/restRequest'; import { @@ -30,6 +31,10 @@ import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; import styles from './styles.module.css'; +type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; +type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; +type NsActions = components<'read'>['schemas']['NationalSocietyAction']; + function BlockTextOutput(props: TextOutputProps & { variant?: never, withoutLabelColon?: never }) { return ( = { [DISASTER_CATEGORY_RED]: styles.red, }; +const plannedInterventionSortedList = [ + 'shelter_housing_and_settlements', + 'livelihoods_and_basic_needs', + 'multi-purpose_cash', + 'health', + 'water_sanitation_and_hygiene', + 'protection_gender_and_inclusion', + 'education', + 'migration', + 'risk_reduction_climate_adaptation_and_recovery_', + 'community_engagement_and_accountability', + 'environmental_sustainability', + 'coordination_and_partnerships', + 'secretariat_services', + 'national_society_strengthening', +] satisfies (PlannedIntervention['title'])[]; + +const identifiedNeedsAndGapsSortedList = [ + 'shelter_housing_and_settlements', + 'livelihoods_and_basic_needs', + 'multi_purpose_cash_grants', + 'health', + 'water_sanitation_and_hygiene', + 'protection_gender_and_inclusion', + 'education', + 'migration', + 'risk_reduction_climate_adaptation_and_recovery', + 'community_engagement_and _accountability', + 'environment_sustainability ', +] satisfies (IdentifiedNeedsAndGaps['title'])[]; + +const nsActionsSortedList = [ + 'shelter_housing_and_settlements', + 'livelihoods_and_basic_needs', + 'multi-purpose_cash', + 'health', + 'water_sanitation_and_hygiene', + 'protection_gender_and_inclusion', + 'education', + 'migration', + 'risk_reduction_climate_adaptation_and_recovery', + 'community_engagement_and _accountability', + 'environment_sustainability ', + 'coordination', + 'national_society_readiness', + 'assessment', + 'resource_mobilization', + 'activation_of_contingency_plans', + 'national_society_eoc', + 'other', +] satisfies (NsActions['title'])[]; + // eslint-disable-next-line import/prefer-default-export export function Component() { const { drefId } = useParams<{ drefId: string }>(); @@ -96,6 +153,30 @@ export function Component() { }, }); + const sortedPlannedInterventions = useMemo( + () => drefResponse?.planned_interventions?.sort((a, b) => ( + // eslint-disable-next-line max-len + plannedInterventionSortedList.indexOf(a.title) - plannedInterventionSortedList.indexOf(b.title) + )), + [drefResponse?.planned_interventions], + ); + + const sortedIdentifiedNeedsAndGaps = useMemo( + () => drefResponse?.needs_identified?.sort((a, b) => ( + // eslint-disable-next-line max-len + identifiedNeedsAndGapsSortedList.indexOf(a.title) - identifiedNeedsAndGapsSortedList.indexOf(b.title) + )), + [drefResponse?.identified_gaps], + ); + + const sortedNsActions = useMemo( + () => drefResponse?.national_society_actions?.sort((a, b) => ( + // eslint-disable-next-line max-len + nsActionsSortedList.indexOf(a.title) - nsActionsSortedList.indexOf(b.title) + )), + [drefResponse?.national_society_actions], + ); + const eventDescriptionDefined = isTruthyString(drefResponse?.event_description?.trim()); const eventScopeDefined = drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && isTruthyString(drefResponse?.event_scope?.trim()); @@ -127,7 +208,8 @@ export function Component() { const showNsAction = isDefined(drefResponse) && isDefined(drefResponse.national_society_actions) - && drefResponse.national_society_actions.length > 0; + && drefResponse.national_society_actions.length > 0 + && isDefined(sortedNsActions); const icrcActionsDefined = isTruthyString(drefResponse?.icrc?.trim()); @@ -148,7 +230,9 @@ export function Component() { && isTruthyString(drefResponse?.identified_gaps?.trim()); const needsIdentifiedDefined = isDefined(drefResponse) && isDefined(drefResponse.needs_identified) - && drefResponse.needs_identified.length > 0; + && drefResponse.needs_identified.length > 0 + && isDefined(sortedIdentifiedNeedsAndGaps); + const showNeedsIdentifiedSection = isDefined(drefResponse) && drefResponse.type_of_dref !== DREF_TYPE_ASSESSMENT && (identifiedGapsDefined || needsIdentifiedDefined); @@ -169,7 +253,8 @@ export function Component() { const plannedInterventionDefined = isDefined(drefResponse) && isDefined(drefResponse.planned_interventions) - && drefResponse.planned_interventions.length > 0; + && drefResponse.planned_interventions.length > 0 + && isDefined(sortedPlannedInterventions); const humanResourceDefined = isTruthyString(drefResponse?.human_resource?.trim()); const surgePersonnelDeployedDefined = isTruthyString( @@ -232,7 +317,6 @@ export function Component() { || projectManagerContactDefined || focalPointContactDefined || mediaContactDefined; - return (
@@ -574,7 +658,7 @@ export function Component() { - {drefResponse?.national_society_actions?.map( + {sortedNsActions?.map( (nsAction) => ( - {needsIdentifiedDefined && drefResponse?.needs_identified?.map( + + {strings.needsIdentifiedSectionHeading} + + {needsIdentifiedDefined && sortedIdentifiedNeedsAndGaps?.map( (identifiedNeed) => ( - - {strings.needsIdentifiedSectionHeading} - {strings.plannedInterventionSectionHeading} - {drefResponse?.planned_interventions?.map( - (plannedIntervention) => ( - - - - {plannedIntervention.title_display} - - - - - - - -
- {strings.indicatorTitleLabel} -
-
- {strings.indicatorTargetLabel} -
- {plannedIntervention.indicators?.map( - (indicator) => ( - - ), - )} -
- - - {plannedIntervention.description} - - -
- ), - )} + {sortedPlannedInterventions?.map((plannedIntervention) => ( + + + + {plannedIntervention.title_display} + + + + + + + +
+ {strings.indicatorTitleLabel} +
+
+ {strings.indicatorTargetLabel} +
+ {plannedIntervention.indicators?.map( + (indicator) => ( + + ), + )} +
+ + + {plannedIntervention.description} + + +
+ ))} )} {showAboutSupportServicesSection && ( From 0095d9c7bd2f36d9cbebc286fd88feedaa4ea04f Mon Sep 17 00:00:00 2001 From: puranban Date: Thu, 7 Dec 2023 11:07:32 +0545 Subject: [PATCH 2/7] Add has children sagfeguarding field in all DREF modules form --- src/views/DrefApplicationForm/Operation/i18n.json | 1 + src/views/DrefApplicationForm/Operation/index.tsx | 10 ++++++++++ src/views/DrefApplicationForm/schema.ts | 2 ++ src/views/DrefFinalReportForm/Operation/i18n.json | 1 + src/views/DrefFinalReportForm/Operation/index.tsx | 10 ++++++++++ src/views/DrefFinalReportForm/schema.ts | 1 + .../DrefOperationalUpdateForm/Operation/i18n.json | 1 + .../DrefOperationalUpdateForm/Operation/index.tsx | 10 ++++++++++ src/views/DrefOperationalUpdateForm/schema.ts | 2 ++ 9 files changed, 38 insertions(+) diff --git a/src/views/DrefApplicationForm/Operation/i18n.json b/src/views/DrefApplicationForm/Operation/i18n.json index 57cdb0ce4..ef0a2de51 100644 --- a/src/views/DrefApplicationForm/Operation/i18n.json +++ b/src/views/DrefApplicationForm/Operation/i18n.json @@ -18,6 +18,7 @@ "drefFormRiskSecurityPotentialRisk": "Please indicate about potential operational risk for this operations and mitigation actions", "drefFormRiskSecurityPotentialRiskDescription": "Please consider any possible challenges to conduct the assessment, any possible limitations in getting the information required and overall risk to the implementation", "drefFormRiskSecuritySafetyConcern": "Please indicate any security and safety concerns for this operation", + "drefFormRiskSecurityHasChildRiskCompleted": "Has the child safeguarding risk analysis assessment been completed?", "drefFormSelectionCriteria": "Explain the selection criteria for the targeted population", "drefFormSelectionCriteriaDescription": "Explain the rational and logic behind which groups are being targeted and why and address vulnerable groups", "drefFormSupportServices": "About Support Services", diff --git a/src/views/DrefApplicationForm/Operation/index.tsx b/src/views/DrefApplicationForm/Operation/index.tsx index 3685615bf..961436a59 100644 --- a/src/views/DrefApplicationForm/Operation/index.tsx +++ b/src/views/DrefApplicationForm/Operation/index.tsx @@ -425,6 +425,16 @@ function Operation(props: Props) { disabled={disabled} /> + + +
n.client_id, diff --git a/src/views/DrefFinalReportForm/Operation/i18n.json b/src/views/DrefFinalReportForm/Operation/i18n.json index 35a7dd77d..4780d1e4f 100644 --- a/src/views/DrefFinalReportForm/Operation/i18n.json +++ b/src/views/DrefFinalReportForm/Operation/i18n.json @@ -22,6 +22,7 @@ "drefFormRiskSecurityPotentialRisk": "Please indicate about potential operational risk for this operations and mitigation actions", "drefFormRiskSecurityPotentialRiskDescription": "Please consider any possible challenges to conduct the assessment, any possible limitations in getting the information required and overall risk to the implementation", "drefFormRiskSecuritySafetyConcern": "Please indicate any security and safety concerns for this operation", + "drefFormRiskSecurityHasChildRiskCompleted": "Has the child safeguarding risk analysis assessment been completed?", "drefFormSelectionCriteria": "Explain the selection criteria for the targeted population", "drefFormSelectionCriteriaDescription": "Explain the rational and logic behind which groups are being targeted and why and address vulnerable groups", "drefFormTargetedPopulation": "Targeted Population", diff --git a/src/views/DrefFinalReportForm/Operation/index.tsx b/src/views/DrefFinalReportForm/Operation/index.tsx index 840d02e45..86275de9d 100644 --- a/src/views/DrefFinalReportForm/Operation/index.tsx +++ b/src/views/DrefFinalReportForm/Operation/index.tsx @@ -435,6 +435,16 @@ function Operation(props: Props) { disabled={disabled} /> + + + n.client_id, member: () => ({ diff --git a/src/views/DrefOperationalUpdateForm/Operation/i18n.json b/src/views/DrefOperationalUpdateForm/Operation/i18n.json index 9513f0255..7225df6b4 100644 --- a/src/views/DrefOperationalUpdateForm/Operation/i18n.json +++ b/src/views/DrefOperationalUpdateForm/Operation/i18n.json @@ -18,6 +18,7 @@ "drefFormRiskSecurityPotentialRisk": "Please indicate about potential operational risk for this operations and mitigation actions", "drefFormRiskSecurityPotentialRiskDescription": "Please consider any possible challenges to conduct the assessment, any possible limitations in getting the information required and overall risk to the implementation", "drefFormRiskSecuritySafetyConcern": "Please indicate any security and safety concerns for this operation", + "drefFormRiskSecurityHasChildRiskCompleted": "Has the child safeguarding risk analysis assessment been completed?", "drefFormSelectionCriteria": "Explain the selection criteria for the targeted population", "drefFormSelectionCriteriaDescription": "Explain the rational and logic behind which groups are being targeted and why and address vulnerable groups", "drefFormSupportServices": "About Support Services", diff --git a/src/views/DrefOperationalUpdateForm/Operation/index.tsx b/src/views/DrefOperationalUpdateForm/Operation/index.tsx index 80cc67031..0d2377e5d 100644 --- a/src/views/DrefOperationalUpdateForm/Operation/index.tsx +++ b/src/views/DrefOperationalUpdateForm/Operation/index.tsx @@ -428,6 +428,16 @@ function Operation(props: Props) { disabled={disabled} /> + + + n.client_id, From 637f7eaf4a1d3929ec5a0ce77c823cb69fc54040 Mon Sep 17 00:00:00 2001 From: puranban Date: Thu, 7 Dec 2023 11:24:54 +0545 Subject: [PATCH 3/7] Add has children sagfeguarding field in all DREF modules export --- src/views/DrefApplicationExport/i18n.json | 1 + src/views/DrefApplicationExport/index.tsx | 18 +++++++++++++++++- src/views/DrefFinalReportExport/i18n.json | 1 + src/views/DrefFinalReportExport/index.tsx | 18 +++++++++++++++++- .../DrefOperationalUpdateExport/i18n.json | 1 + .../DrefOperationalUpdateExport/index.tsx | 18 +++++++++++++++++- 6 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/views/DrefApplicationExport/i18n.json b/src/views/DrefApplicationExport/i18n.json index cff5f276b..33fd76332 100644 --- a/src/views/DrefApplicationExport/i18n.json +++ b/src/views/DrefApplicationExport/i18n.json @@ -69,6 +69,7 @@ "riskAndSecuritySectionHeading": "Risk and Security Considerations", "riskSecurityHeading": "Please indicate about potential operation risk for this operations and mitigation actions", "safetyConcernHeading": "Please indicate any security and safety concerns for this operation", + "hasChildRiskCompleted": "Has the child safeguarding risk analysis assessment been completed?", "plannedInterventionSectionHeading": "Planned Intervention", "targetedPersonsLabel": "Targeted Persons", "budgetLabel": "Budget", diff --git a/src/views/DrefApplicationExport/index.tsx b/src/views/DrefApplicationExport/index.tsx index ab0c20ade..0d5f2b8f5 100644 --- a/src/views/DrefApplicationExport/index.tsx +++ b/src/views/DrefApplicationExport/index.tsx @@ -249,7 +249,12 @@ export function Component() { && isDefined(drefResponse.risk_security) && drefResponse.risk_security.length > 0; const riskSecurityConcernDefined = isTruthyString(drefResponse?.risk_security_concern?.trim()); - const showRiskAndSecuritySection = riskSecurityDefined || riskSecurityConcernDefined; + const hasChildrenSafeguardingDefined = isDefined( + drefResponse?.has_child_safeguarding_risk_analysis_assessment, + ); + const showRiskAndSecuritySection = riskSecurityDefined + || riskSecurityConcernDefined + || hasChildrenSafeguardingDefined; const plannedInterventionDefined = isDefined(drefResponse) && isDefined(drefResponse.planned_interventions) @@ -948,6 +953,17 @@ export function Component() { )} + {hasChildrenSafeguardingDefined && ( + + + + )} )} {plannedInterventionDefined && ( diff --git a/src/views/DrefFinalReportExport/i18n.json b/src/views/DrefFinalReportExport/i18n.json index b47bf93b6..8439d1892 100644 --- a/src/views/DrefFinalReportExport/i18n.json +++ b/src/views/DrefFinalReportExport/i18n.json @@ -62,6 +62,7 @@ "riskLabel": "Risk", "mitigationLabel": "Mitigation action", "safetyConcernHeading": "Please indicate any security and safety concerns for this operation", + "hasChildRiskCompleted": "Has the child safeguarding risk analysis assessment been completed?", "interventionSectionHeading": "Implementation", "targetedPersonsLabel": "Targeted Persons", "assistedPersonsLabel": "Assisted Persons", diff --git a/src/views/DrefFinalReportExport/index.tsx b/src/views/DrefFinalReportExport/index.tsx index 8f03b7588..15bf4d8da 100644 --- a/src/views/DrefFinalReportExport/index.tsx +++ b/src/views/DrefFinalReportExport/index.tsx @@ -149,7 +149,12 @@ export function Component() { && isDefined(drefResponse.risk_security) && drefResponse.risk_security.length > 0; const riskSecurityConcernDefined = isTruthyString(drefResponse?.risk_security_concern?.trim()); - const showRiskAndSecuritySection = riskSecurityDefined || riskSecurityConcernDefined; + const hasChildrenSafeguardingDefined = isDefined( + drefResponse?.has_child_safeguarding_risk_analysis_assessment, + ); + const showRiskAndSecuritySection = riskSecurityDefined + || riskSecurityConcernDefined + || hasChildrenSafeguardingDefined; const plannedInterventionDefined = isDefined(drefResponse) && isDefined(drefResponse.planned_interventions) @@ -665,6 +670,17 @@ export function Component() {
)} + {hasChildrenSafeguardingDefined && ( + + + + )} )} {plannedInterventionDefined && ( diff --git a/src/views/DrefOperationalUpdateExport/i18n.json b/src/views/DrefOperationalUpdateExport/i18n.json index 582c38788..acc8a458d 100644 --- a/src/views/DrefOperationalUpdateExport/i18n.json +++ b/src/views/DrefOperationalUpdateExport/i18n.json @@ -73,6 +73,7 @@ "riskAndSecuritySectionHeading": "Risk and Security Considerations", "riskSecurityHeading": "Please indicate about potential operation risk for this operations and mitigation actions", "safetyConcernHeading": "Please indicate any security and safety concerns for this operation", + "hasChildRiskCompleted": "Has the child safeguarding risk analysis assessment been completed?", "plannedInterventionSectionHeading": "Planned Intervention", "targetedPersonsLabel": "Targeted Persons", "budgetLabel": "Budget", diff --git a/src/views/DrefOperationalUpdateExport/index.tsx b/src/views/DrefOperationalUpdateExport/index.tsx index edd05abca..da1a3ef97 100644 --- a/src/views/DrefOperationalUpdateExport/index.tsx +++ b/src/views/DrefOperationalUpdateExport/index.tsx @@ -172,7 +172,12 @@ export function Component() { && isDefined(drefResponse.risk_security) && drefResponse.risk_security.length > 0; const riskSecurityConcernDefined = isTruthyString(drefResponse?.risk_security_concern?.trim()); - const showRiskAndSecuritySection = riskSecurityDefined || riskSecurityConcernDefined; + const hasChildrenSafeguardingDefined = isDefined( + drefResponse?.has_child_safeguarding_risk_analysis_assessment, + ); + const showRiskAndSecuritySection = riskSecurityDefined + || riskSecurityConcernDefined + || hasChildrenSafeguardingDefined; const plannedInterventionDefined = isDefined(drefResponse) && isDefined(drefResponse.planned_interventions) @@ -827,6 +832,17 @@ export function Component() { )} + {hasChildrenSafeguardingDefined && ( + + + + )} )} {plannedInterventionDefined && ( From 4afcb3ca781b5c232af4fd428bb209b9dd793ab1 Mon Sep 17 00:00:00 2001 From: puranban Date: Thu, 7 Dec 2023 14:34:30 +0545 Subject: [PATCH 4/7] Add upload field for crisis supporting document in DREF --- src/views/DrefApplicationExport/i18n.json | 3 +- src/views/DrefApplicationExport/index.tsx | 11 ++ .../DrefApplicationForm/Overview/i18n.json | 4 +- .../DrefApplicationForm/Overview/index.tsx | 161 ++++++++++-------- src/views/DrefApplicationForm/index.tsx | 14 ++ src/views/DrefApplicationForm/schema.ts | 1 + 6 files changed, 121 insertions(+), 73 deletions(-) diff --git a/src/views/DrefApplicationExport/i18n.json b/src/views/DrefApplicationExport/i18n.json index 33fd76332..138d779b3 100644 --- a/src/views/DrefApplicationExport/i18n.json +++ b/src/views/DrefApplicationExport/i18n.json @@ -98,6 +98,7 @@ "drefAssessmentReportLink": "Assessment Report", "SourceInformationSectionHeading": "Source Information", "sourceInformationSourceNameTitle": "Source Name", - "sourceInformationSourceLinkTitle": "Source Link" + "sourceInformationSourceLinkTitle": "Source Link", + "crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document" } } diff --git a/src/views/DrefApplicationExport/index.tsx b/src/views/DrefApplicationExport/index.tsx index 0d5f2b8f5..04cc56a3e 100644 --- a/src/views/DrefApplicationExport/index.tsx +++ b/src/views/DrefApplicationExport/index.tsx @@ -463,6 +463,17 @@ export function Component() { strongValue /> + {drefResponse?.disaster_category_analysis_details?.file && ( + + + {strings.crisisCategorySupportingDocumentLabel} + + + )} {showEventDescriptionSection && ( <>
diff --git a/src/views/DrefApplicationForm/Overview/i18n.json b/src/views/DrefApplicationForm/Overview/i18n.json index 6f0591136..be2a76710 100644 --- a/src/views/DrefApplicationForm/Overview/i18n.json +++ b/src/views/DrefApplicationForm/Overview/i18n.json @@ -31,6 +31,8 @@ "drefFormUploadCoverImageDescription": "Upload a image for the cover page of the publicly published DREF application.", "drefFormDrefTypeTitle": "DREF Type", "drefFormClickEmergencyResponseFrameworkLabel": "Click to view Emergency Response Framework", - "userListEmptyMessage": "The DREF Application is not shared with anyone." + "userListEmptyMessage": "The DREF Application is not shared with anyone.", + "drefFormUploadCrisisDocument": "If available please upload Crisis categorization Analysis", + "drefFormUploadDocumentButtonLabel": "Upload document" } } diff --git a/src/views/DrefApplicationForm/Overview/index.tsx b/src/views/DrefApplicationForm/Overview/index.tsx index ae1cc3f47..fb3061459 100644 --- a/src/views/DrefApplicationForm/Overview/index.tsx +++ b/src/views/DrefApplicationForm/Overview/index.tsx @@ -40,6 +40,7 @@ import DistrictSearchMultiSelectInput, { type DistrictItem, } from '#components/domain/DistrictSearchMultiSelectInput'; import UserItem from '#components/domain/DrefShareModal/UserItem'; +import GoSingleFileInput from '#components/domain/GoSingleFileInput'; import useDisasterType from '#hooks/domain/useDisasterType'; import { @@ -230,80 +231,98 @@ function Overview(props: Props) { disabled={disabled} /> - - + - - {(value?.disaster_type === DISASTER_FIRE - || value?.disaster_type === DISASTER_FLASH_FLOOD - || value?.disaster_type === DISASTER_FLOOD) - ? ( - - ) : ( -
- )} - - {value?.type_of_dref === TYPE_IMMINENT + numPreferredColumns={2} + > + + + {(value?.disaster_type === DISASTER_FIRE + || value?.disaster_type === DISASTER_FLASH_FLOOD + || value?.disaster_type === DISASTER_FLOOD) + ? ( + + ) : ( +
+ )} + + {value?.type_of_dref === TYPE_IMMINENT - ? strings.drefFormImminentDisasterCategoryLabel - : strings.drefFormDisasterCategoryLabel} - - - - - )} - options={drefDisasterCategoryOptions} - keySelector={disasterCategoryKeySelector} - labelSelector={stringValueSelector} - value={value?.disaster_category} - onChange={setFieldValue} - error={error?.disaster_category} - disabled={disabled} - /> - + ? strings.drefFormImminentDisasterCategoryLabel + : strings.drefFormDisasterCategoryLabel} + + + + + )} + options={drefDisasterCategoryOptions} + keySelector={disasterCategoryKeySelector} + labelSelector={stringValueSelector} + value={value?.disaster_category} + onChange={setFieldValue} + error={error?.disaster_category} + disabled={disabled} + /> + + + + {strings.drefFormUploadDocumentButtonLabel} + + + Date: Thu, 7 Dec 2023 17:33:12 +0545 Subject: [PATCH 5/7] Add targeting strategy document in DREF form and export --- src/views/DrefApplicationExport/i18n.json | 3 +- src/views/DrefApplicationExport/index.tsx | 20 ++++++++++-- .../DrefApplicationForm/Operation/i18n.json | 4 ++- .../DrefApplicationForm/Operation/index.tsx | 16 ++++++++++ .../DrefApplicationForm/Overview/index.tsx | 31 ++++++++++--------- src/views/DrefApplicationForm/index.tsx | 9 +++++- src/views/DrefApplicationForm/schema.ts | 4 ++- 7 files changed, 66 insertions(+), 21 deletions(-) diff --git a/src/views/DrefApplicationExport/i18n.json b/src/views/DrefApplicationExport/i18n.json index 138d779b3..78a20df19 100644 --- a/src/views/DrefApplicationExport/i18n.json +++ b/src/views/DrefApplicationExport/i18n.json @@ -99,6 +99,7 @@ "SourceInformationSectionHeading": "Source Information", "sourceInformationSourceNameTitle": "Source Name", "sourceInformationSourceLinkTitle": "Source Link", - "crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document" + "crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document", + "targetingStrategySupportingDocument": "Targeting Strategy Supporting Document" } } diff --git a/src/views/DrefApplicationExport/index.tsx b/src/views/DrefApplicationExport/index.tsx index 04cc56a3e..31d68b6d8 100644 --- a/src/views/DrefApplicationExport/index.tsx +++ b/src/views/DrefApplicationExport/index.tsx @@ -166,7 +166,7 @@ export function Component() { // eslint-disable-next-line max-len identifiedNeedsAndGapsSortedList.indexOf(a.title) - identifiedNeedsAndGapsSortedList.indexOf(b.title) )), - [drefResponse?.identified_gaps], + [drefResponse?.needs_identified], ); const sortedNsActions = useMemo( @@ -243,7 +243,12 @@ export function Component() { const peopleAssistedDefined = isTruthyString(drefResponse?.people_assisted?.trim()); const selectionCriteriaDefined = isTruthyString(drefResponse?.selection_criteria?.trim()); - const showTargetingStrategySection = peopleAssistedDefined || selectionCriteriaDefined; + const targetingStrategySupportingDocumentDefined = isDefined( + drefResponse?.targeting_strategy_support_file_details, + ); + const showTargetingStrategySection = peopleAssistedDefined + || selectionCriteriaDefined + || targetingStrategySupportingDocumentDefined; const riskSecurityDefined = isDefined(drefResponse) && isDefined(drefResponse.risk_security) @@ -851,6 +856,17 @@ export function Component() { )} + {targetingStrategySupportingDocumentDefined && ( + + + {strings.targetingStrategySupportingDocument} + + + )} )} + + + {strings.drefFormUploadTargetingDocumentButtonLabel} + + - {(value?.disaster_type === DISASTER_FIRE - || value?.disaster_type === DISASTER_FLASH_FLOOD - || value?.disaster_type === DISASTER_FLOOD) - ? ( - - ) : ( -
- )} + {( + value?.disaster_type === DISASTER_FIRE + || value?.disaster_type === DISASTER_FLASH_FLOOD + || value?.disaster_type === DISASTER_FLOOD) ? ( + + ) : ( +
+ )} + ; + formFields = addCondition( formFields, formValue, From 30f5e0e70a93802f94dd908dea5ded92730e33ef Mon Sep 17 00:00:00 2001 From: puranban Date: Fri, 8 Dec 2023 11:08:53 +0545 Subject: [PATCH 6/7] Add sorted NS actions and planned interventions in all DREF export --- src/views/DrefApplicationExport/index.tsx | 154 +++++++++++------- src/views/DrefFinalReportExport/index.tsx | 78 ++++++++- .../DrefOperationalUpdateExport/index.tsx | 120 +++++++++++++- 3 files changed, 283 insertions(+), 69 deletions(-) diff --git a/src/views/DrefApplicationExport/index.tsx b/src/views/DrefApplicationExport/index.tsx index 31d68b6d8..50254b40b 100644 --- a/src/views/DrefApplicationExport/index.tsx +++ b/src/views/DrefApplicationExport/index.tsx @@ -4,6 +4,7 @@ import { _cs, isDefined, isFalsyString, + isNotDefined, isTruthyString, } from '@togglecorp/fujs'; @@ -14,7 +15,6 @@ import Heading from '#components/printable/Heading'; import DescriptionText from '#components/printable/DescriptionText'; import Link from '#components/Link'; import DateOutput from '#components/DateOutput'; -import { components } from '#generated/types'; import useTranslation from '#hooks/useTranslation'; import { useRequest } from '#utils/restRequest'; import { @@ -25,7 +25,7 @@ import { DREF_TYPE_IMMINENT, DisasterCategory, } from '#utils/constants'; - +import { components } from '#generated/types'; import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; @@ -52,57 +52,57 @@ const colorMap: Record = { [DISASTER_CATEGORY_RED]: styles.red, }; -const plannedInterventionSortedList = [ - 'shelter_housing_and_settlements', - 'livelihoods_and_basic_needs', - 'multi-purpose_cash', - 'health', - 'water_sanitation_and_hygiene', - 'protection_gender_and_inclusion', - 'education', - 'migration', - 'risk_reduction_climate_adaptation_and_recovery_', - 'community_engagement_and_accountability', - 'environmental_sustainability', - 'coordination_and_partnerships', - 'secretariat_services', - 'national_society_strengthening', -] satisfies (PlannedIntervention['title'])[]; +const plannedInterventionSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environmental_sustainability: 11, + coordination_and_partnerships: 12, + secretariat_services: 13, + national_society_strengthening: 14, +}; -const identifiedNeedsAndGapsSortedList = [ - 'shelter_housing_and_settlements', - 'livelihoods_and_basic_needs', - 'multi_purpose_cash_grants', - 'health', - 'water_sanitation_and_hygiene', - 'protection_gender_and_inclusion', - 'education', - 'migration', - 'risk_reduction_climate_adaptation_and_recovery', - 'community_engagement_and _accountability', - 'environment_sustainability ', -] satisfies (IdentifiedNeedsAndGaps['title'])[]; +const identifiedNeedsAndGapsSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash_grants: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, +}; -const nsActionsSortedList = [ - 'shelter_housing_and_settlements', - 'livelihoods_and_basic_needs', - 'multi-purpose_cash', - 'health', - 'water_sanitation_and_hygiene', - 'protection_gender_and_inclusion', - 'education', - 'migration', - 'risk_reduction_climate_adaptation_and_recovery', - 'community_engagement_and _accountability', - 'environment_sustainability ', - 'coordination', - 'national_society_readiness', - 'assessment', - 'resource_mobilization', - 'activation_of_contingency_plans', - 'national_society_eoc', - 'other', -] satisfies (NsActions['title'])[]; +const nsActionsSortedList: Record = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, + coordination: 12, + national_society_readiness: 13, + assessment: 14, + resource_mobilization: 15, + activation_of_contingency_plans: 16, + national_society_eoc: 17, + other: 18, +}; // eslint-disable-next-line import/prefer-default-export export function Component() { @@ -153,28 +153,58 @@ export function Component() { }, }); + const filteredPlannedIntervention = useMemo( + () => drefResponse?.planned_interventions?.map((intervention) => { + if (isNotDefined(intervention.title)) { + return undefined; + } + return { ...intervention, title: intervention.title }; + }).filter(isDefined), + [drefResponse?.planned_interventions], + ); + + const filteredIdentifiedNeedsAndGaps = useMemo( + () => drefResponse?.needs_identified?.map((need) => { + if (isNotDefined(need.title)) { + return undefined; + } + return { ...need, title: need.title }; + }).filter(isDefined), + [drefResponse?.needs_identified], + ); + + const filteredNsActions = useMemo( + () => drefResponse?.national_society_actions?.map((nsAction) => { + if (isNotDefined(nsAction.title)) { + return undefined; + } + return { ...nsAction, title: nsAction.title }; + }).filter(isDefined), + [drefResponse?.national_society_actions], + ); + const sortedPlannedInterventions = useMemo( - () => drefResponse?.planned_interventions?.sort((a, b) => ( + () => filteredPlannedIntervention?.sort( // eslint-disable-next-line max-len - plannedInterventionSortedList.indexOf(a.title) - plannedInterventionSortedList.indexOf(b.title) - )), - [drefResponse?.planned_interventions], + (a, b) => plannedInterventionSortedList[a.title] - plannedInterventionSortedList[b.title], + ), + [filteredPlannedIntervention], ); const sortedIdentifiedNeedsAndGaps = useMemo( - () => drefResponse?.needs_identified?.sort((a, b) => ( + () => filteredIdentifiedNeedsAndGaps?.sort( // eslint-disable-next-line max-len - identifiedNeedsAndGapsSortedList.indexOf(a.title) - identifiedNeedsAndGapsSortedList.indexOf(b.title) - )), - [drefResponse?.needs_identified], + (a, b) => identifiedNeedsAndGapsSortedList[a.title] - identifiedNeedsAndGapsSortedList[b.title], + ), + [filteredIdentifiedNeedsAndGaps], ); const sortedNsActions = useMemo( - () => drefResponse?.national_society_actions?.sort((a, b) => ( + () => filteredNsActions?.sort((a, b) => ( // eslint-disable-next-line max-len - nsActionsSortedList.indexOf(a.title) - nsActionsSortedList.indexOf(b.title) + nsActionsSortedList[a.title] - nsActionsSortedList[b.title] )), - [drefResponse?.national_society_actions], + [filteredNsActions], ); const eventDescriptionDefined = isTruthyString(drefResponse?.event_description?.trim()); diff --git a/src/views/DrefFinalReportExport/index.tsx b/src/views/DrefFinalReportExport/index.tsx index 15bf4d8da..f39816814 100644 --- a/src/views/DrefFinalReportExport/index.tsx +++ b/src/views/DrefFinalReportExport/index.tsx @@ -1,9 +1,10 @@ -import { Fragment, useState } from 'react'; +import { Fragment, useMemo, useState } from 'react'; import { useParams } from 'react-router-dom'; import { _cs, isDefined, isFalsyString, + isNotDefined, isTruthyString, } from '@togglecorp/fujs'; @@ -25,12 +26,16 @@ import { DREF_TYPE_IMMINENT, DisasterCategory, } from '#utils/constants'; +import { components } from '#generated/types'; import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; import styles from './styles.module.css'; +type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; +type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; + function BlockTextOutput(props: TextOutputProps & { variant?: never, withoutLabelColon?: never }) { return ( = { [DISASTER_CATEGORY_RED]: styles.red, }; +const plannedInterventionSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environmental_sustainability: 11, + coordination_and_partnerships: 12, + secretariat_services: 13, + national_society_strengthening: 14, +}; + +const identifiedNeedsAndGapsSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash_grants: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, +}; + // eslint-disable-next-line import/prefer-default-export export function Component() { const { finalReportId } = useParams<{ finalReportId: string }>(); @@ -96,6 +132,42 @@ export function Component() { }, }); + const filteredPlannedIntervention = useMemo( + () => drefResponse?.planned_interventions?.map((intervention) => { + if (isNotDefined(intervention.title)) { + return undefined; + } + return { ...intervention, title: intervention.title }; + }).filter(isDefined), + [drefResponse?.planned_interventions], + ); + + const filteredIdentifiedNeedsAndGaps = useMemo( + () => drefResponse?.needs_identified?.map((need) => { + if (isNotDefined(need.title)) { + return undefined; + } + return { ...need, title: need.title }; + }).filter(isDefined), + [drefResponse?.needs_identified], + ); + + const sortedPlannedInterventions = useMemo( + () => filteredPlannedIntervention?.sort( + // eslint-disable-next-line max-len + (a, b) => plannedInterventionSortedList[a.title] - plannedInterventionSortedList[b.title], + ), + [filteredPlannedIntervention], + ); + + const sortedIdentifiedNeedsAndGaps = useMemo( + () => filteredIdentifiedNeedsAndGaps?.sort( + // eslint-disable-next-line max-len + (a, b) => identifiedNeedsAndGapsSortedList[a.title] - identifiedNeedsAndGapsSortedList[b.title], + ), + [filteredIdentifiedNeedsAndGaps], + ); + const showMainDonorsSection = isTruthyString(drefResponse?.main_donors?.trim()); const eventDescriptionDefined = isTruthyString(drefResponse?.event_description?.trim()); const eventScopeDefined = drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT @@ -490,7 +562,7 @@ export function Component() { {strings.needsIdentifiedSectionHeading} - {needsIdentifiedDefined && drefResponse?.needs_identified?.map( + {needsIdentifiedDefined && sortedIdentifiedNeedsAndGaps?.map( (identifiedNeed) => ( @@ -688,7 +760,7 @@ export function Component() { {strings.interventionSectionHeading} - {drefResponse?.planned_interventions?.map( + {sortedPlannedInterventions?.map( (plannedIntervention) => ( diff --git a/src/views/DrefOperationalUpdateExport/index.tsx b/src/views/DrefOperationalUpdateExport/index.tsx index da1a3ef97..3001086f3 100644 --- a/src/views/DrefOperationalUpdateExport/index.tsx +++ b/src/views/DrefOperationalUpdateExport/index.tsx @@ -1,9 +1,10 @@ -import { Fragment, useState } from 'react'; +import { Fragment, useState, useMemo } from 'react'; import { useParams, ScrollRestoration } from 'react-router-dom'; import { _cs, isDefined, isFalsyString, + isNotDefined, isTruthyString, } from '@togglecorp/fujs'; @@ -26,12 +27,17 @@ import { DREF_TYPE_IMMINENT, DisasterCategory, } from '#utils/constants'; +import { components } from '#generated/types'; import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; import styles from './styles.module.css'; +type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; +type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; +type NsActions = components<'read'>['schemas']['NationalSocietyAction']; + function BlockTextOutput(props: TextOutputProps & { variant?: never, withoutLabelColon?: never }) { return ( = { [DISASTER_CATEGORY_RED]: styles.red, }; +const plannedInterventionSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environmental_sustainability: 11, + coordination_and_partnerships: 12, + secretariat_services: 13, + national_society_strengthening: 14, +}; + +const identifiedNeedsAndGapsSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash_grants: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, +}; + +const nsActionsSortedList: Record = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, + coordination: 12, + national_society_readiness: 13, + assessment: 14, + resource_mobilization: 15, + activation_of_contingency_plans: 16, + national_society_eoc: 17, + other: 18, +}; + // eslint-disable-next-line import/prefer-default-export export function Component() { const { opsUpdateId } = useParams<{ opsUpdateId: string }>(); @@ -97,6 +155,60 @@ export function Component() { }, }); + const filteredPlannedIntervention = useMemo( + () => drefResponse?.planned_interventions?.map((intervention) => { + if (isNotDefined(intervention.title)) { + return undefined; + } + return { ...intervention, title: intervention.title }; + }).filter(isDefined), + [drefResponse?.planned_interventions], + ); + + const filteredIdentifiedNeedsAndGaps = useMemo( + () => drefResponse?.needs_identified?.map((need) => { + if (isNotDefined(need.title)) { + return undefined; + } + return { ...need, title: need.title }; + }).filter(isDefined), + [drefResponse?.needs_identified], + ); + + const filteredNsActions = useMemo( + () => drefResponse?.national_society_actions?.map((nsAction) => { + if (isNotDefined(nsAction.title)) { + return undefined; + } + return { ...nsAction, title: nsAction.title }; + }).filter(isDefined), + [drefResponse?.national_society_actions], + ); + + const sortedPlannedInterventions = useMemo( + () => filteredPlannedIntervention?.sort( + // eslint-disable-next-line max-len + (a, b) => plannedInterventionSortedList[a.title] - plannedInterventionSortedList[b.title], + ), + [filteredPlannedIntervention], + ); + + const sortedIdentifiedNeedsAndGaps = useMemo( + () => filteredIdentifiedNeedsAndGaps?.sort( + // eslint-disable-next-line max-len + (a, b) => identifiedNeedsAndGapsSortedList[a.title] - identifiedNeedsAndGapsSortedList[b.title], + ), + [filteredIdentifiedNeedsAndGaps], + ); + + const sortedNsActions = useMemo( + () => filteredNsActions?.sort((a, b) => ( + // eslint-disable-next-line max-len + nsActionsSortedList[a.title] - nsActionsSortedList[b.title] + )), + [filteredNsActions], + ); + const eventDescriptionDefined = isTruthyString(drefResponse?.event_description?.trim()); const eventScopeDefined = drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && isTruthyString(drefResponse?.event_scope?.trim()); @@ -547,7 +659,7 @@ export function Component() { - {drefResponse?.national_society_actions?.map( + {sortedNsActions?.map( (nsAction) => ( {strings.needsIdentifiedSectionHeading} - {needsIdentifiedDefined && drefResponse?.needs_identified?.map( + {needsIdentifiedDefined && sortedIdentifiedNeedsAndGaps?.map( (identifiedNeed) => ( @@ -850,7 +962,7 @@ export function Component() { {strings.plannedInterventionSectionHeading} - {drefResponse?.planned_interventions?.map( + {sortedPlannedInterventions?.map( (plannedIntervention) => ( From b062be7deb7906a58df6bf06ffa68b097db0c4e4 Mon Sep 17 00:00:00 2001 From: puranban Date: Mon, 11 Dec 2023 16:51:47 +0545 Subject: [PATCH 7/7] Add dref sorted file for actions --- src/utils/domain/dref.ts | 63 +++++++++++++++++++ src/views/DrefApplicationExport/index.tsx | 62 ++---------------- src/views/DrefFinalReportExport/index.tsx | 39 ++---------- .../DrefOperationalUpdateExport/index.tsx | 62 ++---------------- 4 files changed, 77 insertions(+), 149 deletions(-) create mode 100644 src/utils/domain/dref.ts diff --git a/src/utils/domain/dref.ts b/src/utils/domain/dref.ts new file mode 100644 index 000000000..1d379b4e1 --- /dev/null +++ b/src/utils/domain/dref.ts @@ -0,0 +1,63 @@ +import { components } from '#generated/types'; + +type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; +type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; +type NsActions = components<'read'>['schemas']['NationalSocietyAction']; + +const plannedInterventionSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environmental_sustainability: 11, + coordination_and_partnerships: 12, + secretariat_services: 13, + national_society_strengthening: 14, +}; + +const identifiedNeedsAndGapsSortedList: Record, number> = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash_grants: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, +}; + +const nsActionsSortedList: Record = { + shelter_housing_and_settlements: 1, + livelihoods_and_basic_needs: 2, + multi_purpose_cash: 3, + health: 4, + water_sanitation_and_hygiene: 5, + protection_gender_and_inclusion: 6, + education: 7, + migration_and_displacement: 8, + risk_reduction_climate_adaptation_and_recovery: 9, + community_engagement_and_accountability: 10, + environment_sustainability: 11, + coordination: 12, + national_society_readiness: 13, + assessment: 14, + resource_mobilization: 15, + activation_of_contingency_plans: 16, + national_society_eoc: 17, + other: 18, +}; + +export { + plannedInterventionSortedList, + identifiedNeedsAndGapsSortedList, + nsActionsSortedList, +}; diff --git a/src/views/DrefApplicationExport/index.tsx b/src/views/DrefApplicationExport/index.tsx index 50254b40b..7a25adaa4 100644 --- a/src/views/DrefApplicationExport/index.tsx +++ b/src/views/DrefApplicationExport/index.tsx @@ -25,16 +25,16 @@ import { DREF_TYPE_IMMINENT, DisasterCategory, } from '#utils/constants'; -import { components } from '#generated/types'; +import { + identifiedNeedsAndGapsSortedList, + nsActionsSortedList, + plannedInterventionSortedList, +} from '#utils/domain/dref'; import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; import styles from './styles.module.css'; -type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; -type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; -type NsActions = components<'read'>['schemas']['NationalSocietyAction']; - function BlockTextOutput(props: TextOutputProps & { variant?: never, withoutLabelColon?: never }) { return ( = { [DISASTER_CATEGORY_RED]: styles.red, }; -const plannedInterventionSortedList: Record, number> = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environmental_sustainability: 11, - coordination_and_partnerships: 12, - secretariat_services: 13, - national_society_strengthening: 14, -}; - -const identifiedNeedsAndGapsSortedList: Record, number> = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash_grants: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environment_sustainability: 11, -}; - -const nsActionsSortedList: Record = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environment_sustainability: 11, - coordination: 12, - national_society_readiness: 13, - assessment: 14, - resource_mobilization: 15, - activation_of_contingency_plans: 16, - national_society_eoc: 17, - other: 18, -}; - // eslint-disable-next-line import/prefer-default-export export function Component() { const { drefId } = useParams<{ drefId: string }>(); diff --git a/src/views/DrefFinalReportExport/index.tsx b/src/views/DrefFinalReportExport/index.tsx index f39816814..52c4b98f6 100644 --- a/src/views/DrefFinalReportExport/index.tsx +++ b/src/views/DrefFinalReportExport/index.tsx @@ -26,16 +26,16 @@ import { DREF_TYPE_IMMINENT, DisasterCategory, } from '#utils/constants'; -import { components } from '#generated/types'; +import { + identifiedNeedsAndGapsSortedList, + plannedInterventionSortedList, +} from '#utils/domain/dref'; import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; import styles from './styles.module.css'; -type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; -type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; - function BlockTextOutput(props: TextOutputProps & { variant?: never, withoutLabelColon?: never }) { return ( = { [DISASTER_CATEGORY_RED]: styles.red, }; -const plannedInterventionSortedList: Record, number> = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environmental_sustainability: 11, - coordination_and_partnerships: 12, - secretariat_services: 13, - national_society_strengthening: 14, -}; - -const identifiedNeedsAndGapsSortedList: Record, number> = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash_grants: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environment_sustainability: 11, -}; - // eslint-disable-next-line import/prefer-default-export export function Component() { const { finalReportId } = useParams<{ finalReportId: string }>(); diff --git a/src/views/DrefOperationalUpdateExport/index.tsx b/src/views/DrefOperationalUpdateExport/index.tsx index 3001086f3..84da96f41 100644 --- a/src/views/DrefOperationalUpdateExport/index.tsx +++ b/src/views/DrefOperationalUpdateExport/index.tsx @@ -27,17 +27,17 @@ import { DREF_TYPE_IMMINENT, DisasterCategory, } from '#utils/constants'; -import { components } from '#generated/types'; +import { + identifiedNeedsAndGapsSortedList, + nsActionsSortedList, + plannedInterventionSortedList, +} from '#utils/domain/dref'; import ifrcLogo from '#assets/icons/ifrc-square.png'; import i18n from './i18n.json'; import styles from './styles.module.css'; -type PlannedIntervention = components<'read'>['schemas']['PlannedIntervention']; -type IdentifiedNeedsAndGaps = components<'read'>['schemas']['IdentifiedNeed']; -type NsActions = components<'read'>['schemas']['NationalSocietyAction']; - function BlockTextOutput(props: TextOutputProps & { variant?: never, withoutLabelColon?: never }) { return ( = { [DISASTER_CATEGORY_RED]: styles.red, }; -const plannedInterventionSortedList: Record, number> = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environmental_sustainability: 11, - coordination_and_partnerships: 12, - secretariat_services: 13, - national_society_strengthening: 14, -}; - -const identifiedNeedsAndGapsSortedList: Record, number> = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash_grants: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environment_sustainability: 11, -}; - -const nsActionsSortedList: Record = { - shelter_housing_and_settlements: 1, - livelihoods_and_basic_needs: 2, - multi_purpose_cash: 3, - health: 4, - water_sanitation_and_hygiene: 5, - protection_gender_and_inclusion: 6, - education: 7, - migration_and_displacement: 8, - risk_reduction_climate_adaptation_and_recovery: 9, - community_engagement_and_accountability: 10, - environment_sustainability: 11, - coordination: 12, - national_society_readiness: 13, - assessment: 14, - resource_mobilization: 15, - activation_of_contingency_plans: 16, - national_society_eoc: 17, - other: 18, -}; - // eslint-disable-next-line import/prefer-default-export export function Component() { const { opsUpdateId } = useParams<{ opsUpdateId: string }>();