PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / composables / useProAccess.ts

useProAccess.ts in The Innovative Form Builder – IvyForms 1.1, at frontend/src/composables/useProAccess.ts

59 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { computed } from 'vue'
2 import { useProFeatures } from '@/composables/useProFeatures'
3
4 type LicenseInfo = {
5 status?: string
6 plan?: string
7 }
8
9 export function useProAccess() {
10 const pro = useProFeatures()
11
12 const isLoaded = computed(() => pro.loaded.value)
13 const isLitePlan = computed(() => pro.plan.value === 'lite')
14
15 const isProInstalled = computed(() => {
16 if (typeof window === 'undefined') {
17 return false
18 }
19
20 const scriptsLoaded =
21 (window as { ivyFormsProScripts?: Record<string, string> }).ivyFormsProScripts !==
22 undefined ||
23 (window as { IvyFormsProScripts?: Record<string, string> }).IvyFormsProScripts !== undefined
24
25 return scriptsLoaded && !!window.IvyForms?.pro
26 })
27
28 const isLicenseActive = computed(() => {
29 if (!isProInstalled.value) {
30 return false
31 }
32
33 const license = pro.license.value as LicenseInfo | null
34 if (!license) {
35 return false
36 }
37
38 return license.status === 'valid' && license.plan !== 'lite'
39 })
40
41 // Canonical Pro gate for feature access in the admin UI.
42 const isProActivated = computed(
43 () => isLoaded.value && isProInstalled.value && isLicenseActive.value && !isLitePlan.value,
44 )
45
46 const canUseFeature = (featureSlug: string) => {
47 return isProActivated.value && pro.hasFeature(featureSlug)
48 }
49
50 return {
51 isLoaded,
52 isLitePlan,
53 isProInstalled,
54 isLicenseActive,
55 isProActivated,
56 canUseFeature,
57 }
58 }
59