35 lines
719 B
TypeScript
35 lines
719 B
TypeScript
|
|
import apiClient from './client';
|
||
|
|
|
||
|
|
interface User {
|
||
|
|
id: string;
|
||
|
|
name: string;
|
||
|
|
email: string;
|
||
|
|
role: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface LoginRequest {
|
||
|
|
email: string;
|
||
|
|
password: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
interface LoginResponse {
|
||
|
|
token: string;
|
||
|
|
user: User;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const userApi = {
|
||
|
|
login: async (data: LoginRequest): Promise<LoginResponse> => {
|
||
|
|
return apiClient.post('/auth/login', data);
|
||
|
|
},
|
||
|
|
register: async (data: any): Promise<User> => {
|
||
|
|
return apiClient.post('/auth/register', data);
|
||
|
|
},
|
||
|
|
getProfile: async (): Promise<User> => {
|
||
|
|
return apiClient.get('/user/profile');
|
||
|
|
},
|
||
|
|
updateProfile: async (data: any): Promise<User> => {
|
||
|
|
return apiClient.put('/user/profile', data);
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export default userApi;
|