Skip to content

Commit

Permalink
Added fix to bug: Incorrect Toast Message code100x#1748
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanfaizur committed Feb 18, 2025
1 parent aa31e1e commit 187dad8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/posts/form/form-vote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,29 @@ const VoteForm: React.FC<IVoteFormProps> = ({
toast.error(error);
},
});

const handleVote = (voteType: VoteType) => {
const isUpvote = voteType === VoteType.UPVOTE;
const isUserVote = userVoted && userVoteVal.voteType === voteType;

toast.promise(
execute({ voteType, questionId, answerId, currentPath, slug }),
voteType === VoteType.DOWNVOTE
isUserVote
? {
loading: 'Downvoting...',
success: 'Question has been downvoted.',
loading: isUpvote ? 'Removing upvote...' : 'Removing downvote...',
success: isUpvote ? 'Upvote removed.' : 'Downvote removed.',
error: 'Error',
}
: {
: isUpvote
? {
loading: 'Upvoting...',
success: 'Question has been upvoted.',
error: 'Error',
}
: {
loading: 'Downvoting...',
success: 'Question has been downvoted.',
error: 'Error',
},
);
};
Expand Down

0 comments on commit 187dad8

Please sign in to comment.