Skip to content

Commit

Permalink
feat: expose license
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Jul 27, 2024
1 parent ed48b50 commit f13af11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions composables/usePocketbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useStorage } from '@vueuse/core'
import type { IPocketbasePost } from '~/assets/js/pocketbase.dto'

let email = ref<string | null>(null)
let license = ref<string | null>(null)
let subscription_expires_at = ref<string | null>(null)

let savedPostList = ref<IPocketbasePost[]>([])
Expand All @@ -21,6 +22,7 @@ export function usePocketbase() {
callOnce(async () => {
//
email.value = await $pocketBase.authStore.model.email
license.value = await $pocketBase.authStore.model.username
subscription_expires_at.value = await $pocketBase.authStore.model.subscription_expires_at

savedPostList.value = await $pocketBase.collection('posts').getFullList<IPocketbasePost>({
Expand Down Expand Up @@ -56,6 +58,7 @@ export function usePocketbase() {

return {
email,
license,
subscription_expires_at,

savedPostList
Expand Down
15 changes: 13 additions & 2 deletions composables/useUserData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function useUserData() {
const { $pocketBase } = useNuxtApp()
const { subscription_expires_at, email } = usePocketbase()
const { subscription_expires_at, license, email } = usePocketbase()

return {
isPremium: computed(
Expand All @@ -13,7 +13,7 @@ export function useUserData() {
if (!subscription_expires_at.value) {
return false
}

return new Date(subscription_expires_at.value) > new Date()
}
),
Expand All @@ -27,6 +27,17 @@ export function useUserData() {

return email.value
}
),

license: computed(
//
() => {
if (!$pocketBase.authStore.isValid) {
return null
}

return license.value
}
)
}
}

0 comments on commit f13af11

Please sign in to comment.