diff --git a/web/src/components/console/post-manage/index.tsx b/web/src/components/console/post-manage/index.tsx
index 3de8e75..a8064eb 100644
--- a/web/src/components/console/post-manage/index.tsx
+++ b/web/src/components/console/post-manage/index.tsx
@@ -58,6 +58,10 @@ export function PostManage() {
setPosts((prev) => prev.map((p) => (p.id === post.id ? { ...p, ...post } : p)));
}, [setPosts]);
+ const onPostDelete = useCallback(({ postId }: { postId: number }) => {
+ setPosts((prev) => prev.filter((p) => p.id !== postId));
+ }, [setPosts]);
+
const onOrderChange = useCallback(({ orderBy, desc }: { orderBy: OrderBy; desc: boolean }) => {
setOrderBy(orderBy);
setDesc(desc);
@@ -82,7 +86,7 @@ export function PostManage() {
{posts.map(post =>
)}
@@ -92,7 +96,7 @@ export function PostManage() {
;
}
-function PostItem({ post, onPostUpdate }: { post: Post, onPostUpdate?: ({ post }: { post: Partial & Pick }) => void }) {
+function PostItem({ post, onPostUpdate, onPostDelete }: { post: Post, onPostUpdate: ({ post }: { post: Partial & Pick }) => void ,onPostDelete: ({ postId }: { postId: number }) => void}) {
const commonT = useTranslations("Common");
const postT = useTranslations("Metrics");
const stateT = useTranslations("State");
@@ -120,14 +124,14 @@ function PostItem({ post, onPostUpdate }: { post: Post, onPostUpdate?: ({ post }
-
+
)
}
-function PostDropdownMenu({ post, onPostUpdate }: { post: Post, onPostUpdate?: ({ post }: { post: Partial & Pick }) => void }) {
+function PostDropdownMenu({ post, onPostUpdate, onPostDelete }: { post: Post, onPostUpdate: ({ post }: { post: Partial & Pick }) => void, onPostDelete: ({ postId }: { postId: number }) => void }) {
const operationT = useTranslations("Operation");
const clickToPostEdit = useToEditPost();
const clickToPost = useToPost();
@@ -137,7 +141,7 @@ function PostDropdownMenu({ post, onPostUpdate }: { post: Post, onPostUpdate?: (
updatePost({ post: { ...post, isPrivate: !post.isPrivate } })
.then(() => {
toast.success(operationT("update_success"));
- onPostUpdate?.({ post: { id: post.id, isPrivate: !post.isPrivate } });
+ onPostUpdate({ post: { id: post.id, isPrivate: !post.isPrivate } });
})
.catch(() => {
toast.error(operationT("update_failed"));
@@ -148,7 +152,7 @@ function PostDropdownMenu({ post, onPostUpdate }: { post: Post, onPostUpdate?: (
deletePost({ id: post.id })
.then(() => {
toast.success(operationT("delete_success"));
- onPostUpdate?.({ post: { id: post.id } });
+ onPostDelete({ postId: post.id });
})
.catch(() => {
toast.error(operationT("delete_failed"));