2019-08-17 23:03:10 +00:00
|
|
|
import { rawDataToServerObject, Server } from '@/api/server/getServer';
|
|
|
|
import http, { getPaginationSet, PaginatedResult } from '@/api/http';
|
|
|
|
|
2020-07-15 03:48:41 +00:00
|
|
|
interface QueryParams {
|
|
|
|
query?: string;
|
|
|
|
page?: number;
|
2020-10-16 04:21:38 +00:00
|
|
|
type?: string;
|
2020-07-15 03:48:41 +00:00
|
|
|
}
|
|
|
|
|
2020-10-16 04:21:38 +00:00
|
|
|
export default ({ query, ...params }: QueryParams): Promise<PaginatedResult<Server>> => {
|
2019-08-17 23:03:10 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-07-05 01:30:50 +00:00
|
|
|
http.get('/api/client', {
|
2020-04-26 00:52:32 +00:00
|
|
|
params: {
|
2020-10-16 04:21:38 +00:00
|
|
|
'filter[*]': query,
|
|
|
|
...params,
|
2020-04-26 00:52:32 +00:00
|
|
|
},
|
|
|
|
})
|
2022-06-26 19:13:52 +00:00
|
|
|
.then(({ data }) =>
|
|
|
|
resolve({
|
|
|
|
items: (data.data || []).map((datum: any) => rawDataToServerObject(datum)),
|
|
|
|
pagination: getPaginationSet(data.meta.pagination),
|
|
|
|
})
|
|
|
|
)
|
2019-08-17 23:03:10 +00:00
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|