feat(blog): wire comment moderation and writers
This commit is contained in:
@@ -403,23 +403,35 @@ class ApiClient {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
category?: string;
|
||||
tag?: string;
|
||||
tag?: string | string[];
|
||||
search?: string;
|
||||
featured?: boolean;
|
||||
author?: string;
|
||||
author?: string | string[];
|
||||
}) {
|
||||
const queryParams = new URLSearchParams();
|
||||
if (params?.page) queryParams.append('page', params.page.toString());
|
||||
if (params?.limit) queryParams.append('limit', params.limit.toString());
|
||||
if (params?.category) queryParams.append('category', params.category);
|
||||
if (params?.tag) queryParams.append('tag', params.tag);
|
||||
if (Array.isArray(params?.tag)) {
|
||||
params.tag.forEach((tag) => queryParams.append('tag', tag));
|
||||
} else if (params?.tag) {
|
||||
queryParams.append('tag', params.tag);
|
||||
}
|
||||
if (params?.search) queryParams.append('search', params.search);
|
||||
if (params?.featured !== undefined) queryParams.append('featured', params.featured.toString());
|
||||
if (params?.author) queryParams.append('author', params.author);
|
||||
if (Array.isArray(params?.author)) {
|
||||
params.author.forEach((author) => queryParams.append('author', author));
|
||||
} else if (params?.author) {
|
||||
queryParams.append('author', params.author);
|
||||
}
|
||||
|
||||
const query = queryParams.toString();
|
||||
return this.request<Types.PostListSchema[]>(`/api/blog/posts${query ? `?${query}` : ''}`);
|
||||
}
|
||||
|
||||
async getBlogFilters() {
|
||||
return this.request<Types.BlogFiltersSchema>('/api/blog/filters');
|
||||
}
|
||||
|
||||
async getPost(slug: string) {
|
||||
return this.request<Types.PostDetailSchema>(`/api/blog/posts/${encodeURIComponent(slug)}`);
|
||||
@@ -455,6 +467,10 @@ class ApiClient {
|
||||
return this.request<Types.PostListSchema[]>(`/api/blog/admin/posts${query.toString() ? `?${query.toString()}` : ''}`);
|
||||
}
|
||||
|
||||
async listBlogWriters() {
|
||||
return this.request<NonNullable<Types.PostListSchema['writers']>>('/api/blog/admin/writers');
|
||||
}
|
||||
|
||||
async getAdminBlogPost(postId: number) {
|
||||
return this.request<Types.PostDetailSchema>(`/api/blog/admin/posts/${postId}`);
|
||||
}
|
||||
@@ -565,6 +581,13 @@ class ApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
async updateComment(commentId: number, data: Types.CommentUpdateSchema) {
|
||||
return this.request<Types.CommentSchema>(`/api/blog/comments/${commentId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
|
||||
async hideComment(commentId: number, note?: string) {
|
||||
return this.request<Types.MessageSchema>(`/api/blog/comments/${commentId}/hide`, {
|
||||
method: 'POST',
|
||||
@@ -572,6 +595,19 @@ class ApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
async unhideComment(commentId: number) {
|
||||
return this.request<Types.MessageSchema>(`/api/blog/comments/${commentId}/unhide`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
async deleteComment(commentId: number, note?: string) {
|
||||
return this.request<Types.MessageSchema>(`/api/blog/comments/${commentId}/delete`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ note: note ?? '' }),
|
||||
});
|
||||
}
|
||||
|
||||
async listDeletedComments() {
|
||||
return this.request<Types.CommentSchema[]>('/api/blog/deleted/comments');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user