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:
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user