Skip to content

Commit

Permalink
add confirm dialog to Leave Deck action (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
jxjj authored Jan 22, 2025
1 parent 85e50f6 commit 5e158d8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion resources/client/pages/Decks/DeckIndexPage/MoreDeckActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</DropdownMenuItem>
<DropdownMenuItem
v-if="deck.capabilities.canLeave"
@click="handleLeaveDeck(deck.id)"
@click="state.isConfirmLeaveDeckModalOpen = true"
>
<IconExit class="size-5 mr-4" />
Leave
Expand All @@ -49,6 +49,22 @@
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<Modal
title="Leave Deck"
submitButtonLabel="Leave Deck"
@submit="handleLeaveDeck(deck.id)"
v-if="deck.capabilities.canLeave"
:open="state.isConfirmLeaveDeckModalOpen"
@update:open="state.isConfirmLeaveDeckModalOpen = false"
triggerButtonVariant="none"
submitButtonVariant="destructive"
variant="danger"
>
<p>
Are you sure you want to leave this deck? You will no longer have access
to these cards.
</p>
</Modal>
<Modal
title="Delete Deck"
submitButtonLabel="Delete"
Expand Down Expand Up @@ -102,6 +118,7 @@ const props = defineProps<{
const state = reactive({
isConfirmDeleteModalOpen: false,
isConfirmLeaveDeckModalOpen: false,
});
const { mutate: deleteDeck } = useDeleteDeckMutation();
Expand All @@ -110,6 +127,7 @@ const router = useRouter();
function handleLeaveDeck(deckId: number) {
leaveDeck(deckId);
state.isConfirmLeaveDeckModalOpen = false;
router.push({ name: "decks.index" });
}
</script>
Expand Down

0 comments on commit 5e158d8

Please sign in to comment.