Skip to content

Commit

Permalink
fix: 게시물 하나 남은 상태에서 삭제 시 alert 안뜨는 버그
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Aug 5, 2023
1 parent 64346ae commit 6f8028c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pages/feed/PostDetail/PostDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ export default function PostDetail({ post }: PostDetailProps) {
setShowMore(false);
};

const handleDeletePost = async () => {
await deletePost(post.id);
if (params.route === 'my' && posts?.length === 1) {
navigate('/user');
}
const handleDeletePost = () => {
deletePost(post.id);
};

const isMyPost = user?.id === post.user.id;
Expand Down Expand Up @@ -105,6 +102,9 @@ export default function PostDetail({ post }: PostDetailProps) {
useEffect(() => {
if (isSuccess) {
alert('게시물이 정상적으로 삭제되었습니다.');
if (params.route === 'my' && posts?.length === 1) {
navigate('/user');
}
}
if (error) {
alert('오류가 발생하였습니다.');
Expand Down

0 comments on commit 6f8028c

Please sign in to comment.