1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

sort locations & networks alphabetically, closes #124

This commit is contained in:
checktheroads
2021-04-10 09:24:09 -07:00
parent 571d236871
commit ab0d4eb940

View File

@@ -8,15 +8,19 @@ import type { TNetwork, TSelectOption } from '~/types';
import type { TQuerySelectField } from './types';
function buildOptions(networks: TNetwork[]) {
return networks.map(net => {
return networks
.map(net => {
const label = net.display_name;
const options = net.locations.map(loc => ({
const options = net.locations
.map(loc => ({
label: loc.name,
value: loc._id,
group: net.display_name,
}));
}))
.sort((a, b) => (a.label < b.label ? -1 : a.label > b.label ? 1 : 0));
return { label, options };
});
})
.sort((a, b) => (a.label < b.label ? -1 : a.label > b.label ? 1 : 0));
}
export const QueryLocation: React.FC<TQuerySelectField> = (props: TQuerySelectField) => {