Skip to content

Commit

Permalink
✨ mutation이 isPending일때 삭제 버튼 비활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
jhsung23 committed Mar 10, 2024
1 parent fbfed49 commit 3d89963
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/app/mypage/_components/MyVote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type BottomSheetType = 'askDelete' | 'selectOption';

const MyVote = () => {
const { data, status } = useGetMyVote();
const { mutate: onDelete } = useDeleteVoteMutation();
const { mutate: onDelete, isPending } = useDeleteVoteMutation();
const { onOpenSheet, openedSheet, onCloseSheet } = useBottomSheetState<BottomSheetType>();
const deleteTarget = useRef<VoteType['id'] | null>(null);

Expand Down Expand Up @@ -51,6 +51,7 @@ const MyVote = () => {
onOpenSheet('selectOption');
deleteTarget.current = vote.id;
}}
disabled={isPending && deleteTarget.current === vote.id}
/>
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/app/vote/[slug]/_component/VoteExtraDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type BottomSheetType = 'askDelete' | 'replyOption';

const VoteExtraDetail = ({ author, views, category, voteId }: Props) => {
const { data: user } = useGetUser();
const { mutate: onDelete } = useDeleteVoteMutation();
const { mutate: onDelete, isPending } = useDeleteVoteMutation();

const router = useRouter();
const { onOpenSheet, openedSheet, onCloseSheet } = useBottomSheetState<BottomSheetType>();
Expand All @@ -44,6 +44,7 @@ const VoteExtraDetail = ({ author, views, category, voteId }: Props) => {
icon="more"
className="!p-0"
onClick={() => onOpenSheet('replyOption')}
disabled={isPending}
/>
)
}
Expand Down

0 comments on commit 3d89963

Please sign in to comment.