ui(admin): start work on LocationSelect.tsx

This commit is contained in:
Matthew Penner 2021-01-31 15:59:37 -07:00
parent 1c8143ad9d
commit 7bbe9e8e89
5 changed files with 160 additions and 28 deletions

View file

@ -0,0 +1,20 @@
import http from '@/api/http';
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
export default (filters?: Record<string, string>): 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: { ...params } })
.then(response => resolve(
(response.data.data || []).map(rawDataToLocation)
))
.catch(reject);
});
};