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:
@@ -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) => {
|
||||
|
Reference in New Issue
Block a user