2022-12-16 02:06:14 +00:00
|
|
|
import http from '@/api/http';
|
|
|
|
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
|
|
|
|
|
|
|
|
interface Filters {
|
|
|
|
short?: string;
|
|
|
|
long?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (filters?: Filters): Promise<Location[]> => {
|
|
|
|
const params = {};
|
|
|
|
if (filters !== undefined) {
|
|
|
|
Object.keys(filters).forEach(key => {
|
|
|
|
// @ts-ignore
|
|
|
|
params['filter[' + key + ']'] = filters[key];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.get('/api/application/locations', { params })
|
2023-01-12 19:31:47 +00:00
|
|
|
.then(response => resolve((response.data.data || []).map(rawDataToLocation)))
|
2022-12-16 02:06:14 +00:00
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|