2023-12-09 15:47:03 +01:00
|
|
|
<template>
|
|
|
|
|
<div class="flex flex-col min-h-screen">
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
class="w-full md:max-w-3xl md:mx-auto px-4 mb-10 md:pb-20 md:pt-16 text-center flex-grow"
|
|
|
|
|
>
|
2023-12-09 15:47:03 +01:00
|
|
|
<h1 class="text-4xl font-semibold">
|
|
|
|
|
Thank you!
|
|
|
|
|
</h1>
|
|
|
|
|
<h4 class="text-xl mt-6">
|
|
|
|
|
We're checking the status of your subscription please wait a moment...
|
|
|
|
|
</h4>
|
|
|
|
|
<div class="text-center">
|
2023-12-11 11:56:21 +01:00
|
|
|
<Loader class="h-6 w-6 text-nt-blue mx-auto mt-20" />
|
2023-12-09 15:47:03 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<open-form-footer />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
<script setup>
|
|
|
|
|
import { useBroadcastChannel } from '@vueuse/core'
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
definePageMeta({
|
|
|
|
|
middleware: 'auth'
|
|
|
|
|
})
|
2024-01-04 18:38:50 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
useOpnSeoMeta({
|
|
|
|
|
title: 'Subscription Success'
|
|
|
|
|
})
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
const authStore = useAuthStore()
|
|
|
|
|
const confetti = useConfetti()
|
|
|
|
|
const user = computed(() => authStore.user)
|
|
|
|
|
const subscribeBroadcast = useBroadcastChannel('subscribe')
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
const interval = ref(null)
|
2024-04-15 19:39:03 +02:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
const redirectIfSubscribed = () => {
|
|
|
|
|
if (user.value.is_subscribed) {
|
|
|
|
|
subscribeBroadcast.post({ 'type': 'success' })
|
|
|
|
|
window.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const checkSubscription = () => {
|
|
|
|
|
// Fetch the user.
|
2024-12-02 10:55:09 +01:00
|
|
|
return opnFetch('user').then((data) => {
|
2024-08-23 12:23:01 +02:00
|
|
|
authStore.setUser(data)
|
|
|
|
|
redirectIfSubscribed()
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.error(error)
|
|
|
|
|
clearInterval(interval.value)
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
onMounted(() => {
|
|
|
|
|
redirectIfSubscribed()
|
|
|
|
|
interval.value = setInterval(() => checkSubscription(), 5000)
|
|
|
|
|
})
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
clearInterval(interval.value)
|
|
|
|
|
})
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-08-23 12:23:01 +02:00
|
|
|
onUnmounted(() => {
|
|
|
|
|
// stop confettis after 2 sec
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
confetti.stop()
|
|
|
|
|
}, 2000)
|
|
|
|
|
})
|
|
|
|
|
</script>
|