feat(users, contents): extend admin update functionality and role management

- Added `moderator` role to `User` type for improved role assignment flexibility.
- Introduced `updateAdmin` method in user and content services to handle partial admin-specific updates.
- Enhanced `Content` type with `categoryId` and `iconUrl` to support richer categorization.
This commit is contained in:
Mathis HERRIOT
2026-01-21 13:22:07 +01:00
parent 68b5071f6d
commit 764c4c07c8
5 changed files with 21 additions and 1 deletions

View File

@@ -65,4 +65,9 @@ export const ContentService = {
async removeAdmin(id: string): Promise<void> {
await api.delete(`/contents/${id}/admin`);
},
async updateAdmin(id: string, update: Partial<Content>): Promise<Content> {
const { data } = await api.patch<Content>(`/contents/${id}/admin`, update);
return data;
},
};

View File

@@ -34,6 +34,11 @@ export const UserService = {
await api.delete(`/users/${uuid}`);
},
async updateAdmin(uuid: string, update: Partial<User>): Promise<User> {
const { data } = await api.patch<User>(`/users/admin/${uuid}`, update);
return data;
},
async updateAvatar(file: File): Promise<User> {
const formData = new FormData();
formData.append("file", file);

View File

@@ -18,6 +18,7 @@ export interface Content {
favoritesCount: number;
isLiked?: boolean;
tags: (string | Tag)[];
categoryId?: string | null;
category?: Category;
authorId: string;
author: User;
@@ -36,6 +37,7 @@ export interface Category {
name: string;
slug: string;
description?: string;
iconUrl?: string;
}
export interface PaginatedResponse<T> {

View File

@@ -6,7 +6,7 @@ export interface User {
displayName?: string;
avatarUrl?: string;
bio?: string;
role?: "user" | "admin";
role?: "user" | "admin" | "moderator";
status?: "active" | "verification" | "suspended" | "pending" | "deleted";
createdAt: string;
}