2021-01-31 22:59:37 +00:00
|
|
|
import http from '@/api/http';
|
|
|
|
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
|
|
|
|
|
2021-02-16 05:41:19 +00:00
|
|
|
interface Filters {
|
|
|
|
short?: string;
|
|
|
|
long?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (filters?: Filters): Promise<Location[]> => {
|
2021-01-31 22:59:37 +00:00
|
|
|
const params = {};
|
|
|
|
if (filters !== undefined) {
|
|
|
|
Object.keys(filters).forEach(key => {
|
|
|
|
// @ts-ignore
|
|
|
|
params['filter[' + key + ']'] = filters[key];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
2021-07-25 21:51:39 +00:00
|
|
|
http.get('/api/application/locations', { params })
|
2021-01-31 22:59:37 +00:00
|
|
|
.then(response => resolve(
|
|
|
|
(response.data.data || []).map(rawDataToLocation)
|
|
|
|
))
|
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|