Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve community page join flow #116

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</Button>
<Button
v-if="deck.capabilities.canJoinAsViewer"
@click="joinDeck(deck.id)"
@click="handleJoinDeck"
>Join</Button
>
<Button
Expand Down Expand Up @@ -54,6 +54,7 @@ import FlippableCard from "@/components/FlippableCard.vue";
import { ref } from "vue";
import { useJoinCommunityDeckMutation } from "@/queries/community";
import { useLeaveDeckMutation } from "@/queries/deckMemberships";
import { useRouter } from "vue-router";

const props = defineProps<{
deckId: number;
Expand All @@ -70,6 +71,12 @@ function flipAllCards() {
}

const { mutate: joinDeck } = useJoinCommunityDeckMutation();

const router = useRouter();
async function handleJoinDeck() {
await joinDeck(deckIdRef.value);
router.push({ name: "decks.show", params: { deckId: deckIdRef.value } });
}
const { mutate: leaveDeck } = useLeaveDeckMutation();
</script>
<style scoped></style>
27 changes: 20 additions & 7 deletions resources/client/pages/CommunityDecks/CommunityDecksIndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,26 @@
<h3 class="text-lg font-bold">{{ deck.name }}</h3>
<p class="text-sm text-stone-400 mb-4">{{ deck.description }}</p>

<div class="flex gap-2 justify-end">
<div v-if="deck.current_user_role" class="flex gap-2 justify-end">
<Button asChild variant="secondary">
<RouterLink
:to="{
name: 'decks.show',
params: { deckId: deck.id },
}"
class="btn btn-primary"
>View</RouterLink
>
</Button>
<Button
v-if="deck.capabilities.canLeave"
@click="leaveDeck(deck.id)"
variant="destructive"
>Leave</Button
>
</div>

<div v-else class="flex gap-2 justify-end">
<Button asChild variant="secondary">
<RouterLink
:to="{
Expand All @@ -34,12 +53,6 @@
@click="joinDeck(deck.id)"
>Join</Button
>
<Button
v-else-if="deck.capabilities.canLeave"
@click="leaveDeck(deck.id)"
variant="destructive"
>Leave</Button
>
</div>
</article>
</li>
Expand Down
Loading