feat(users): add avatar and bio support, improve user profile handling
Introduce `avatarUrl` and `bio` fields in the user schema. Update repository, service, and controller to handle avatar uploads, processing, and bio updates. Add S3 integration for avatar storage and enhance user data handling for private and public profiles.
This commit is contained in:
@@ -16,4 +16,32 @@ export const UserService = {
|
||||
const { data } = await api.patch<User>("/users/me", update);
|
||||
return data;
|
||||
},
|
||||
|
||||
async getUsersAdmin(
|
||||
limit = 10,
|
||||
offset = 0,
|
||||
): Promise<{ data: User[]; totalCount: number }> {
|
||||
const { data } = await api.get<{ data: User[]; totalCount: number }>(
|
||||
"/users/admin",
|
||||
{
|
||||
params: { limit, offset },
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
async removeUserAdmin(uuid: string): Promise<void> {
|
||||
await api.delete(`/users/${uuid}`);
|
||||
},
|
||||
|
||||
async updateAvatar(file: File): Promise<User> {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
const { data } = await api.post<User>("/users/me/avatar", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,12 +4,12 @@ export interface User {
|
||||
email: string;
|
||||
displayName?: string;
|
||||
avatarUrl?: string;
|
||||
bio?: string;
|
||||
role: "user" | "admin";
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface UserProfile extends User {
|
||||
bio?: string;
|
||||
favoritesCount: number;
|
||||
uploadsCount: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user