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
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 18s
This commit is contained in:
@@ -119,7 +119,7 @@ export async function createBlogPost(
|
||||
* Update an existing blog post
|
||||
*/
|
||||
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) {
|
||||
throw new Error(`Failed to update post: ${response.statusText}`);
|
||||
|
||||
@@ -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<typeof updateBlogPost>[0] = {
|
||||
postId,
|
||||
title: title.trim(),
|
||||
content,
|
||||
coverImageKey,
|
||||
});
|
||||
};
|
||||
|
||||
if (coverImageKey) {
|
||||
payload.coverImageKey = coverImageKey;
|
||||
}
|
||||
|
||||
await updateBlogPost(payload);
|
||||
|
||||
success('Blog post updated successfully!', 2000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user