From 77c52b7e5076b3cf2aedfdf433df921585472fe0 Mon Sep 17 00:00:00 2001 From: Bluesmile82 Date: Fri, 18 Aug 2023 11:14:19 +0200 Subject: [PATCH 1/2] Refactor getCountriesAndParties to not count EUU as a country --- .../ndcs-explore-map-selectors.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js b/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js index 332af354e..34500791f 100644 --- a/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js +++ b/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js @@ -482,19 +482,20 @@ export const getVulnerabilityData = createSelector( ); const getCountriesAndParties = submissions => { + const countriesSubmissions = submissions.filter(s => s !== europeSlug); const partiesNumber = submissions.length; - let countriesNumber = submissions.length; + let countriesNumber = countriesSubmissions.length; - if (!submissions.includes(europeGroupExplorerPagesSlug)) { - return { partiesNumber, countriesNumber }; + if (submissions.includes(europeGroupExplorerPagesSlug)) { + const europeanCountriesWithSubmission = intersection( + europeanCountries, + countriesSubmissions + ); + + countriesNumber += + europeanCountries.length - (europeanCountriesWithSubmission.length - 1); } - const europeanCountriesWithSubmission = intersection( - europeanCountries, - submissions - ); - countriesNumber += - europeanCountries.length - (europeanCountriesWithSubmission.length - 1) - 1; // Don't count the EUU return { partiesNumber, countriesNumber }; }; From 801446a9439b5d3ced23a992e9f6f6a72ff5c22b Mon Sep 17 00:00:00 2001 From: Bluesmile82 Date: Fri, 18 Aug 2023 11:15:26 +0200 Subject: [PATCH 2/2] EUU was missing from the WORLD selection as a country --- app/javascript/app/components/ndcs/shared/selectors.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index b5058adb8..e88a37016 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -48,7 +48,13 @@ export const selectedCountriesFunction = (locations, regions, countries) => { if (!locations || !locations.length || !regions || !regions.length) { return countries; } - const PARTIES_MISSING_IN_WORLD_SECTION = [...NO_DOCUMENT_SUBMITTED_COUNTRIES]; + + const EUURegion = regions.find(r => r.iso_code3 === 'EUU'); + // EUU as a country is not included in the WORLD section + const PARTIES_MISSING_IN_WORLD_SECTION = [ + ...NO_DOCUMENT_SUBMITTED_COUNTRIES, + { iso: europeSlug, label: EUURegion?.label } + ]; const selectedRegionsCountries = locations.reduce((acc, location) => { let members = acc; if (location.iso === 'TOP') { @@ -82,9 +88,9 @@ export const selectedCountriesFunction = (locations, regions, countries) => { return false; }); } - return members; }, []); + const selectedRegionsCountriesISOS = selectedRegionsCountries.map( c => c.iso_code3 );