2026-04-05 00:36:20 -05:00
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
2026-04-10 18:10:01 -05:00
|
|
|
import type {InviteStatus} from "~/types/invitation-status";
|
|
|
|
|
|
|
|
|
|
definePageMeta({
|
|
|
|
|
layout: 'auth'
|
|
|
|
|
})
|
2026-04-05 00:36:20 -05:00
|
|
|
const route = useRoute();
|
|
|
|
|
|
|
|
|
|
const token = route.params.token as string;
|
|
|
|
|
let isAuthorized = ref(false);
|
|
|
|
|
let isProcessed = ref(false);
|
|
|
|
|
let failed = ref(false);
|
2026-04-10 18:10:01 -05:00
|
|
|
let errorMessage = ref("An error occurred while accepting the request.");
|
2026-04-05 00:36:20 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const acceptInvitation = () => {
|
|
|
|
|
$api<InviteStatus>(`/api/invitations/${token}/accept`, {
|
|
|
|
|
method: "GET",
|
|
|
|
|
onResponseError({response}) {
|
|
|
|
|
if (response.status === 401) {
|
|
|
|
|
isAuthorized.value = false
|
|
|
|
|
isProcessed.value = true
|
|
|
|
|
return;
|
2026-04-10 18:10:01 -05:00
|
|
|
} else if (response.status === 404) {
|
|
|
|
|
errorMessage.value = "Invitation not found."
|
|
|
|
|
isProcessed.value = true
|
2026-04-05 00:36:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
failed.value = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}).then((invitationStatus) => {
|
|
|
|
|
navigateTo('/lists')
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acceptInvitation();
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-04-10 18:10:01 -05:00
|
|
|
<div class="content">
|
|
|
|
|
<div v-if="!isAuthorized && !isProcessed && !failed">
|
|
|
|
|
<span class="status-message">Checking your invitation...</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="!isAuthorized && isProcessed && !failed" class="auth-message">
|
|
|
|
|
<span>You'll need to <NuxtLink class="link" to="/auth/login">log in</NuxtLink> or
|
|
|
|
|
<NuxtLink class="link" to="/auth/register">create an account</NuxtLink> to view this list.</span>
|
|
|
|
|
<span>If you're creating a new account, be sure to use the email address where you received this invitation.</span>
|
|
|
|
|
</div>
|
2026-04-05 00:36:20 -05:00
|
|
|
|
2026-04-10 18:10:01 -05:00
|
|
|
<div v-show="failed">
|
|
|
|
|
<span>{{ errorMessage }}</span>
|
|
|
|
|
</div>
|
2026-04-05 00:36:20 -05:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-04-10 18:10:01 -05:00
|
|
|
.auth-message {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
height: 50vh;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
font-size: 1.5rem;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link {
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
color: #007bff;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.link:hover {
|
|
|
|
|
color: #0056b3;
|
|
|
|
|
}
|
2026-04-05 00:36:20 -05:00
|
|
|
|
|
|
|
|
</style>
|