2021-10-10 20:13:10 +00:00
|
|
|
import http, { QueryBuilderParams, withQueryBuilderParams } from '@/api/http';
|
2022-02-27 16:40:51 +00:00
|
|
|
import { Transformers, User } from '@definitions/admin';
|
2021-10-10 18:32:07 +00:00
|
|
|
|
|
|
|
export const getUser = async (id: string | number): Promise<User> => {
|
|
|
|
const { data } = await http.get(`/api/application/users/${id}`);
|
|
|
|
|
2022-02-27 16:26:13 +00:00
|
|
|
return Transformers.toUser(data.data);
|
2021-10-10 18:32:07 +00:00
|
|
|
};
|
2021-10-10 20:13:10 +00:00
|
|
|
|
|
|
|
export const searchUserAccounts = async (params: QueryBuilderParams<'username' | 'email'>): Promise<User[]> => {
|
|
|
|
const { data } = await http.get('/api/application/users', {
|
|
|
|
params: withQueryBuilderParams(params),
|
|
|
|
});
|
|
|
|
|
2022-02-27 16:26:13 +00:00
|
|
|
return data.data.map(Transformers.toUser);
|
2021-10-10 20:13:10 +00:00
|
|
|
};
|