Line data Source code
1 : import { computed } from 'vue'
2 :
3 : import { isCloud } from '@/platform/distribution/types'
4 : import { useWorkspaceIdentity } from '@/platform/workspace/ports/workspaceIdentity'
5 :
6 : import type { BillingType } from './types'
7 :
8 8836 : export function useBillingRouting() {
9 8836 : const workspaceStore = useWorkspaceIdentity()
10 :
11 8836 : const shouldUseUnifiedPricing = computed(() => {
12 0 : return isCloud && workspaceStore.activeWorkspace?.type !== undefined
13 : })
14 :
15 8836 : const type = computed<BillingType>(() => {
16 : const workspaceType = workspaceStore.activeWorkspace?.type
17 2383 : if (!workspaceType) return 'unknown'
18 :
19 26 : return 'workspace'
20 : })
21 :
22 : const shouldUseWorkspaceBilling = computed(() => type.value === 'workspace')
23 :
24 8836 : return { type, shouldUseWorkspaceBilling, shouldUseUnifiedPricing }
25 : }
|