mirror of
https://github.com/lorsanstand/Aether.git
synced 2026-09-18 14:18:20 +03:00
Edit README
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import apiClient from './api';
|
||||
|
||||
export interface User {
|
||||
id: number;
|
||||
display_name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
birth_day?: string;
|
||||
description?: string;
|
||||
avatar_url?: string;
|
||||
is_active: boolean;
|
||||
is_verified: boolean;
|
||||
is_superuser: boolean;
|
||||
}
|
||||
|
||||
export interface UserUpdate {
|
||||
display_name?: string;
|
||||
username?: string;
|
||||
birth_day?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export const userService = {
|
||||
getCurrentUser: async (): Promise<User> => {
|
||||
const response = await apiClient.get('/users/me');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateProfile: async (data: UserUpdate): Promise<User> => {
|
||||
const response = await apiClient.put('/users/me', data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
uploadAvatar: async (file: File): Promise<User> => {
|
||||
const formData = new FormData();
|
||||
formData.append('avatar', file);
|
||||
|
||||
const response = await apiClient.post('/users/me/avatar', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
deleteAvatar: async (): Promise<void> => {
|
||||
await apiClient.delete('/users/me/avatar');
|
||||
},
|
||||
|
||||
deleteAccount: async (): Promise<void> => {
|
||||
await apiClient.delete('/users/me');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user