From 3b7d7e2dcc42e3be9862eb24f6ad86413e3df01b Mon Sep 17 00:00:00 2001 From: cialloo Date: Sun, 26 Oct 2025 18:44:36 +0800 Subject: [PATCH] fix: update API endpoint for blog post editing and improve cover image handling in EditPost component --- src/blog/api.ts | 2 +- src/pages/EditPost.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/blog/api.ts b/src/blog/api.ts index 021f8b7..1fefba2 100644 --- a/src/blog/api.ts +++ b/src/blog/api.ts @@ -119,7 +119,7 @@ export async function createBlogPost( * Update an existing blog post */ export async function updateBlogPost(payload: UpdatePostPayload): Promise { - const response = await apiPost(`${API_BASE}/post/update`, payload); + const response = await apiPost(`${API_BASE}/post/edit`, payload); if (!response.ok) { throw new Error(`Failed to update post: ${response.statusText}`); diff --git a/src/pages/EditPost.tsx b/src/pages/EditPost.tsx index 6b75011..e4678af 100644 --- a/src/pages/EditPost.tsx +++ b/src/pages/EditPost.tsx @@ -108,20 +108,20 @@ function EditPost() { const content = editorRef.current.getEditorState(); - if (!coverImageKey) { - error('Please upload a cover image'); - return; - } - setIsSubmitting(true); try { - await updateBlogPost({ + const payload: Parameters[0] = { postId, title: title.trim(), content, - coverImageKey, - }); + }; + + if (coverImageKey) { + payload.coverImageKey = coverImageKey; + } + + await updateBlogPost(payload); success('Blog post updated successfully!', 2000);