feat(frontend): refine blog and profile experience
This commit is contained in:
@@ -476,6 +476,33 @@ class ApiClient {
|
||||
return this.request<Types.PostAssetSchema[]>(`/api/blog/admin/posts/${postId}/assets`);
|
||||
}
|
||||
|
||||
async uploadBlogPostFeaturedImage(postId: number, file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const token = this.getStorageValue('access_token');
|
||||
const response = await fetch(`${this.baseUrl}/api/blog/admin/posts/${postId}/featured-image`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = (await response.json().catch(() => ({}))) as ApiErrorBody;
|
||||
throw new Error(error.error || error.detail || 'Featured image upload failed');
|
||||
}
|
||||
|
||||
return response.json() as Promise<Types.PostDetailSchema>;
|
||||
}
|
||||
|
||||
async deleteBlogPostFeaturedImage(postId: number) {
|
||||
return this.request<Types.PostDetailSchema>(`/api/blog/admin/posts/${postId}/featured-image`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
async uploadBlogPostAsset(
|
||||
postId: number,
|
||||
file: File,
|
||||
|
||||
Reference in New Issue
Block a user