opnform-host-nginx/client/pages/subscriptions/success.vue

89 lines
2.4 KiB
Vue
Raw Normal View History

2023-12-09 15:47:03 +01:00
<template>
<div class="flex flex-col min-h-screen">
<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>
<script>
import { computed } from "vue"
import { useAuthStore } from "../../stores/auth"
2023-12-09 15:47:03 +01:00
export default {
layout: "default",
middleware: "auth",
2023-12-09 15:47:03 +01:00
setup() {
useOpnSeoMeta({
title: "Subscription Success",
})
2023-12-09 15:47:03 +01:00
const authStore = useAuthStore()
return {
authStore,
authenticated: computed(() => authStore.check),
user: computed(() => authStore.user),
crisp: useCrisp(),
2023-12-09 15:47:03 +01:00
}
},
data: () => ({
interval: null,
2023-12-09 15:47:03 +01:00
}),
computed: {},
mounted() {
2023-12-09 15:47:03 +01:00
this.redirectIfSubscribed()
this.interval = setInterval(() => this.checkSubscription(), 5000)
},
beforeUnmount() {
2023-12-09 15:47:03 +01:00
clearInterval(this.interval)
},
methods: {
async checkSubscription() {
2023-12-09 15:47:03 +01:00
// Fetch the user.
await this.authStore.fetchUser()
this.redirectIfSubscribed()
},
redirectIfSubscribed() {
2023-12-09 15:47:03 +01:00
if (this.user.is_subscribed) {
useAmplitude().logEvent("subscribed", {
plan: this.user.has_enterprise_subscription ? "enterprise" : "pro",
})
this.crisp.pushEvent("subscribed", {
plan: this.user.has_enterprise_subscription ? "enterprise" : "pro",
})
this.$router.push({ name: "home" })
2023-12-09 15:47:03 +01:00
if (this.user.has_enterprise_subscription) {
useAlert().success(
"Awesome! Your subscription to OpnForm is now confirmed! You now have access to all Enterprise " +
"features. No need to invite your teammates, just ask them to create a OpnForm account and to connect the same Notion workspace. Feel free to contact us if you have any question 🙌",
)
2023-12-09 15:47:03 +01:00
} else {
useAlert().success(
"Awesome! Your subscription to OpnForm is now confirmed! You now have access to all Pro " +
"features. Feel free to contact us if you have any question 🙌",
)
2023-12-09 15:47:03 +01:00
}
}
},
2023-12-09 15:47:03 +01:00
},
}
</script>