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
|
* 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}`);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user