From bdef91b5aaa26108efa38b24cf56f0e2b89ec0e4 Mon Sep 17 00:00:00 2001 From: npy11 Date: Fri, 13 Dec 2024 16:19:01 +0530 Subject: [PATCH] authorised agency group by js changes due to iphone issue --- blocks/authorisedagencies/authorisedagencies.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blocks/authorisedagencies/authorisedagencies.js b/blocks/authorisedagencies/authorisedagencies.js index 1e4d0d4..07c3794 100644 --- a/blocks/authorisedagencies/authorisedagencies.js +++ b/blocks/authorisedagencies/authorisedagencies.js @@ -17,11 +17,12 @@ export default async function decorate(block) { } function groupAndSortLocations(data) { - const grouped = Object.groupBy(data, ({ Location }) => { - const lowercaseLocation = Location.toLowerCase(); - return lowercaseLocation.charAt(0).toUpperCase() + lowercaseLocation.slice(1); - }); - + const grouped = data.reduce((acc, item) => { + const location = item.Location.charAt(0).toUpperCase() + item.Location.slice(1).toLowerCase(); + acc[location] = acc[location] || []; + acc[location].push(item); + return acc; + }, {}); const sortedCities = Object.keys(grouped).sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' })); return { grouped, sortedCities }; }