Skip to content

Commit

Permalink
Merge pull request #82 from WWWPiramalFinanceCOM/authorsied/prod-changes
Browse files Browse the repository at this point in the history
 authorised agency group by js changes due to iphone issue
  • Loading branch information
nky11 authored Dec 13, 2024
2 parents a440aaa + bdef91b commit 55f97fa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions blocks/authorisedagencies/authorisedagencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down

0 comments on commit 55f97fa

Please sign in to comment.