forked from RiseUP/riseup-squad21
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
// Caminho: services/usuariosApi.ts
|
|
import api from './api';
|
|
|
|
export interface UserRole {
|
|
id: any;
|
|
user_id: string;
|
|
role: string;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export interface User {
|
|
id: any;
|
|
email: string;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export interface FullUserData {
|
|
user: User;
|
|
profile: any;
|
|
roles: string[];
|
|
permissions: any;
|
|
}
|
|
|
|
export const usuariosApi = {
|
|
listRoles: async (): Promise<UserRole[]> => {
|
|
const response = await api.get<UserRole[]>('/rest/v1/user_roles');
|
|
return response.data;
|
|
},
|
|
|
|
createUser: async (data: { email: string; full_name: string; role: string; [key: string]: any }): Promise<any> => {
|
|
const response = await api.post('/functions/v1/create-user', data);
|
|
return response.data;
|
|
},
|
|
|
|
getCurrentUser: async (): Promise<User> => {
|
|
const response = await api.get<User>('/auth/v1/user');
|
|
return response.data;
|
|
},
|
|
|
|
getFullData: async (userId: string): Promise<FullUserData> => {
|
|
const response = await api.get<FullUserData>(`/functions/v1/user-info?user_id=${userId}`);
|
|
return response.data;
|
|
},
|
|
}; |