fix: update API endpoint for blog post editing and improve cover image handling in EditPost component
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 18s

This commit is contained in:
2025-10-26 18:44:36 +08:00
parent 9c263d0f51
commit 3b7d7e2dcc
2 changed files with 9 additions and 9 deletions

View File

@@ -119,7 +119,7 @@ export async function createBlogPost(
* Update an existing blog post * Update an existing blog post
*/ */
export async function updateBlogPost(payload: UpdatePostPayload): Promise<UpdatePostResponse> { export async function updateBlogPost(payload: UpdatePostPayload): Promise<UpdatePostResponse> {
const response = await apiPost(`${API_BASE}/post/update`, payload); const response = await apiPost(`${API_BASE}/post/edit`, payload);
if (!response.ok) { if (!response.ok) {
throw new Error(`Failed to update post: ${response.statusText}`); throw new Error(`Failed to update post: ${response.statusText}`);

View File

@@ -108,20 +108,20 @@ function EditPost() {
const content = editorRef.current.getEditorState(); const content = editorRef.current.getEditorState();
if (!coverImageKey) {
error('Please upload a cover image');
return;
}
setIsSubmitting(true); setIsSubmitting(true);
try { try {
await updateBlogPost({ const payload: Parameters<typeof updateBlogPost>[0] = {
postId, postId,
title: title.trim(), title: title.trim(),
content, content,
coverImageKey, };
});
if (coverImageKey) {
payload.coverImageKey = coverImageKey;
}
await updateBlogPost(payload);
success('Blog post updated successfully!', 2000); success('Blog post updated successfully!', 2000);