@antelopejs/dms-saas 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -1003
- package/dist/billing-state/recovery.js +2 -2
- package/dist/billing-state/recovery.js.map +1 -1
- package/dist/operator-actions/db/lifecycle-delivery.model.d.ts +1 -0
- package/dist/operator-actions/db/operator-action.model.d.ts +1 -0
- package/dist/pages/tenant/general.js +1 -0
- package/dist/pages/tenant/general.js.map +1 -1
- package/dist/stripe/client.d.ts +3 -0
- package/dist/stripe/client.js +16 -1
- package/dist/stripe/client.js.map +1 -1
- package/dist/stripe/customer-billing.js +1 -1
- package/dist/stripe/customer-billing.js.map +1 -1
- package/dist/stripe/subscription-cancellation.js +1 -1
- package/dist/stripe/subscription-cancellation.js.map +1 -1
- package/dist/stripe/upcoming-invoice.js +3 -3
- package/dist/stripe/upcoming-invoice.js.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.js.map +1 -1
- package/dist/upcoming-invoice/db/preview-cache.model.d.ts +1 -0
- package/dist/workspaces/db/provisioning-attempt.model.d.ts +1 -0
- package/dist/workspaces/db/trial-identity.model.d.ts +1 -0
- package/frontend-vue/app/build/PayInvoicePanel.vue +4 -8
- package/frontend-vue/app/build/PlanChangeReview.vue +3 -6
- package/frontend-vue/app/build/segments/useSegmentCatalog.ts +7 -12
- package/frontend-vue/app/build/useWorkspaceName.ts +1 -2
- package/frontend-vue/app/build/users/useUserDetail.ts +8 -10
- package/frontend-vue/app/build/workspace-detail/ComplimentaryDialog.vue +5 -3
- package/frontend-vue/app/build/workspace-detail/CreditDialog.vue +5 -3
- package/frontend-vue/app/build/workspace-detail/UpgradeDialog.vue +14 -7
- package/frontend-vue/app/build/workspace-detail/useWorkspaceActions.ts +11 -10
- package/frontend-vue/app/build/workspace-detail/useWorkspaceOverview.ts +16 -30
- package/frontend-vue/app/components/CustomerPortalButton.vue +6 -4
- package/frontend-vue/app/components/DataExport.vue +34 -54
- package/frontend-vue/app/components/DataExportHistory.vue +2 -7
- package/frontend-vue/app/components/IssueCreditNoteModal.vue +5 -4
- package/frontend-vue/app/components/MigrationStripeCheck.vue +11 -8
- package/frontend-vue/app/components/PastDueAlert.vue +8 -6
- package/frontend-vue/app/components/PastDueBanner.vue +4 -4
- package/frontend-vue/app/components/PaymentMethodCard.vue +6 -11
- package/frontend-vue/app/components/PlanAccessEditor.vue +31 -30
- package/frontend-vue/app/components/PlanCard.vue +2 -3
- package/frontend-vue/app/components/PlanEditorPreview.vue +27 -36
- package/frontend-vue/app/components/PlanUpgradeModal.vue +1 -1
- package/frontend-vue/app/components/PlatformNotes.vue +27 -28
- package/frontend-vue/app/components/Pricing.vue +16 -23
- package/frontend-vue/app/components/RefundButton.vue +61 -46
- package/frontend-vue/app/components/RetirePlanModal.vue +13 -7
- package/frontend-vue/app/components/SeatQuotaBanner.vue +9 -10
- package/frontend-vue/app/components/SegmentConditionsBuilder.vue +0 -1
- package/frontend-vue/app/components/SegmentRulesText.vue +1 -3
- package/frontend-vue/app/components/TenantBillingForm.vue +14 -19
- package/frontend-vue/app/components/TenantPlanCard.vue +18 -21
- package/frontend-vue/app/components/TrialEndingBanner.vue +5 -10
- package/frontend-vue/app/components/UserPlatformRoleCard.vue +8 -9
- package/frontend-vue/app/components/UserSegmentMatches.vue +8 -16
- package/frontend-vue/app/components/UserSummaryCard.vue +2 -4
- package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +13 -5
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +5 -1
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +10 -9
- package/frontend-vue/app/components/WorkspaceDetailHeader.vue +14 -4
- package/frontend-vue/app/components/WorkspaceSuspended.vue +27 -32
- package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +5 -18
- package/frontend-vue/app/composables/useBillingIdentity.ts +9 -5
- package/frontend-vue/app/composables/useBillingStatus.ts +8 -7
- package/frontend-vue/app/composables/useCurrentWorkspace.ts +6 -8
- package/frontend-vue/app/composables/useExportHistory.ts +67 -78
- package/frontend-vue/app/composables/useMountedData.ts +27 -0
- package/frontend-vue/app/composables/useMyWorkspaces.ts +26 -28
- package/frontend-vue/app/composables/useNextInvoice.ts +7 -6
- package/frontend-vue/app/composables/useOnDemandRead.ts +49 -0
- package/frontend-vue/app/composables/usePendingCheckout.ts +2 -1
- package/frontend-vue/app/composables/usePlanCatalog.ts +3 -9
- package/frontend-vue/app/composables/usePublicPricing.ts +24 -0
- package/frontend-vue/app/composables/useSaasRegistration.ts +2 -0
- package/frontend-vue/app/composables/useSeatQuota.ts +2 -6
- package/frontend-vue/app/composables/useTenantPlan.ts +26 -9
- package/frontend-vue/app/composables/useWorkspaceOverview.ts +2 -6
- package/frontend-vue/app/custom-pages/auth/no-workspace.vue +3 -1
- package/frontend-vue/dms.server.ts +22 -0
- package/frontend-vue/package.json +1 -1
- package/package.json +36 -18
- package/skills/dms-saas/SKILL.md +56 -0
- package/frontend-vue/app/composables/useServerConfirm.ts +0 -44
- package/frontend-vue/app/composables/useSharedRequest.ts +0 -54
- package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +0 -52
- package/frontend-vue/app/composables/useWorkspaceRenamed.ts +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
import { useUserDetail } from '../build/users/useUserDetail'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{ routeParams?: Record<string, string> }>()
|
|
@@ -11,7 +11,7 @@ type RoleChange = 'promote' | 'demote'
|
|
|
11
11
|
|
|
12
12
|
const { t } = useI18n()
|
|
13
13
|
const { $authFetch } = useAuthFetch()
|
|
14
|
-
const { confirmFrom } =
|
|
14
|
+
const { confirmFrom } = useConfirmFrom()
|
|
15
15
|
const toast = useToast()
|
|
16
16
|
const { resolveApiError } = useApiErrorMessage()
|
|
17
17
|
const detail = useUserDetail(() => props.routeParams)
|
|
@@ -25,16 +25,17 @@ const change = computed<RoleChange>(() =>
|
|
|
25
25
|
async function runChange(kind: RoleChange): Promise<void> {
|
|
26
26
|
await $authFetch(`${API}/${detail.userId.value}/${kind}`, { method: 'POST' })
|
|
27
27
|
toast.add({ color: 'success', title: t(`${I18N}.${kind}d`) })
|
|
28
|
-
|
|
28
|
+
// The dialog closes once the card shows the new role.
|
|
29
|
+
await refreshPageBlocks()
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
async function openConfirm(): Promise<void> {
|
|
32
33
|
const kind = change.value
|
|
33
34
|
isOpening.value = true
|
|
34
35
|
try {
|
|
35
|
-
await confirmFrom(`${API}/${detail.userId.value}/${kind}-confirm`,
|
|
36
|
-
runChange(kind),
|
|
37
|
-
)
|
|
36
|
+
await confirmFrom(`${API}/${detail.userId.value}/${kind}-confirm`, {
|
|
37
|
+
onConfirm: () => runChange(kind),
|
|
38
|
+
})
|
|
38
39
|
} catch (error) {
|
|
39
40
|
toast.add({
|
|
40
41
|
color: 'error',
|
|
@@ -44,14 +45,12 @@ async function openConfirm(): Promise<void> {
|
|
|
44
45
|
isOpening.value = false
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
onMounted(() => void detail.load())
|
|
49
48
|
</script>
|
|
50
49
|
|
|
51
50
|
<template>
|
|
52
51
|
<DmsCard :title="$t(`${I18N}.title`)">
|
|
53
52
|
<DmsSaasLoadFailure
|
|
54
|
-
v-if="detail.
|
|
53
|
+
v-if="detail.status.value === 'error' && !user"
|
|
55
54
|
@retry="detail.refresh()"
|
|
56
55
|
/>
|
|
57
56
|
<div v-else-if="!user" class="flex flex-col gap-2">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from 'vue'
|
|
3
3
|
import type { SegmentConditionGroup } from '../build/segments/types'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{ routeParams?: Record<string, string> }>()
|
|
@@ -22,24 +22,16 @@ const DAY_FORMAT: Intl.DateTimeFormatOptions = {
|
|
|
22
22
|
const SKELETON_ROWS = 2
|
|
23
23
|
|
|
24
24
|
const { locale } = useI18n()
|
|
25
|
-
const { $authFetch } = useAuthFetch()
|
|
26
25
|
const userId = computed(() => props.routeParams?.id ?? '')
|
|
27
|
-
const
|
|
28
|
-
|
|
26
|
+
const segments = useApiData<{ items: SegmentMatch[] }>(() =>
|
|
27
|
+
userId.value ? `/api/saas/users/${userId.value}/segments` : null,
|
|
28
|
+
)
|
|
29
|
+
const matches = computed(() => segments.data.value?.items ?? null)
|
|
30
|
+
const hasFailed = computed(() => segments.status.value === 'error')
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const response = await $authFetch<{ items: SegmentMatch[] }>(
|
|
34
|
-
`/api/saas/users/${userId.value}/segments`,
|
|
35
|
-
)
|
|
36
|
-
matches.value = response.items
|
|
37
|
-
} catch {
|
|
38
|
-
hasFailed.value = true
|
|
39
|
-
}
|
|
32
|
+
function load(): Promise<void> {
|
|
33
|
+
return segments.refresh()
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
onMounted(load)
|
|
43
35
|
</script>
|
|
44
36
|
|
|
45
37
|
<template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, watch } from 'vue'
|
|
3
3
|
import { userDisplayName, useUserDetail } from '../build/users/useUserDetail'
|
|
4
4
|
|
|
5
5
|
// The identity header of the user page: who the user is and how their
|
|
@@ -22,14 +22,12 @@ watch(avatarKey, (key) => key && resolve(key), { immediate: true })
|
|
|
22
22
|
const avatarSrc = computed(() =>
|
|
23
23
|
avatarKey.value ? getUrl(avatarKey.value) : undefined,
|
|
24
24
|
)
|
|
25
|
-
|
|
26
|
-
onMounted(() => void detail.refresh())
|
|
27
25
|
</script>
|
|
28
26
|
|
|
29
27
|
<template>
|
|
30
28
|
<div class="flex flex-col gap-4">
|
|
31
29
|
<DmsSaasLoadFailure
|
|
32
|
-
v-if="detail.
|
|
30
|
+
v-if="detail.status.value === 'error' && !user"
|
|
33
31
|
:title="$t('saas.users.load_failed')"
|
|
34
32
|
@retry="detail.refresh()"
|
|
35
33
|
/>
|
|
@@ -150,11 +150,18 @@ const whatHappens = computed(() => {
|
|
|
150
150
|
return [created, ownerSentence.value].filter(Boolean).join(' ')
|
|
151
151
|
})
|
|
152
152
|
|
|
153
|
+
const plansRead = useOnDemandRead<PlanOption[]>(() => PLANS_ENDPOINT)
|
|
154
|
+
const lookedUpEmail = ref('')
|
|
155
|
+
const ownerRead = useOnDemandRead<OwnerLookup>(
|
|
156
|
+
() => (lookedUpEmail.value ? LOOKUP_ENDPOINT : null),
|
|
157
|
+
{ query: () => ({ email: lookedUpEmail.value }) },
|
|
158
|
+
)
|
|
159
|
+
|
|
153
160
|
async function loadPlans(): Promise<void> {
|
|
154
161
|
isLoading.value = true
|
|
155
162
|
loadError.value = null
|
|
156
163
|
try {
|
|
157
|
-
const all = await
|
|
164
|
+
const all = await plansRead.read()
|
|
158
165
|
plans.value = all.filter((option) => option.isActive && !option.isDeleted)
|
|
159
166
|
} catch (error) {
|
|
160
167
|
loadError.value = resolveApiError(error, `${C}.load_error`)
|
|
@@ -164,12 +171,13 @@ async function loadPlans(): Promise<void> {
|
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
async function lookUpOwner(email: string): Promise<void> {
|
|
174
|
+
lookedUpEmail.value = email
|
|
167
175
|
try {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
176
|
+
const found = await ownerRead.read()
|
|
177
|
+
// A newer address was typed while this one was looked up.
|
|
178
|
+
if (lookedUpEmail.value === email) lookup.value = found
|
|
171
179
|
} catch {
|
|
172
|
-
lookup.value = null
|
|
180
|
+
if (lookedUpEmail.value === email) lookup.value = null
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
|
|
@@ -161,6 +161,8 @@ async function initStripeElement(): Promise<void> {
|
|
|
161
161
|
cardError.value = t(`${KEYS}.error.card_setup`)
|
|
162
162
|
return
|
|
163
163
|
}
|
|
164
|
+
// Not a `useApiData` read: each call creates a SetupIntent, whose client
|
|
165
|
+
// secret is the card form's alone, never cached nor shared.
|
|
164
166
|
const setup = await $authFetch<SetupIntent>(SETUP_INTENT_ENDPOINT)
|
|
165
167
|
stripeHandle.value = useStripePaymentElement({
|
|
166
168
|
publishableKey: publishableKey.value,
|
|
@@ -190,11 +192,13 @@ function ensureCardStep(): Promise<void> {
|
|
|
190
192
|
|
|
191
193
|
watch(asksForCard, ensureCardStep)
|
|
192
194
|
|
|
195
|
+
const optionsRead = useOnDemandRead<CreateOptions>(() => OPTIONS_ENDPOINT)
|
|
196
|
+
|
|
193
197
|
async function load(): Promise<void> {
|
|
194
198
|
isLoading.value = true
|
|
195
199
|
loadError.value = null
|
|
196
200
|
try {
|
|
197
|
-
options.value = await
|
|
201
|
+
options.value = await optionsRead.read()
|
|
198
202
|
selectedPlanId.value ??= options.value.plans[0]?._id ?? null
|
|
199
203
|
} catch (error) {
|
|
200
204
|
loadError.value = resolveApiError(error, `${KEYS}.error.load_description`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, h
|
|
2
|
+
import { computed, h } from 'vue'
|
|
3
3
|
import { DATA_EXPORT_PATH, HOME_PATH } from '../build/workspace-paths'
|
|
4
4
|
|
|
5
5
|
const DELETE_ENDPOINT = '/api/saas/workspaces/current/delete'
|
|
@@ -17,9 +17,9 @@ const { $authFetch } = useAuthFetch()
|
|
|
17
17
|
const { confirm } = useConfirm()
|
|
18
18
|
const { resolveApiError } = useApiErrorMessage()
|
|
19
19
|
const toast = useToast()
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
20
|
+
// The deletion asks for the name as it is now: a rename on this page reads
|
|
21
|
+
// the page's data again, this overview included.
|
|
22
|
+
const { data: overview, status, refresh } = useWorkspaceOverview()
|
|
23
23
|
|
|
24
24
|
const destroyedOn = computed(
|
|
25
25
|
() =>
|
|
@@ -142,8 +142,6 @@ async function openDeleteConfirm(): Promise<void> {
|
|
|
142
142
|
onConfirm: () => deleteWorkspace(view),
|
|
143
143
|
})
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
onMounted(refresh)
|
|
147
145
|
</script>
|
|
148
146
|
|
|
149
147
|
<template>
|
|
@@ -165,12 +163,15 @@ onMounted(refresh)
|
|
|
165
163
|
</DmsFieldRow>
|
|
166
164
|
<DmsFieldRow :label="$t(`${KEYS}.delete.title`)">
|
|
167
165
|
<template #details>
|
|
168
|
-
<USkeleton
|
|
166
|
+
<USkeleton
|
|
167
|
+
v-if="!overview && status !== 'error'"
|
|
168
|
+
class="mt-1 h-10 w-full"
|
|
169
|
+
/>
|
|
169
170
|
<DmsSaasLoadFailure
|
|
170
|
-
v-else-if="error && !overview"
|
|
171
|
+
v-else-if="status === 'error' && !overview"
|
|
171
172
|
class="mt-1"
|
|
172
173
|
:title="$t(`${KEYS}.glance.load_failed`)"
|
|
173
|
-
@retry="refresh"
|
|
174
|
+
@retry="refresh()"
|
|
174
175
|
/>
|
|
175
176
|
<div v-else class="text-muted mt-0.5 flex flex-col gap-1 text-[12.5px]">
|
|
176
177
|
<p>{{ deleteSummary }}</p>
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, watch } from 'vue'
|
|
2
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
3
3
|
import type { DropdownMenuItem } from '@nuxt/ui'
|
|
4
4
|
import WorkspaceActionDialogs from '../build/workspace-detail/WorkspaceActionDialogs.vue'
|
|
5
5
|
import { useWorkspaceActions } from '../build/workspace-detail/useWorkspaceActions'
|
|
6
6
|
import { useWorkspaceOverview } from '../build/workspace-detail/useWorkspaceOverview'
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
WorkspaceDialog,
|
|
9
|
+
WorkspaceOverview,
|
|
10
|
+
} from '../build/workspace-detail/types'
|
|
8
11
|
import { workspaceInitials } from '../build/public/access'
|
|
9
12
|
|
|
10
13
|
/**
|
|
@@ -146,13 +149,20 @@ const QUERY_ACTIONS: Record<string, () => void> = {
|
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
// The list's row menu opens a dialog here: run it once the workspace is
|
|
149
|
-
// loaded, then drop the query so a
|
|
150
|
-
|
|
152
|
+
// loaded (the server may have rendered it already), then drop the query so a
|
|
153
|
+
// reload does not open it again.
|
|
154
|
+
async function runRequestedAction(
|
|
155
|
+
current: WorkspaceOverview | null,
|
|
156
|
+
): Promise<void> {
|
|
151
157
|
const requested = route.query[ACTION_QUERY]
|
|
152
158
|
if (!current || typeof requested !== 'string') return
|
|
153
159
|
const { [ACTION_QUERY]: _action, ...query } = route.query
|
|
154
160
|
await router.replace({ query })
|
|
155
161
|
QUERY_ACTIONS[requested]?.()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
onMounted(() => {
|
|
165
|
+
watch(overview, runRequestedAction, { immediate: true })
|
|
156
166
|
})
|
|
157
167
|
</script>
|
|
158
168
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* how the workspace owner reopens it, whom a member should ask, and the
|
|
5
5
|
* caller's other workspaces. Reachable while the access gate blocks.
|
|
6
6
|
*/
|
|
7
|
-
import { computed, onMounted, ref } from 'vue'
|
|
7
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
8
8
|
import {
|
|
9
9
|
ACCESS_REASON_VIEWS,
|
|
10
10
|
workspaceInitials,
|
|
@@ -39,17 +39,22 @@ interface PortalSession {
|
|
|
39
39
|
const { t, locale } = useI18n()
|
|
40
40
|
const toast = useToast()
|
|
41
41
|
const { $authFetch } = useAuthFetch()
|
|
42
|
-
const { user, clear: clearSession } =
|
|
42
|
+
const { user, clear: clearSession } = useDmsUserSession()
|
|
43
43
|
const { resolveApiError } = useApiErrorMessage()
|
|
44
44
|
const { formatMinorUnits } = useMoneyFormat()
|
|
45
45
|
const { statusView } = useSaasStatus()
|
|
46
|
-
const cachedAccess = useWorkspaceAccessCache()
|
|
47
|
-
const { data: billingStatusState } = useBillingStatus()
|
|
48
|
-
const { data: tenantPlanState } = useTenantPlan()
|
|
49
46
|
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
47
|
+
const accessRead = useApiData<WorkspaceAccessDetails>(ACCESS_ENDPOINT)
|
|
48
|
+
const access = accessRead.data
|
|
49
|
+
const isLoading = computed(() => accessRead.pending.value)
|
|
50
|
+
const loadError = computed(() =>
|
|
51
|
+
accessRead.error.value
|
|
52
|
+
? resolveApiError(
|
|
53
|
+
accessRead.error.value,
|
|
54
|
+
'saas.public.suspended.load_error',
|
|
55
|
+
)
|
|
56
|
+
: null,
|
|
57
|
+
)
|
|
53
58
|
const isOpeningPortal = ref(false)
|
|
54
59
|
|
|
55
60
|
const reason = computed(() => access.value?.reason ?? null)
|
|
@@ -152,29 +157,8 @@ const mailtoOwner = computed(() =>
|
|
|
152
157
|
: null,
|
|
153
158
|
)
|
|
154
159
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* navigation keeps them alive, and Billing would keep announcing a
|
|
158
|
-
* suspension the owner just settled.
|
|
159
|
-
*/
|
|
160
|
-
async function enterWorkspace(): Promise<void> {
|
|
161
|
-
cachedAccess.value = null
|
|
162
|
-
billingStatusState.value = null
|
|
163
|
-
tenantPlanState.value = null
|
|
164
|
-
await navigateDms(HOME_PATH)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async function loadAccess(): Promise<void> {
|
|
168
|
-
isLoading.value = true
|
|
169
|
-
loadError.value = null
|
|
170
|
-
try {
|
|
171
|
-
access.value = await $authFetch<WorkspaceAccessDetails>(ACCESS_ENDPOINT)
|
|
172
|
-
if (!access.value.blocked) await enterWorkspace()
|
|
173
|
-
} catch (error) {
|
|
174
|
-
loadError.value = resolveApiError(error, 'saas.public.suspended.load_error')
|
|
175
|
-
} finally {
|
|
176
|
-
isLoading.value = false
|
|
177
|
-
}
|
|
160
|
+
function loadAccess(): Promise<void> {
|
|
161
|
+
return accessRead.refresh()
|
|
178
162
|
}
|
|
179
163
|
|
|
180
164
|
function payInvoice(): void {
|
|
@@ -209,7 +193,18 @@ async function signOut(): Promise<void> {
|
|
|
209
193
|
await navigateDms(LOGIN_PATH)
|
|
210
194
|
}
|
|
211
195
|
|
|
212
|
-
|
|
196
|
+
// A workspace no longer blocked is entered again, from the browser. The
|
|
197
|
+
// billing data read before the suspension is not shown here, so the pages
|
|
198
|
+
// past this one read it afresh.
|
|
199
|
+
onMounted(() => {
|
|
200
|
+
watch(
|
|
201
|
+
() => access.value?.blocked,
|
|
202
|
+
(blocked) => {
|
|
203
|
+
if (blocked === false) void navigateDms(HOME_PATH)
|
|
204
|
+
},
|
|
205
|
+
{ immediate: true },
|
|
206
|
+
)
|
|
207
|
+
})
|
|
213
208
|
</script>
|
|
214
209
|
|
|
215
210
|
<template>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
3
|
import { HOME_PATH } from '../build/workspace-paths'
|
|
4
4
|
import WorkspaceSwitcherRow from '../build/WorkspaceSwitcherRow.vue'
|
|
5
5
|
|
|
6
|
+
// Drawn as two roots: attributes have no single element to land on.
|
|
7
|
+
defineOptions({ inheritAttrs: false })
|
|
8
|
+
|
|
6
9
|
const props = defineProps<{
|
|
7
10
|
collapsed?: boolean
|
|
8
11
|
}>()
|
|
@@ -25,8 +28,7 @@ const canCreateWorkspace = computed(
|
|
|
25
28
|
?.admissionMode !== 'invitation-only',
|
|
26
29
|
)
|
|
27
30
|
|
|
28
|
-
const { workspaces, isLoaded, refresh } = useMyWorkspaces()
|
|
29
|
-
const hasFailed = ref(false)
|
|
31
|
+
const { workspaces, isLoaded, hasFailed, refresh: load } = useMyWorkspaces()
|
|
30
32
|
const isOpen = ref(false)
|
|
31
33
|
const isCreateOpen = ref(false)
|
|
32
34
|
const searchQuery = ref('')
|
|
@@ -78,15 +80,6 @@ function initialOf(name: string): string {
|
|
|
78
80
|
return (name.trim()[0] ?? '?').toUpperCase()
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
async function load(): Promise<void> {
|
|
82
|
-
try {
|
|
83
|
-
await refresh()
|
|
84
|
-
hasFailed.value = false
|
|
85
|
-
} catch {
|
|
86
|
-
hasFailed.value = true
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
83
|
function reportSwitchFailure(target: MyWorkspace | string): void {
|
|
91
84
|
const name = typeof target === 'string' ? target : target.name
|
|
92
85
|
toast.add({
|
|
@@ -134,12 +127,6 @@ async function onWorkspaceCreated(
|
|
|
134
127
|
await load()
|
|
135
128
|
}
|
|
136
129
|
}
|
|
137
|
-
|
|
138
|
-
useWorkspaceRenamed(() => void load())
|
|
139
|
-
|
|
140
|
-
onMounted(() => {
|
|
141
|
-
if (!isLoaded.value) void load()
|
|
142
|
-
})
|
|
143
130
|
</script>
|
|
144
131
|
|
|
145
132
|
<template>
|
|
@@ -124,13 +124,17 @@ function toRequestBody(draft: BillingIdentityDraft) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
/**
|
|
127
|
+
/** The workspace billing identity a form shows, read with the page. */
|
|
128
|
+
export function useBillingInfo(): ApiDataResult<BillingInfoResponse> {
|
|
129
|
+
return useApiData<BillingInfoResponse>(BILLING_INFO_ENDPOINT)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Saves the workspace billing identity, and reads it for a dialog on open. */
|
|
128
133
|
export function useBillingIdentity() {
|
|
129
134
|
const { $authFetch } = useAuthFetch()
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
135
|
+
const { read: load } = useOnDemandRead<BillingInfoResponse>(
|
|
136
|
+
() => BILLING_INFO_ENDPOINT,
|
|
137
|
+
)
|
|
134
138
|
|
|
135
139
|
function save(draft: BillingIdentityDraft): Promise<BillingInfoResponse> {
|
|
136
140
|
return $authFetch<BillingInfoResponse>(BILLING_INFO_ENDPOINT, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ApiReadOptions } from './useMountedData'
|
|
2
|
+
|
|
1
3
|
const BILLING_STATUS_ENDPOINT = '/api/saas/billing/status'
|
|
2
|
-
const BILLING_STATUS_STATE_KEY = 'saas-billing-status'
|
|
3
4
|
|
|
4
5
|
export interface PaymentMethodSummary {
|
|
5
6
|
brand: string
|
|
@@ -42,12 +43,12 @@ export interface BillingStatusResponse {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/** Read by most billing blocks and the past-due banner; each call reaches
|
|
45
|
-
* Stripe, so they share one request.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
46
|
+
* Stripe, so they share one request. The layout strips read it with
|
|
47
|
+
* `server: false` (see `useMountedData`). */
|
|
48
|
+
export function useBillingStatus(
|
|
49
|
+
options: ApiReadOptions = {},
|
|
50
|
+
): ApiDataResult<BillingStatusResponse> {
|
|
51
|
+
return useApiData<BillingStatusResponse>(BILLING_STATUS_ENDPOINT, options)
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
const CARD_EXPIRY_YEAR_MODULO = 100
|
|
@@ -5,24 +5,22 @@ export interface CurrentWorkspace {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
const CURRENT_ENDPOINT = '/api/saas/workspaces/current'
|
|
8
|
-
const STATE_KEY = 'saas-current-workspace'
|
|
9
8
|
|
|
10
9
|
interface CurrentWorkspaceHandle {
|
|
11
|
-
workspace: Ref<CurrentWorkspace | null
|
|
10
|
+
workspace: Readonly<Ref<CurrentWorkspace | null>>
|
|
12
11
|
load: () => Promise<void>
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* The current workspace's identity, read
|
|
17
|
-
*
|
|
15
|
+
* The current workspace's identity, read when a dialog needs it (the plan
|
|
16
|
+
* card names it in its cancellation copy).
|
|
18
17
|
*/
|
|
19
18
|
export function useCurrentWorkspace(): CurrentWorkspaceHandle {
|
|
20
|
-
const
|
|
21
|
-
const workspace = useDmsState<CurrentWorkspace | null>(STATE_KEY, () => null)
|
|
19
|
+
const current = useOnDemandRead<CurrentWorkspace>(() => CURRENT_ENDPOINT)
|
|
22
20
|
|
|
23
21
|
async function load(): Promise<void> {
|
|
24
|
-
|
|
22
|
+
await current.read()
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
return { workspace, load }
|
|
25
|
+
return { workspace: current.data, load }
|
|
28
26
|
}
|