diff --git a/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-component.jsx b/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-component.jsx index e32a9fdfe..eb86ed7b3 100644 --- a/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-component.jsx +++ b/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-component.jsx @@ -19,17 +19,6 @@ import styles from './ndcs-enhancements-2025-map-styles.scss'; const TOOLTIP_ID = 'ndcs-2025-map-tooltip'; -// Show submitted 2025 only once. Remove if we want to add more values -const uniqueLegendItems = legendBuckets => { - const uniqueItems = {}; - Object.entries(legendBuckets).forEach(([key, item]) => { - if (!Object.values(uniqueItems).find(uItem => uItem.name === item.name)) { - uniqueItems[key] = item; - } - }); - return uniqueItems; -}; - const NDCSEnhancements2025Map = ({ loading, indicator, @@ -60,7 +49,7 @@ const NDCSEnhancements2025Map = ({ ); diff --git a/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-selectors.js b/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-selectors.js index 50aedf72b..ba1d66ab7 100644 --- a/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-selectors.js +++ b/app/javascript/app/components/ndcs/ndcs-enhancements-2025-map/ndcs-enhancements-2025-map-selectors.js @@ -52,9 +52,6 @@ export const getIndicatorsParsed = createSelector( [getCategories, getIndicatorsData, getISOCountries], (categories, indicators, isos) => { if (!categories || !indicators || !indicators.length) return null; - // const categoryId = Object.keys(categories).find(id => - // ENHANCEMENT_CATEGORIES.includes(categories[id].slug) - // ); return sortBy( uniqBy( @@ -75,7 +72,7 @@ export const getIndicatorsParsed = createSelector( 'value' ), 'label' - ); // .filter(ind => ind.categoryIds?.indexOf(parseInt(categoryId, 10)) > -1); + ); } ); @@ -210,28 +207,17 @@ export const reduceLegendBuckets = createSelector( if (!indicator) return null; const updatedIndicator = { ...indicator }; - // Get legend buckets and only use the ones on the namesLegendOrder updatedIndicator.legendBuckets = Object.entries( updatedIndicator.legendBuckets ).reduce((acc, [key, value]) => { - const allowedNames = [ - 'Submitted 2025 NDC', - 'No Information', - 'Not Applicable' - ]; if (value.name === 'No Information') { acc[key] = { ...value, name: 'No 2025 NDC' }; - } else if (!allowedNames.includes(value.name)) { - delete acc[key]; - const submitted2025NDC = Object.entries( - updatedIndicator.legendBuckets - ).find(([, v]) => v.name === 'Submitted 2025 NDC'); - acc[key] = submitted2025NDC[1]; } else { acc[key] = value; } return acc; }, {}); + updatedIndicator.locations = Object.entries( updatedIndicator.locations ).reduce((acc, [key, value]) => { @@ -253,6 +239,8 @@ export const sortIndicatorLegend = createSelector( if (!indicator) return null; const updatedIndicator = { ...indicator }; const namesLegendOrder = [ + 'Submitted 2025 NDC with 2030 and 2035 targets', + 'Submitted 2025 NDC with 2030 target', 'Submitted 2025 NDC', 'No 2025 NDC', 'Not Applicable' @@ -303,19 +291,10 @@ export const getPathsWithStyles = createSelector( : locations[iso]; let style = COUNTRY_STYLES; - const submittedLabelId = Object.values(locations).find( - l => l.value === 'Submitted 2025 NDC' - )?.label_id; - const strokeWidth = zoom > 2 ? (1 / zoom) * 2 : 0.5; if (countryData && countryData.label_id) { - // Correction for the enhanced 2025 NDCs. We only want to show the Submitted 2025 NDCs info - const reducedLabelId = - countryData.value === 'No Information' - ? countryData.label_id - : submittedLabelId; - const legendIndex = legendBuckets[reducedLabelId].index; + const legendIndex = legendBuckets[countryData.label_id].index; const color = getColorByIndex(legendBuckets, legendIndex, MAP_COLORS); style = { ...COUNTRY_STYLES, diff --git a/app/javascript/app/components/ndcs/ndcs-enhancements-2025-table/ndcs-enhancements-2025-table-selectors.js b/app/javascript/app/components/ndcs/ndcs-enhancements-2025-table/ndcs-enhancements-2025-table-selectors.js index 97a552484..a8684f796 100644 --- a/app/javascript/app/components/ndcs/ndcs-enhancements-2025-table/ndcs-enhancements-2025-table-selectors.js +++ b/app/javascript/app/components/ndcs/ndcs-enhancements-2025-table/ndcs-enhancements-2025-table-selectors.js @@ -108,25 +108,21 @@ export const tableRemoveIsoFromData = createSelector( const updatedD = { ...d }; updatedD['2025 Statement'] = updatedD['2025 NDC Statement']; - // Use the color of the NDC status to color also the 2030 target status - const submissionValue = - d['2025 NDC Submission'] === 'Submitted 2025 NDC with 2030 target' - ? 'Submitted 2025 NDC' - : d['2025 NDC Submission']; - const color = (d['2025 NDC Submission'] && NDC_2025_LABEL_COLORS[ - INVERTED_NDC_2025_LABEL_SLUGS[submissionValue] + INVERTED_NDC_2025_LABEL_SLUGS[d['2025 NDC Submission']] ]) || NDC_2025_LABEL_COLORS.NO_SUBMISSION; - updatedD['NDC Status'] = submissionValue && { + updatedD['NDC Status'] = d['2025 NDC Submission'] && { color, text: d['2025 NDC Submission'] === 'No Information' ? 'No 2025 NDC' : d['2025 NDC Submission'], - sortIndex: color === NDC_2025_LABEL_COLORS.SUBMITTED_2025 ? '1' : '0' + sortIndex: Object.values(NDC_2025_LABEL_SLUGS).indexOf( + d['2025 NDC Submission'] + ) }; updatedD['Source Link'] = d.Source diff --git a/app/javascript/app/data/constants.js b/app/javascript/app/data/constants.js index 0035e522c..73bb53be0 100644 --- a/app/javascript/app/data/constants.js +++ b/app/javascript/app/data/constants.js @@ -404,6 +404,9 @@ export const ENHANCEMENT_LABEL_SLUGS = { }; export const NDC_2025_LABEL_SLUGS = { + SUBMITTED_2025_WITH_2030_AND_2035_TARGETS: + 'Submitted 2025 NDC with 2030 and 2035 targets', + SUBMITTED_2025_WITH_2030_TARGET: 'Submitted 2025 NDC with 2030 target', SUBMITTED_2025: 'Submitted 2025 NDC', NO_INFO: 'No Information' }; @@ -421,8 +424,8 @@ export const ENHANCEMENT_LABEL_COLORS = { export const NDC_2025_LABEL_COLORS = { SUBMITTED_2025: CHART_NAMED_COLORS.color2, - SUBMITTED_2025_WITH_ENHANCEMENTS: CHART_NAMED_COLORS.color2, - SUBMITTED_2025_WITH_ENHANCEMENTS_2035: CHART_NAMED_COLORS.color2, + SUBMITTED_2025_WITH_2030_AND_2035_TARGETS: CHART_NAMED_COLORS.color1, + SUBMITTED_2025_WITH_2030_TARGET: CHART_NAMED_COLORS.color3, NO_SUBMISSION: '#999C9F' }; @@ -552,8 +555,12 @@ export const NDC_2025_COLORS = { }; export const LEGEND_STATUS_2025_VALUES_COLORS = { - 'Submitted 2025 NDC': NDC_2025_COLORS.darkBlue, - 'No information': NDC_2025_COLORS.darkGray, + 'Submitted 2025 NDC with 2030 and 2035 targets': + NDC_2025_LABEL_COLORS.SUBMITTED_2025_WITH_2030_AND_2035_TARGETS, + 'Submitted 2025 NDC with 2030 target': + NDC_2025_LABEL_COLORS.SUBMITTED_2025_WITH_2030_TARGET, + 'Submitted 2025 NDC': NDC_2025_LABEL_COLORS.SUBMITTED_2025, + 'No information': NDC_2025_LABEL_COLORS.NO_SUBMISSION, 'Not Applicable: Countries that are not a Party to the UNFCCC': NDC_2025_COLORS.lightGray };