Skip to content

Commit

Permalink
게스트 투표에도 로딩을 추가한다. (SWYP-team-2th#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
YOOJS1205 committed Mar 3, 2025
1 parent a7e004c commit b7ea073
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/components/vote-detail/Vote/VoteCard/VoteCardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ export default function VoteCardList() {
const { openDialog } = useDialog();
const { voteDetail } = useVoteDetail(shareUrl ?? '');
const queryClient = useQueryClient();
const { mutate: voteMutate, isPending } = useVote(voteDetail.id, {
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['voteDetail', shareUrl],
});
queryClient.invalidateQueries({
queryKey: ['voteStatus', voteDetail.id],
});
const { mutate: voteMutate, isPending: isVotePending } = useVote(
voteDetail.id,
{
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['voteDetail', shareUrl],
});
queryClient.invalidateQueries({
queryKey: ['voteStatus', voteDetail.id],
});
},
},
});
const { mutate: postGuestVote } = usePostGuestVote(voteDetail.id, {
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['voteDetail', shareUrl],
});
},
});
);
const { mutate: postGuestVote, isPending: isGuestVotePending } =
usePostGuestVote(voteDetail.id, {
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['voteDetail', shareUrl],
});
},
});

const handleClickVoteCardItem = (id: number) => {
openDialog(
Expand All @@ -52,7 +56,7 @@ export default function VoteCardList() {

return (
<div className="flex w-full space-x-6 my-[15px] px-[12px] relative">
{isPending && (
{(isVotePending || isGuestVotePending) && (
<div className="absolute w-full inset-0 z-10 bg-gray-100/50">
<Loading />
</div>
Expand Down

0 comments on commit b7ea073

Please sign in to comment.