ui(admin): start work on LocationSelect.tsx
This commit is contained in:
parent
1c8143ad9d
commit
7bbe9e8e89
5 changed files with 160 additions and 28 deletions
20
resources/scripts/api/admin/locations/searchLocations.ts
Normal file
20
resources/scripts/api/admin/locations/searchLocations.ts
Normal 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);
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue