From 21769deda6b735ee75561c0433ae1d3bc6a53518 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Wed, 10 Jun 2026 22:11:20 +0330 Subject: [PATCH] fix(admin): show error toast instead of success when savePost fails api() returns null on HTTP error; the save block now checks the return value before closing the modal and showing the success toast. Co-Authored-By: Claude Sonnet 4.6 --- DrSousan.Api/wwwroot/admin/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DrSousan.Api/wwwroot/admin/index.html b/DrSousan.Api/wwwroot/admin/index.html index 1984cc6..521ba72 100644 --- a/DrSousan.Api/wwwroot/admin/index.html +++ b/DrSousan.Api/wwwroot/admin/index.html @@ -2103,8 +2103,10 @@ async function savePost(){ categoryId:catId?parseInt(catId):null, ogImage:document.getElementById('post-image').value, }; - if(id) await api(`/api/blog/posts/${id}`,{method:'PUT',body:JSON.stringify(body)}); - else await api('/api/blog/posts',{method:'POST',body:JSON.stringify(body)}); + const res = id + ? await api(`/api/blog/posts/${id}`,{method:'PUT',body:JSON.stringify(body)}) + : await api('/api/blog/posts',{method:'POST',body:JSON.stringify(body)}); + if(res === null && id) return; // api() already showed error toast closeModal('postModal'); toast('مقاله ذخیره شد ✓'); loadPosts(); }