@antelopejs/dms-saas 0.8.1 → 0.9.0
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 +20 -4
- package/dist/auth/owner-only-permissions-resolver.js.map +1 -1
- package/dist/auth/plan-permissions-resolver.js.map +1 -1
- package/dist/automation/index.js.map +1 -1
- package/dist/billing-state/directory-hooks.js.map +1 -1
- package/dist/billing-state/directory.js.map +1 -1
- package/dist/billing-state/past-due-banner.js.map +1 -1
- package/dist/billing-state/recovery.js +2 -1
- package/dist/billing-state/recovery.js.map +1 -1
- package/dist/billing-state/trial-ending-banner.js.map +1 -1
- package/dist/crons/hard-delete-cancelled.js.map +1 -1
- package/dist/data-api/platformOwner/admin-user-workspaces.js +1 -1
- package/dist/data-api/platformOwner/admin-user-workspaces.js.map +1 -1
- package/dist/data-api/platformOwner/credit-note-rows.d.ts +4 -4
- package/dist/data-api/platformOwner/credit-note-rows.js +2 -1
- package/dist/data-api/platformOwner/credit-note-rows.js.map +1 -1
- package/dist/data-api/platformOwner/credit-notes.d.ts +1 -1
- package/dist/data-api/platformOwner/credit-notes.js +1 -1
- package/dist/data-api/platformOwner/credit-notes.js.map +1 -1
- package/dist/data-api/platformOwner/features.js.map +1 -1
- package/dist/data-api/platformOwner/invitations.js.map +1 -1
- package/dist/data-api/platformOwner/invoice-cells.js.map +1 -1
- package/dist/data-api/platformOwner/invoice-rows.d.ts +5 -4
- package/dist/data-api/platformOwner/invoice-rows.js.map +1 -1
- package/dist/data-api/platformOwner/invoices.d.ts +5 -5
- package/dist/data-api/platformOwner/invoices.js +5 -4
- package/dist/data-api/platformOwner/invoices.js.map +1 -1
- package/dist/data-api/platformOwner/plan-migrations.js.map +1 -1
- package/dist/data-api/platformOwner/plans.d.ts +5 -5
- package/dist/data-api/platformOwner/plans.js.map +1 -1
- package/dist/data-api/platformOwner/segments.js.map +1 -1
- package/dist/data-api/platformOwner/table-scope.d.ts +2 -1
- package/dist/data-api/platformOwner/table-scope.js.map +1 -1
- package/dist/data-api/platformOwner/users.js +7 -6
- package/dist/data-api/platformOwner/users.js.map +1 -1
- package/dist/data-api/platformOwner/workspace-cells.d.ts +2 -2
- package/dist/data-api/platformOwner/workspace-cells.js +1 -1
- package/dist/data-api/platformOwner/workspace-cells.js.map +1 -1
- package/dist/data-api/platformOwner/workspaces.d.ts +6 -5
- package/dist/data-api/platformOwner/workspaces.js +7 -10
- package/dist/data-api/platformOwner/workspaces.js.map +1 -1
- package/dist/data-api/tenant/tenant-invoices.js.map +1 -1
- package/dist/frontend-module.js.map +1 -1
- package/dist/hooks/register.js.map +1 -1
- package/dist/hooks/tenant-export.js.map +1 -1
- package/dist/i18n/composed-text.js.map +1 -1
- package/dist/implementations/dms-saas/invoice-line-items.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/invoice-line-items/injection.d.ts +1 -1
- package/dist/invoice-line-items/injection.js.map +1 -1
- package/dist/invoice-line-items/recovery/discovery.js +11 -9
- package/dist/invoice-line-items/recovery/discovery.js.map +1 -1
- package/dist/invoice-line-items/recovery/managed-lines.js +18 -12
- package/dist/invoice-line-items/recovery/managed-lines.js.map +1 -1
- package/dist/metrics/activity-sources.js +1 -3
- package/dist/metrics/activity-sources.js.map +1 -1
- package/dist/metrics/activity.d.ts +3 -2
- package/dist/metrics/activity.js +19 -3
- package/dist/metrics/activity.js.map +1 -1
- package/dist/metrics/directory-summary.js +12 -4
- package/dist/metrics/directory-summary.js.map +1 -1
- package/dist/metrics/normalised-mrr.js.map +1 -1
- package/dist/metrics/revenue.d.ts +2 -2
- package/dist/metrics/revenue.js +3 -2
- package/dist/metrics/revenue.js.map +1 -1
- package/dist/operator-actions/commands.js +2 -1
- package/dist/operator-actions/commands.js.map +1 -1
- package/dist/operator-actions/db/lifecycle-delivery.model.js.map +1 -1
- package/dist/operator-actions/invitation-commands.d.ts +1 -1
- package/dist/operator-actions/invitation-commands.js +5 -27
- package/dist/operator-actions/invitation-commands.js.map +1 -1
- package/dist/operator-actions/journal.js +5 -2
- package/dist/operator-actions/journal.js.map +1 -1
- package/dist/operator-actions/lifecycle-consumers.js.map +1 -1
- package/dist/operator-actions/one-shot.d.ts +9 -0
- package/dist/operator-actions/one-shot.js +21 -0
- package/dist/operator-actions/one-shot.js.map +1 -0
- package/dist/operator-actions/types.d.ts +1 -1
- package/dist/operator-billing/billing-settings-store.js.map +1 -1
- package/dist/operator-billing/billing-stats.d.ts +2 -1
- package/dist/operator-billing/billing-stats.js +3 -2
- package/dist/operator-billing/billing-stats.js.map +1 -1
- package/dist/operator-billing/credit-allowance.d.ts +6 -3
- package/dist/operator-billing/credit-allowance.js.map +1 -1
- package/dist/operator-billing/credit-note-request.js.map +1 -1
- package/dist/operator-billing/invoice-credit.js +9 -3
- package/dist/operator-billing/invoice-credit.js.map +1 -1
- package/dist/operator-billing/legal-documents-store.js.map +1 -1
- package/dist/operator-billing/legal-versions.js +13 -8
- package/dist/operator-billing/legal-versions.js.map +1 -1
- package/dist/pages/platform/dashboard.js.map +1 -1
- package/dist/pages/platform/features.js.map +1 -1
- package/dist/pages/platform/plans/edit.js.map +1 -1
- package/dist/pages/platform/plans/index.js.map +1 -1
- package/dist/pages/platform/plans/migrations.js.map +1 -1
- package/dist/pages/platform/users/detail.js.map +1 -1
- package/dist/pages/platform/users/index.js.map +1 -1
- package/dist/pages/platform/workspaces/detail.js.map +1 -1
- package/dist/pages/platform/workspaces/index.js.map +1 -1
- package/dist/pages/public/index.js.map +1 -1
- package/dist/pages/public/legal/privacy-policy.js.map +1 -1
- package/dist/pages/public/legal/terms-and-conditions.js.map +1 -1
- package/dist/pages/public/legal/terms-of-use.js.map +1 -1
- package/dist/pages/public/pricing.js.map +1 -1
- package/dist/pages/public/register.js.map +1 -1
- package/dist/pages/public/screens.js +5 -2
- package/dist/pages/public/screens.js.map +1 -1
- package/dist/pages/tenant/billing.js.map +1 -1
- package/dist/pages/tenant/general.js.map +1 -1
- package/dist/pages/tenant/members-seat-quota.js.map +1 -1
- package/dist/pages/tenant/workspace-suspended.js.map +1 -1
- package/dist/plan-changes/applied-upgrade.d.ts +1 -1
- package/dist/plan-changes/applied-upgrade.js.map +1 -1
- package/dist/plan-changes/deferred.js.map +1 -1
- package/dist/plan-changes/guarded-free.js.map +1 -1
- package/dist/plan-changes/guarded-landing.js.map +1 -1
- package/dist/plan-changes/inventory-barrier.js.map +1 -1
- package/dist/plans/migration-blocks.js +6 -6
- package/dist/plans/migration-blocks.js.map +1 -1
- package/dist/plans/migration-dialogs.js.map +1 -1
- package/dist/plans/plan-diff.js +2 -1
- package/dist/plans/plan-diff.js.map +1 -1
- package/dist/plans/plan-permission-tree.js.map +1 -1
- package/dist/plans/plan-write.js +9 -7
- package/dist/plans/plan-write.js.map +1 -1
- package/dist/plans/seat-hooks.js.map +1 -1
- package/dist/plans/stripe-sync.js.map +1 -1
- package/dist/routes/platformOwner/dashboard.d.ts +2 -1
- package/dist/routes/platformOwner/dashboard.js.map +1 -1
- package/dist/routes/platformOwner/plan-deletion.js.map +1 -1
- package/dist/routes/platformOwner/plan-dialogs.d.ts +3 -2
- package/dist/routes/platformOwner/plan-dialogs.js.map +1 -1
- package/dist/routes/platformOwner/plan-migrations.d.ts +4 -2
- package/dist/routes/platformOwner/plan-migrations.js +2 -1
- package/dist/routes/platformOwner/plan-migrations.js.map +1 -1
- package/dist/routes/platformOwner/plans.d.ts +3 -2
- package/dist/routes/platformOwner/plans.js.map +1 -1
- package/dist/routes/platformOwner/platform-notes.js +3 -3
- package/dist/routes/platformOwner/platform-notes.js.map +1 -1
- package/dist/routes/platformOwner/segments-export.js.map +1 -1
- package/dist/routes/platformOwner/segments.js +2 -3
- package/dist/routes/platformOwner/segments.js.map +1 -1
- package/dist/routes/platformOwner/workspace-detail.d.ts +6 -2
- package/dist/routes/platformOwner/workspace-detail.js +10 -1
- package/dist/routes/platformOwner/workspace-detail.js.map +1 -1
- package/dist/routes/platformOwner/workspace-operator-actions.d.ts +2 -1
- package/dist/routes/platformOwner/workspace-operator-actions.js +4 -4
- package/dist/routes/platformOwner/workspace-operator-actions.js.map +1 -1
- package/dist/routes/platformOwner/workspaces-admin.d.ts +4 -2
- package/dist/routes/platformOwner/workspaces-admin.js +30 -7
- package/dist/routes/platformOwner/workspaces-admin.js.map +1 -1
- package/dist/routes/public/pricing.d.ts +2 -1
- package/dist/routes/public/pricing.js.map +1 -1
- package/dist/routes/public/public-plan-catalog.d.ts +2 -1
- package/dist/routes/public/public-plan-catalog.js +2 -1
- package/dist/routes/public/public-plan-catalog.js.map +1 -1
- package/dist/routes/public/register.d.ts +6 -3
- package/dist/routes/public/register.js +2 -1
- package/dist/routes/public/register.js.map +1 -1
- package/dist/routes/tenant/billing-pay-invoice.js.map +1 -1
- package/dist/routes/tenant/billing-portal.js.map +1 -1
- package/dist/routes/tenant/billing-self-refund.js.map +1 -1
- package/dist/routes/tenant/data-export.js.map +1 -1
- package/dist/routes/tenant/tenant-billing.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-authentication.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-cancellation.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-checkout-recovery.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-checkout.js +2 -3
- package/dist/routes/tenant/tenant-plan-checkout.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-ops.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-preview.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-resubscription.js.map +1 -1
- package/dist/routes/tenant/tenant-plan.d.ts +5 -3
- package/dist/routes/tenant/tenant-plan.js +4 -3
- package/dist/routes/tenant/tenant-plan.js.map +1 -1
- package/dist/routes/tenant/tenant-upcoming-invoice.js +2 -3
- package/dist/routes/tenant/tenant-upcoming-invoice.js.map +1 -1
- package/dist/routes/tenant/workspaces.d.ts +2 -1
- package/dist/routes/tenant/workspaces.js.map +1 -1
- package/dist/stripe/client.js +2 -1
- package/dist/stripe/client.js.map +1 -1
- package/dist/stripe/customer-billing.d.ts +1 -1
- package/dist/stripe/customer-billing.js +1 -1
- package/dist/stripe/customer-billing.js.map +1 -1
- package/dist/stripe/payload-shapes.d.ts +20 -5
- package/dist/stripe/payload-shapes.js +4 -4
- package/dist/stripe/payload-shapes.js.map +1 -1
- package/dist/stripe/pending-update.js +2 -1
- package/dist/stripe/pending-update.js.map +1 -1
- package/dist/stripe/plan-schedule.js +3 -2
- package/dist/stripe/plan-schedule.js.map +1 -1
- package/dist/stripe/sync-plan.js +9 -8
- package/dist/stripe/sync-plan.js.map +1 -1
- package/dist/stripe/webhook-checkout.d.ts +2 -2
- package/dist/stripe/webhook-checkout.js +5 -4
- package/dist/stripe/webhook-checkout.js.map +1 -1
- package/dist/stripe/webhook-credit-notes.d.ts +2 -2
- package/dist/stripe/webhook-credit-notes.js +2 -1
- package/dist/stripe/webhook-credit-notes.js.map +1 -1
- package/dist/stripe/webhook-dispatch.js +6 -2
- package/dist/stripe/webhook-dispatch.js.map +1 -1
- package/dist/stripe/webhook-handlers.d.ts +10 -10
- package/dist/stripe/webhook-handlers.js.map +1 -1
- package/dist/stripe/webhook-shared.d.ts +1 -1
- package/dist/stripe/webhook-shared.js +2 -1
- package/dist/stripe/webhook-shared.js.map +1 -1
- package/dist/stripe/workspace-checkout.js +2 -1
- package/dist/stripe/workspace-checkout.js.map +1 -1
- package/dist/upcoming-invoice/eligibility.js.map +1 -1
- package/dist/upcoming-invoice/preview.js.map +1 -1
- package/dist/upcoming-invoice/pricing.js +6 -2
- package/dist/upcoming-invoice/pricing.js.map +1 -1
- package/dist/users/user-facts.js.map +1 -1
- package/dist/utils/content-language.d.ts +3 -1
- package/dist/utils/content-language.js +2 -1
- package/dist/utils/content-language.js.map +1 -1
- package/dist/utils/keyed-insert.d.ts +3 -7
- package/dist/utils/keyed-insert.js.map +1 -1
- package/dist/utils/parse-future-date.js +2 -1
- package/dist/utils/parse-future-date.js.map +1 -1
- package/dist/utils/primitive-guards.d.ts +4 -0
- package/dist/utils/primitive-guards.js +19 -0
- package/dist/utils/primitive-guards.js.map +1 -0
- package/dist/utils/query-parameter.d.ts +1 -0
- package/dist/utils/query-parameter.js +3 -0
- package/dist/utils/query-parameter.js.map +1 -0
- package/dist/utils/row-instance.js.map +1 -1
- package/dist/utils/segment-conditions-type.js +2 -1
- package/dist/utils/segment-conditions-type.js.map +1 -1
- package/dist/utils/segment-evaluator.js +8 -7
- package/dist/utils/segment-evaluator.js.map +1 -1
- package/dist/utils/segment-explain.js +2 -1
- package/dist/utils/segment-explain.js.map +1 -1
- package/dist/utils/segment-matching.js.map +1 -1
- package/dist/utils/segment-validation.js +12 -13
- package/dist/utils/segment-validation.js.map +1 -1
- package/dist/utils/time.js +2 -1
- package/dist/utils/time.js.map +1 -1
- package/dist/workers/plan-migration.js.map +1 -1
- package/dist/workspaces/billing-identity.d.ts +3 -1
- package/dist/workspaces/billing-identity.js +10 -1
- package/dist/workspaces/billing-identity.js.map +1 -1
- package/dist/workspaces/default-plan.js.map +1 -1
- package/dist/workspaces/deletion.js.map +1 -1
- package/dist/workspaces/detail-items.js.map +1 -1
- package/dist/workspaces/operator-creation.js +2 -3
- package/dist/workspaces/operator-creation.js.map +1 -1
- package/dist/workspaces/owner-invitation-email.js.map +1 -1
- package/dist/workspaces/provisioning-types.d.ts +46 -0
- package/dist/workspaces/provisioning-types.js +3 -0
- package/dist/workspaces/provisioning-types.js.map +1 -0
- package/dist/workspaces/provisioning.d.ts +3 -45
- package/dist/workspaces/provisioning.js.map +1 -1
- package/dist/workspaces/registration-extras.js +13 -9
- package/dist/workspaces/registration-extras.js.map +1 -1
- package/dist/workspaces/self-serve-creation.js.map +1 -1
- package/dist/workspaces/subscription-create-params.js.map +1 -1
- package/frontend-vue/app/build/PayInvoicePanel.vue +3 -2
- package/frontend-vue/app/build/PlanChangeReview.vue +7 -6
- package/frontend-vue/app/build/components/RetirePlanDiff.vue +178 -0
- package/frontend-vue/app/build/public/OtherWorkspaces.vue +4 -11
- package/frontend-vue/app/build/public/registration-errors.ts +2 -0
- package/frontend-vue/app/build/workspace-detail/ComplimentaryDialog.vue +7 -5
- package/frontend-vue/app/build/workspace-detail/CreditDialog.vue +5 -4
- package/frontend-vue/app/build/workspace-detail/UpgradeDialog.vue +7 -5
- package/frontend-vue/app/build/workspace-detail/types.ts +1 -1
- package/frontend-vue/app/build/workspace-detail/useWorkspaceActions.ts +2 -7
- package/frontend-vue/app/build/workspace-paths.ts +12 -0
- package/frontend-vue/app/components/CustomerPortalButton.vue +4 -2
- package/frontend-vue/app/components/DataExport.vue +14 -14
- package/frontend-vue/app/components/DataExportHistory.vue +7 -12
- package/frontend-vue/app/components/IssueCreditNoteModal.vue +4 -7
- package/frontend-vue/app/components/LegalLayout.vue +5 -4
- package/frontend-vue/app/components/MigrationStripeCheck.vue +2 -5
- package/frontend-vue/app/components/PendingCheckoutModal.vue +2 -7
- package/frontend-vue/app/components/PlanTaxSync.vue +2 -6
- package/frontend-vue/app/components/PlanUpgradeModal.vue +10 -11
- package/frontend-vue/app/components/PlatformNotes.vue +4 -8
- package/frontend-vue/app/components/Pricing.vue +4 -2
- package/frontend-vue/app/components/RefundButton.vue +4 -2
- package/frontend-vue/app/components/RetirePlanModal.vue +16 -165
- package/frontend-vue/app/components/TenantBillingForm.vue +3 -7
- package/frontend-vue/app/components/TenantPlanCard.vue +11 -18
- package/frontend-vue/app/components/UserPlatformRoleCard.vue +2 -5
- package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +5 -3
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +12 -5
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +8 -3
- package/frontend-vue/app/components/WorkspaceDetailHeader.vue +16 -13
- package/frontend-vue/app/components/WorkspaceInvitationLink.vue +3 -2
- package/frontend-vue/app/components/WorkspaceOperatorActions.vue +17 -4
- package/frontend-vue/app/components/WorkspaceSuspended.vue +6 -13
- package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +21 -15
- package/frontend-vue/app/composables/useApiErrorMessage.ts +4 -33
- package/frontend-vue/app/composables/useInvitationLink.ts +14 -11
- package/frontend-vue/app/composables/useSaasRegistration.ts +14 -72
- package/frontend-vue/app/composables/useSaasRegistrationPlan.ts +73 -0
- package/frontend-vue/app/custom-pages/auth/no-workspace.vue +14 -11
- package/frontend-vue/build/backend-boundary.ts +122 -0
- package/frontend-vue/dms.frontend.build.ts +2 -0
- package/frontend-vue/i18n/locales/saas-operator-dashboard-en-GB.json +66 -0
- package/frontend-vue/i18n/locales/saas-operator-dashboard-fr-FR.json +66 -0
- package/frontend-vue/i18n/locales/saas-operator-workspaces-en-GB.json +13 -65
- package/frontend-vue/i18n/locales/saas-operator-workspaces-fr-FR.json +13 -65
- package/frontend-vue/i18n/locales/saas-public-en-GB.json +2 -4
- package/frontend-vue/i18n/locales/saas-public-fr-FR.json +2 -4
- package/frontend-vue/i18n/locales/saas-tenant-workspace-en-GB.json +0 -1
- package/frontend-vue/i18n/locales/saas-tenant-workspace-fr-FR.json +0 -1
- package/frontend-vue/package.json +1 -1
- package/package.json +10 -11
- package/skills/dms-saas/SKILL.md +2 -3
- package/skills/dms-saas/cases.json +48 -0
|
@@ -13,7 +13,7 @@ const { t } = useI18n()
|
|
|
13
13
|
const { $authFetch } = useAuthFetch()
|
|
14
14
|
const { confirmFrom } = useConfirmFrom()
|
|
15
15
|
const toast = useToast()
|
|
16
|
-
const {
|
|
16
|
+
const { presentError } = useApiErrorPresenter()
|
|
17
17
|
const detail = useUserDetail(() => props.routeParams)
|
|
18
18
|
const user = computed(() => detail.data.value)
|
|
19
19
|
const isOpening = ref(false)
|
|
@@ -37,10 +37,7 @@ async function openConfirm(): Promise<void> {
|
|
|
37
37
|
onConfirm: () => runChange(kind),
|
|
38
38
|
})
|
|
39
39
|
} catch (error) {
|
|
40
|
-
|
|
41
|
-
color: 'error',
|
|
42
|
-
title: resolveApiError(error, `${I18N}.confirm_failed`),
|
|
43
|
-
})
|
|
40
|
+
presentError(error, { fallbackKey: `${I18N}.confirm_failed` })
|
|
44
41
|
} finally {
|
|
45
42
|
isOpening.value = false
|
|
46
43
|
}
|
|
@@ -52,7 +52,7 @@ const { $authFetch } = useAuthFetch()
|
|
|
52
52
|
const { t, locale } = useI18n()
|
|
53
53
|
const toast = useToast()
|
|
54
54
|
const router = useDmsRouter()
|
|
55
|
-
const {
|
|
55
|
+
const { resolveError } = useApiErrorPresenter()
|
|
56
56
|
|
|
57
57
|
const plans = ref<PlanOption[]>([])
|
|
58
58
|
const loadError = ref<string | null>(null)
|
|
@@ -164,7 +164,8 @@ async function loadPlans(): Promise<void> {
|
|
|
164
164
|
const all = await plansRead.read()
|
|
165
165
|
plans.value = all.filter((option) => option.isActive && !option.isDeleted)
|
|
166
166
|
} catch (error) {
|
|
167
|
-
loadError.value =
|
|
167
|
+
loadError.value =
|
|
168
|
+
resolveError(error, { fallbackKey: `${C}.load_error` })?.message ?? ''
|
|
168
169
|
} finally {
|
|
169
170
|
isLoading.value = false
|
|
170
171
|
}
|
|
@@ -237,7 +238,8 @@ async function submit(): Promise<void> {
|
|
|
237
238
|
notifyCreated(created)
|
|
238
239
|
props.onSuccessCallback?.()
|
|
239
240
|
} catch (error) {
|
|
240
|
-
submitError.value =
|
|
241
|
+
submitError.value =
|
|
242
|
+
resolveError(error, { fallbackKey: `${C}.error` })?.message ?? ''
|
|
241
243
|
} finally {
|
|
242
244
|
isSubmitting.value = false
|
|
243
245
|
}
|
|
@@ -65,7 +65,7 @@ const CARD_ERROR_KEYS = new Set([
|
|
|
65
65
|
|
|
66
66
|
const { $authFetch } = useAuthFetch()
|
|
67
67
|
const { t, locale } = useI18n()
|
|
68
|
-
const {
|
|
68
|
+
const { resolveError } = useApiErrorPresenter()
|
|
69
69
|
const { formatMajorUnits } = useMoneyFormat()
|
|
70
70
|
const planPriceLabel = usePlanPriceLabel()
|
|
71
71
|
const planIntervalLabel = usePlanIntervalLabel(`${KEYS}.interval`)
|
|
@@ -184,7 +184,9 @@ async function setUpCard(): Promise<void> {
|
|
|
184
184
|
await initStripeElement()
|
|
185
185
|
} catch (error) {
|
|
186
186
|
cardSetup = null
|
|
187
|
-
cardError.value =
|
|
187
|
+
cardError.value =
|
|
188
|
+
resolveError(error, { fallbackKey: `${KEYS}.error.card_setup` })
|
|
189
|
+
?.message ?? ''
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
|
|
@@ -205,7 +207,9 @@ async function load(): Promise<void> {
|
|
|
205
207
|
options.value = await optionsRead.read()
|
|
206
208
|
selectedPlanId.value ??= options.value.plans[0]?._id ?? null
|
|
207
209
|
} catch (error) {
|
|
208
|
-
loadError.value =
|
|
210
|
+
loadError.value =
|
|
211
|
+
resolveError(error, { fallbackKey: `${KEYS}.error.load_description` })
|
|
212
|
+
?.message ?? ''
|
|
209
213
|
} finally {
|
|
210
214
|
isLoading.value = false
|
|
211
215
|
}
|
|
@@ -236,7 +240,8 @@ async function confirmCard(): Promise<ConfirmedPayment> {
|
|
|
236
240
|
}
|
|
237
241
|
|
|
238
242
|
function reportSubmitError(error: unknown): void {
|
|
239
|
-
const message =
|
|
243
|
+
const message =
|
|
244
|
+
resolveError(error, { fallbackKey: `${KEYS}.error.failed` })?.message ?? ''
|
|
240
245
|
if (CARD_ERROR_KEYS.has(readApiErrorKey(error) ?? '')) {
|
|
241
246
|
cardError.value = message
|
|
242
247
|
return
|
|
@@ -251,7 +256,9 @@ async function renewCard(): Promise<void> {
|
|
|
251
256
|
try {
|
|
252
257
|
await stripeHandle.value?.renew(await createSetupIntent())
|
|
253
258
|
} catch (error) {
|
|
254
|
-
cardError.value =
|
|
259
|
+
cardError.value =
|
|
260
|
+
resolveError(error, { fallbackKey: `${KEYS}.error.card_setup` })
|
|
261
|
+
?.message ?? ''
|
|
255
262
|
}
|
|
256
263
|
}
|
|
257
264
|
|
|
@@ -15,7 +15,7 @@ const DATE_FORMAT: Intl.DateTimeFormatOptions = {
|
|
|
15
15
|
const { t, locale } = useI18n()
|
|
16
16
|
const { $authFetch } = useAuthFetch()
|
|
17
17
|
const { confirm } = useConfirm()
|
|
18
|
-
const {
|
|
18
|
+
const { resolveError } = useApiErrorPresenter()
|
|
19
19
|
const toast = useToast()
|
|
20
20
|
// The deletion asks for the name as it is now: a rename on this page reads
|
|
21
21
|
// the page's data again, this overview included.
|
|
@@ -108,11 +108,16 @@ async function deleteWorkspace(view: WorkspaceOverview): Promise<void> {
|
|
|
108
108
|
body: { confirmName: view.name },
|
|
109
109
|
})
|
|
110
110
|
} catch (failure) {
|
|
111
|
-
const message =
|
|
111
|
+
const message =
|
|
112
|
+
resolveError(failure, { fallbackKey: `${KEYS}.error.delete` })?.message ??
|
|
113
|
+
''
|
|
112
114
|
if (readApiErrorKey(failure) === CONFIRMATION_MISMATCH) {
|
|
113
115
|
throw new ConfirmTextError(message)
|
|
114
116
|
}
|
|
115
|
-
throw new
|
|
117
|
+
throw new ConfirmActionError(
|
|
118
|
+
{ fallbackKey: `${KEYS}.error.delete` },
|
|
119
|
+
{ cause: failure },
|
|
120
|
+
)
|
|
116
121
|
}
|
|
117
122
|
toast.add({
|
|
118
123
|
title: t(`${KEYS}.delete.deleted`, { name: view.name }),
|
|
@@ -25,6 +25,7 @@ const WORKSPACE_HOME = '/'
|
|
|
25
25
|
const tenantId = props.routeParams?.id ?? ''
|
|
26
26
|
const { t, locale } = useI18n()
|
|
27
27
|
const toast = useToast()
|
|
28
|
+
const { presentError } = useApiErrorPresenter()
|
|
28
29
|
const route = useDmsRoute()
|
|
29
30
|
const router = useDmsRouter()
|
|
30
31
|
const { statusView } = useSaasStatus()
|
|
@@ -66,12 +67,8 @@ async function copyLink(): Promise<void> {
|
|
|
66
67
|
async function openWorkspace(): Promise<void> {
|
|
67
68
|
try {
|
|
68
69
|
await useTenantSwitch(tenantId, WORKSPACE_HOME)
|
|
69
|
-
} catch {
|
|
70
|
-
|
|
71
|
-
title: t(`${D}.open_error`),
|
|
72
|
-
color: 'error',
|
|
73
|
-
icon: 'i-ph-warning-circle',
|
|
74
|
-
})
|
|
70
|
+
} catch (error) {
|
|
71
|
+
presentError(error, { fallbackKey: `${D}.open_error` })
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
|
|
@@ -93,9 +90,11 @@ const menu = computed<DropdownMenuItem[][]>(() => {
|
|
|
93
90
|
const current = overview.value
|
|
94
91
|
const support: DropdownMenuItem[] = [
|
|
95
92
|
{
|
|
96
|
-
label: current?.
|
|
93
|
+
label: current?.membership
|
|
94
|
+
? t(`${D}.${current.membership.role}`)
|
|
95
|
+
: t(`${D}.join`),
|
|
97
96
|
icon: 'i-ph-user-plus',
|
|
98
|
-
disabled: !!current?.
|
|
97
|
+
disabled: !!current?.membership,
|
|
99
98
|
onSelect: () => void actions.join(),
|
|
100
99
|
},
|
|
101
100
|
{
|
|
@@ -226,22 +225,26 @@ onMounted(() => {
|
|
|
226
225
|
<span>
|
|
227
226
|
{{ $t(`${D}.created`, { date: day(overview.createdAt) }) }}
|
|
228
227
|
</span>
|
|
229
|
-
<span v-if="overview.
|
|
230
|
-
{{
|
|
228
|
+
<span v-if="overview.membership" class="text-success">
|
|
229
|
+
{{
|
|
230
|
+
$t(`${D}.membership_${overview.membership.role}`, {
|
|
231
|
+
date: day(overview.membership.joinedAt),
|
|
232
|
+
})
|
|
233
|
+
}}
|
|
231
234
|
</span>
|
|
232
235
|
</div>
|
|
233
236
|
</div>
|
|
234
237
|
<div class="flex shrink-0 items-center gap-2">
|
|
235
238
|
<UBadge
|
|
236
|
-
v-if="overview.
|
|
239
|
+
v-if="overview.membership"
|
|
237
240
|
color="success"
|
|
238
241
|
variant="subtle"
|
|
239
242
|
icon="i-ph-check"
|
|
240
243
|
>
|
|
241
|
-
{{ $t(`${D}.
|
|
244
|
+
{{ $t(`${D}.${overview.membership.role}`) }}
|
|
242
245
|
</UBadge>
|
|
243
246
|
<UButton
|
|
244
|
-
v-if="overview.
|
|
247
|
+
v-if="overview.membership"
|
|
245
248
|
color="neutral"
|
|
246
249
|
variant="outline"
|
|
247
250
|
icon="i-ph-arrow-square-out"
|
|
@@ -21,7 +21,7 @@ const props = defineProps<{
|
|
|
21
21
|
const L = 'saas.workspace_detail.invitations.link'
|
|
22
22
|
|
|
23
23
|
const { locale } = useI18n()
|
|
24
|
-
const {
|
|
24
|
+
const { resolveError } = useApiErrorPresenter()
|
|
25
25
|
const { fetchInvitationLink, copyLink } = useInvitationLink()
|
|
26
26
|
|
|
27
27
|
const link = ref<string | null>(null)
|
|
@@ -45,7 +45,8 @@ async function load(): Promise<void> {
|
|
|
45
45
|
link.value = invitation.link
|
|
46
46
|
expiresAt.value = invitation.expiresAt
|
|
47
47
|
} catch (error) {
|
|
48
|
-
errorMessage.value =
|
|
48
|
+
errorMessage.value =
|
|
49
|
+
resolveError(error, { fallbackKey: `${L}.error` })?.message ?? ''
|
|
49
50
|
} finally {
|
|
50
51
|
isLoading.value = false
|
|
51
52
|
}
|
|
@@ -24,7 +24,7 @@ interface OperatorRow {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const tenantId = props.routeParams?.id ?? ''
|
|
27
|
-
const { t } = useI18n()
|
|
27
|
+
const { t, locale } = useI18n()
|
|
28
28
|
const { overview, isLoading, hasError, load } = useWorkspaceOverview(tenantId)
|
|
29
29
|
const actions = useWorkspaceActions(tenantId)
|
|
30
30
|
const dialogs = ref<InstanceType<typeof WorkspaceActionDialogs> | null>(null)
|
|
@@ -61,9 +61,22 @@ const rows = computed<OperatorRow[]>(() => {
|
|
|
61
61
|
{
|
|
62
62
|
id: 'join',
|
|
63
63
|
icon: 'i-ph-user-plus',
|
|
64
|
-
title: current?.
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
title: current?.membership
|
|
65
|
+
? t(`${D}.${current.membership.role}`)
|
|
66
|
+
: t(`${D}.join`),
|
|
67
|
+
description:
|
|
68
|
+
current?.membership && current.membership.role !== 'support'
|
|
69
|
+
? t(
|
|
70
|
+
`saas.workspace_detail.header.membership_${current.membership.role}`,
|
|
71
|
+
{
|
|
72
|
+
date:
|
|
73
|
+
formatDate(current.membership.joinedAt, locale.value, {
|
|
74
|
+
dateStyle: 'medium',
|
|
75
|
+
}) ?? '—',
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
: t(`${D}.join_description`),
|
|
79
|
+
isDisabled: !!current?.membership,
|
|
67
80
|
run: () => void actions.join(),
|
|
68
81
|
},
|
|
69
82
|
]
|
|
@@ -37,10 +37,9 @@ interface PortalSession {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const { t, locale } = useI18n()
|
|
40
|
-
const toast = useToast()
|
|
41
40
|
const { $authFetch } = useAuthFetch()
|
|
42
41
|
const { user, clear: clearSession } = useDmsUserSession()
|
|
43
|
-
const {
|
|
42
|
+
const { presentError, resolveError } = useApiErrorPresenter()
|
|
44
43
|
const { formatMinorUnits } = useMoneyFormat()
|
|
45
44
|
const { statusView } = useSaasStatus()
|
|
46
45
|
|
|
@@ -49,10 +48,9 @@ const access = accessRead.data
|
|
|
49
48
|
const isLoading = computed(() => accessRead.pending.value)
|
|
50
49
|
const loadError = computed(() =>
|
|
51
50
|
accessRead.error.value
|
|
52
|
-
?
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
51
|
+
? (resolveError(accessRead.error.value, {
|
|
52
|
+
fallbackKey: 'saas.public.suspended.load_error',
|
|
53
|
+
})?.message ?? '')
|
|
56
54
|
: null,
|
|
57
55
|
)
|
|
58
56
|
const isOpeningPortal = ref(false)
|
|
@@ -175,13 +173,8 @@ async function openPortal(): Promise<void> {
|
|
|
175
173
|
})
|
|
176
174
|
window.location.href = session.url
|
|
177
175
|
} catch (error) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
title: t('saas.public.suspended.owner.portal_failed'),
|
|
181
|
-
description: resolveApiError(
|
|
182
|
-
error,
|
|
183
|
-
'saas.public.suspended.owner.portal_failed_hint',
|
|
184
|
-
),
|
|
176
|
+
presentError(error, {
|
|
177
|
+
fallbackKey: 'saas.public.suspended.owner.portal_failed',
|
|
185
178
|
})
|
|
186
179
|
} finally {
|
|
187
180
|
isOpeningPortal.value = false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, watch } from 'vue'
|
|
3
|
-
import { HOME_PATH } from '../build/workspace-paths'
|
|
3
|
+
import { HOME_PATH, workspaceSwitchLandingPath } from '../build/workspace-paths'
|
|
4
4
|
import WorkspaceSwitcherRow from '../build/WorkspaceSwitcherRow.vue'
|
|
5
5
|
|
|
6
6
|
// Drawn as two roots: attributes have no single element to land on.
|
|
@@ -13,9 +13,11 @@ const props = defineProps<{
|
|
|
13
13
|
const KEYS = 'saas.workspace.switcher'
|
|
14
14
|
const SEARCH_THRESHOLD = 6
|
|
15
15
|
const PAST_DUE_STATUS = 'past_due'
|
|
16
|
-
const
|
|
16
|
+
const { presentError } = useApiErrorPresenter()
|
|
17
17
|
const { t } = useI18n()
|
|
18
18
|
const { statusView } = useSaasStatus()
|
|
19
|
+
const route = useDmsRoute()
|
|
20
|
+
const siteLayout = useSiteLayout()
|
|
19
21
|
|
|
20
22
|
// Platform owners are not tenant members by default, so an owner can legitimately
|
|
21
23
|
// have no workspace at all — the switcher must still offer them a way in.
|
|
@@ -80,15 +82,14 @@ function initialOf(name: string): string {
|
|
|
80
82
|
return (name.trim()[0] ?? '?').toUpperCase()
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
function reportSwitchFailure(
|
|
85
|
+
function reportSwitchFailure(
|
|
86
|
+
error: unknown,
|
|
87
|
+
target: MyWorkspace | string,
|
|
88
|
+
): void {
|
|
84
89
|
const name = typeof target === 'string' ? target : target.name
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
? t(`${KEYS}.still_in`, { name: current.value.name })
|
|
89
|
-
: undefined,
|
|
90
|
-
color: 'error',
|
|
91
|
-
icon: 'i-ph-warning-circle',
|
|
90
|
+
presentError(error, {
|
|
91
|
+
fallbackKey: `${KEYS}.switch_failed`,
|
|
92
|
+
params: { name },
|
|
92
93
|
})
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -97,10 +98,15 @@ async function selectWorkspace(workspace: MyWorkspace): Promise<void> {
|
|
|
97
98
|
if (workspace.isCurrent || switchingId.value) return
|
|
98
99
|
switchingId.value = workspace._id
|
|
99
100
|
try {
|
|
100
|
-
await useTenantSwitch(
|
|
101
|
-
|
|
101
|
+
await useTenantSwitch(
|
|
102
|
+
workspace._id,
|
|
103
|
+
workspaceSwitchLandingPath(
|
|
104
|
+
siteLayout.findMatchingRoute(route.path)?.metadata,
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
} catch (error) {
|
|
102
108
|
switchingId.value = null
|
|
103
|
-
reportSwitchFailure(workspace)
|
|
109
|
+
reportSwitchFailure(error, workspace)
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
|
|
@@ -122,8 +128,8 @@ async function onWorkspaceCreated(
|
|
|
122
128
|
// Lands on the homepage rather than reloading the screen the creation
|
|
123
129
|
// was started from — that screen belongs to the previous workspace.
|
|
124
130
|
await useTenantSwitch(tenantId, HOME_PATH)
|
|
125
|
-
} catch {
|
|
126
|
-
reportSwitchFailure(name)
|
|
131
|
+
} catch (error) {
|
|
132
|
+
reportSwitchFailure(error, name)
|
|
127
133
|
await load()
|
|
128
134
|
}
|
|
129
135
|
}
|
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
/** The i18n key the server answered a failed `$authFetch` with, if any. */
|
|
2
2
|
export function readApiErrorKey(error: unknown): string | undefined {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Resolves an unknown error thrown by `$authFetch` into a human-readable,
|
|
11
|
-
* translated message.
|
|
12
|
-
*
|
|
13
|
-
* The backend signals failures with `assert(cond, status, "i18n.key")`, which
|
|
14
|
-
* serializes the i18n key as the response body. ofetch exposes that body on
|
|
15
|
-
* `error.data` (a string, or `{ message }` for some handlers), while
|
|
16
|
-
* `error.message` only holds the generic "POST <url> 409" text — never show
|
|
17
|
-
* that to the user. We translate the server key when it exists, otherwise fall
|
|
18
|
-
* back to a caller-provided generic key.
|
|
19
|
-
*/
|
|
20
|
-
export function useApiErrorMessage() {
|
|
21
|
-
const nuxtApp = useDmsApp();
|
|
22
|
-
|
|
23
|
-
/** Translated server message, or `undefined` when the server sent no usable key. */
|
|
24
|
-
function resolveServerMessage(error: unknown): string | undefined {
|
|
25
|
-
const { t, te } = nuxtApp.$i18n;
|
|
26
|
-
const key = readApiErrorKey(error);
|
|
27
|
-
return key && te(key) ? t(key) : undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Translated server message, or the caller's generic fallback key. */
|
|
31
|
-
function resolveApiError(error: unknown, fallbackKey: string): string {
|
|
32
|
-
return resolveServerMessage(error) ?? nuxtApp.$i18n.t(fallbackKey);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return { resolveApiError, resolveServerMessage };
|
|
3
|
+
const data = (error as { data?: unknown } | undefined)?.data
|
|
4
|
+
if (typeof data === 'string') return data
|
|
5
|
+
const message = (data as { message?: unknown } | undefined)?.message
|
|
6
|
+
return typeof message === 'string' ? message : undefined
|
|
36
7
|
}
|
|
@@ -29,26 +29,29 @@ export function useInvitationLink() {
|
|
|
29
29
|
/** Returns whether the link reached the clipboard. */
|
|
30
30
|
async function copyLink(link: string): Promise<boolean> {
|
|
31
31
|
const t = nuxtApp.$i18n.t
|
|
32
|
+
let copied: boolean
|
|
32
33
|
try {
|
|
33
34
|
await navigator.clipboard.writeText(link)
|
|
35
|
+
copied = true
|
|
36
|
+
} catch {
|
|
37
|
+
copied = false
|
|
38
|
+
}
|
|
39
|
+
if (copied) {
|
|
34
40
|
toast.add({
|
|
35
41
|
title: t('saas.workspace_detail.invitations.link.copied'),
|
|
36
42
|
color: 'success',
|
|
37
43
|
icon: 'i-ph-check-circle',
|
|
38
44
|
})
|
|
39
45
|
return true
|
|
40
|
-
} catch {
|
|
41
|
-
// The clipboard can be refused (permissions, insecure origin): the link
|
|
42
|
-
// stays readable so it can still be copied by hand.
|
|
43
|
-
toast.add({
|
|
44
|
-
title: t('saas.workspace_detail.invitations.link.copy_failed'),
|
|
45
|
-
description: link,
|
|
46
|
-
color: 'warning',
|
|
47
|
-
icon: 'i-ph-warning',
|
|
48
|
-
duration: 0,
|
|
49
|
-
})
|
|
50
|
-
return false
|
|
51
46
|
}
|
|
47
|
+
toast.add({
|
|
48
|
+
title: t('saas.workspace_detail.invitations.link.copy_failed'),
|
|
49
|
+
description: link,
|
|
50
|
+
color: 'warning',
|
|
51
|
+
icon: 'i-ph-warning',
|
|
52
|
+
duration: 0,
|
|
53
|
+
})
|
|
54
|
+
return false
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
return { fetchInvitationLink, copyLink }
|
|
@@ -7,21 +7,12 @@ import {
|
|
|
7
7
|
toRef,
|
|
8
8
|
toValue,
|
|
9
9
|
} from 'vue'
|
|
10
|
-
import {
|
|
10
|
+
import { REGISTER_PLAN_PARAM } from '../build/public/routes'
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from '
|
|
15
|
-
import {
|
|
16
|
-
billingUpgradePath,
|
|
17
|
-
LOGIN_PATH,
|
|
18
|
-
loginPathThen,
|
|
19
|
-
REGISTER_PLAN_PARAM,
|
|
20
|
-
} from '../build/public/routes'
|
|
21
|
-
import {
|
|
22
|
-
onPublicLocaleChange,
|
|
23
|
-
usePublicFetch,
|
|
24
|
-
} from '../build/public/usePublicFetch'
|
|
12
|
+
registrationLandingPath,
|
|
13
|
+
useSaasRegistrationPlan,
|
|
14
|
+
} from './useSaasRegistrationPlan'
|
|
15
|
+
import { REGISTRATION_LOAD_ERROR_KEY } from '../build/public/registration-errors'
|
|
25
16
|
|
|
26
17
|
export interface RegistrationForm {
|
|
27
18
|
email: string
|
|
@@ -121,14 +112,12 @@ type PaymentStepRule = (skipsPaymentMethod: boolean) => boolean
|
|
|
121
112
|
|
|
122
113
|
const SETUP_INTENT_ENDPOINT = '/api/saas/register/setup-intent'
|
|
123
114
|
const REGISTER_ENDPOINT = '/api/saas/register'
|
|
124
|
-
const REGISTRATION_PLAN_ENDPOINT = '/api/saas/register/plan'
|
|
125
115
|
const DEFAULT_PAYMENT_ELEMENT_ID = 'dms-saas-register-payment-element'
|
|
126
116
|
const DEFAULT_PAYMENT_POLICY: RegistrationPaymentMethodPolicy = 'required'
|
|
127
117
|
const INVITATION_ONLY = 'invitation-only'
|
|
128
118
|
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
|
129
119
|
const DEFAULT_WORKSPACE_NAME_KEY = 'saas.public.register.default_workspace_name'
|
|
130
120
|
const NO_PAYMENT_ERROR_KEY = 'saas.public.register.error.card_required'
|
|
131
|
-
const LOAD_ERROR_KEY = 'saas.public.register.error.load'
|
|
132
121
|
const SUBMIT_ERROR_KEY = 'saas.public.register.error.failed'
|
|
133
122
|
const PASSWORD_POLICY_ERROR_KEY = 'saas.errors.registration.password_policy'
|
|
134
123
|
|
|
@@ -268,20 +257,6 @@ export function isRegistrationClosedBy(
|
|
|
268
257
|
return config?.admissionMode === INVITATION_ONLY
|
|
269
258
|
}
|
|
270
259
|
|
|
271
|
-
/**
|
|
272
|
-
* Where a new account lands: sign-in, then the upgrade review on Billing
|
|
273
|
-
* when the visitor chose a paid plan on Pricing.
|
|
274
|
-
*
|
|
275
|
-
* @param summary The registration plan summary, when it loaded
|
|
276
|
-
*/
|
|
277
|
-
export function registrationLandingPath(
|
|
278
|
-
summary: RegistrationPlanSummary | null,
|
|
279
|
-
): string {
|
|
280
|
-
const requested = summary?.requestedPlan
|
|
281
|
-
if (!requested || !isPaidPlan(requested)) return LOGIN_PATH
|
|
282
|
-
return loginPathThen(billingUpgradePath(requested._id))
|
|
283
|
-
}
|
|
284
|
-
|
|
285
260
|
/**
|
|
286
261
|
* The consumer's capture, detached from the consumer.
|
|
287
262
|
*
|
|
@@ -300,44 +275,6 @@ export function snapshotRegistrationExtras(
|
|
|
300
275
|
return JSON.parse(JSON.stringify(extras)) as Record<string, unknown>
|
|
301
276
|
}
|
|
302
277
|
|
|
303
|
-
/**
|
|
304
|
-
* The plan a registration opens the workspace on, and the one chosen on
|
|
305
|
-
* Pricing, loaded for display. The chosen plan is remembered for the tab, so
|
|
306
|
-
* the OAuth round-trip back to "Set up your first workspace" keeps it.
|
|
307
|
-
*
|
|
308
|
-
* @param planReference Slug or id of the chosen plan
|
|
309
|
-
*/
|
|
310
|
-
export function useSaasRegistrationPlan(
|
|
311
|
-
planReference: MaybeRefOrGetter<string | null | undefined>,
|
|
312
|
-
) {
|
|
313
|
-
const publicFetch = usePublicFetch()
|
|
314
|
-
const { resolveApiError } = useApiErrorMessage()
|
|
315
|
-
const summary = ref<RegistrationPlanSummary | null>(null)
|
|
316
|
-
const isLoading = ref(false)
|
|
317
|
-
const loadError = ref<string | null>(null)
|
|
318
|
-
|
|
319
|
-
async function load(): Promise<void> {
|
|
320
|
-
isLoading.value = true
|
|
321
|
-
loadError.value = null
|
|
322
|
-
const plan = toValue(planReference) || undefined
|
|
323
|
-
try {
|
|
324
|
-
summary.value = await publicFetch<RegistrationPlanSummary>(
|
|
325
|
-
REGISTRATION_PLAN_ENDPOINT,
|
|
326
|
-
{ query: plan ? { [REGISTER_PLAN_PARAM]: plan } : {} },
|
|
327
|
-
)
|
|
328
|
-
rememberChosenPlan(summary.value.requestedPlan?._id ?? null)
|
|
329
|
-
} catch (error) {
|
|
330
|
-
loadError.value = resolveApiError(error, LOAD_ERROR_KEY)
|
|
331
|
-
} finally {
|
|
332
|
-
isLoading.value = false
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
onPublicLocaleChange(load)
|
|
337
|
-
|
|
338
|
-
return { summary, isLoading, loadError, load }
|
|
339
|
-
}
|
|
340
|
-
|
|
341
278
|
/**
|
|
342
279
|
* The public registration flow, without a single line of presentation.
|
|
343
280
|
*
|
|
@@ -363,7 +300,7 @@ export function useSaasRegistrationPlan(
|
|
|
363
300
|
*/
|
|
364
301
|
export function useSaasRegistration(options: UseSaasRegistrationOptions = {}) {
|
|
365
302
|
const { $authFetch } = useAuthFetch()
|
|
366
|
-
const {
|
|
303
|
+
const { resolveError } = useApiErrorPresenter()
|
|
367
304
|
const { $i18n } = useDmsApp()
|
|
368
305
|
const config = useDmsRuntimeConfig()
|
|
369
306
|
const route = useDmsRoute()
|
|
@@ -518,14 +455,17 @@ export function useSaasRegistration(options: UseSaasRegistrationOptions = {}) {
|
|
|
518
455
|
const clientSecret = await createSetupIntent()
|
|
519
456
|
if (clientSecret) await stripeHandle.value?.renew(clientSecret)
|
|
520
457
|
} catch (error) {
|
|
521
|
-
errorMessage.value =
|
|
458
|
+
errorMessage.value =
|
|
459
|
+
resolveError(error, { fallbackKey: REGISTRATION_LOAD_ERROR_KEY })
|
|
460
|
+
?.message ?? ''
|
|
522
461
|
}
|
|
523
462
|
}
|
|
524
463
|
|
|
525
464
|
function reportFailure(error: unknown): void {
|
|
526
465
|
const field = registrationFieldOf(readApiErrorKey(error))
|
|
527
466
|
if (!field) {
|
|
528
|
-
errorMessage.value =
|
|
467
|
+
errorMessage.value =
|
|
468
|
+
resolveError(error, { fallbackKey: SUBMIT_ERROR_KEY })?.message ?? ''
|
|
529
469
|
return
|
|
530
470
|
}
|
|
531
471
|
serverFieldErrors.value = {
|
|
@@ -610,7 +550,9 @@ export function useSaasRegistration(options: UseSaasRegistrationOptions = {}) {
|
|
|
610
550
|
try {
|
|
611
551
|
await mountPaymentElement()
|
|
612
552
|
} catch (error) {
|
|
613
|
-
errorMessage.value =
|
|
553
|
+
errorMessage.value =
|
|
554
|
+
resolveError(error, { fallbackKey: REGISTRATION_LOAD_ERROR_KEY })
|
|
555
|
+
?.message ?? ''
|
|
614
556
|
} finally {
|
|
615
557
|
isLoading.value = false
|
|
616
558
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, ref, toValue } from 'vue'
|
|
2
|
+
import { rememberChosenPlan } from '../build/public/chosen-plan'
|
|
3
|
+
import {
|
|
4
|
+
isPaidPlan,
|
|
5
|
+
type RegistrationPlanSummary,
|
|
6
|
+
} from '../build/public/pricing'
|
|
7
|
+
import {
|
|
8
|
+
billingUpgradePath,
|
|
9
|
+
LOGIN_PATH,
|
|
10
|
+
loginPathThen,
|
|
11
|
+
REGISTER_PLAN_PARAM,
|
|
12
|
+
} from '../build/public/routes'
|
|
13
|
+
import {
|
|
14
|
+
onPublicLocaleChange,
|
|
15
|
+
usePublicFetch,
|
|
16
|
+
} from '../build/public/usePublicFetch'
|
|
17
|
+
import { REGISTRATION_LOAD_ERROR_KEY } from '../build/public/registration-errors'
|
|
18
|
+
|
|
19
|
+
const REGISTRATION_PLAN_ENDPOINT = '/api/saas/register/plan'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Where a new account lands: sign-in, then the upgrade review on Billing
|
|
23
|
+
* when the visitor chose a paid plan on Pricing.
|
|
24
|
+
*
|
|
25
|
+
* @param summary The registration plan summary, when it loaded
|
|
26
|
+
*/
|
|
27
|
+
export function registrationLandingPath(
|
|
28
|
+
summary: RegistrationPlanSummary | null,
|
|
29
|
+
): string {
|
|
30
|
+
const requested = summary?.requestedPlan
|
|
31
|
+
if (!requested || !isPaidPlan(requested)) return LOGIN_PATH
|
|
32
|
+
return loginPathThen(billingUpgradePath(requested._id))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The plan a registration opens the workspace on, and the one chosen on
|
|
37
|
+
* Pricing, loaded for display. The chosen plan is remembered for the tab, so
|
|
38
|
+
* the OAuth round-trip back to "Set up your first workspace" keeps it.
|
|
39
|
+
*
|
|
40
|
+
* @param planReference Slug or id of the chosen plan
|
|
41
|
+
*/
|
|
42
|
+
export function useSaasRegistrationPlan(
|
|
43
|
+
planReference: MaybeRefOrGetter<string | null | undefined>,
|
|
44
|
+
) {
|
|
45
|
+
const publicFetch = usePublicFetch()
|
|
46
|
+
const { resolveError } = useApiErrorPresenter()
|
|
47
|
+
const summary = ref<RegistrationPlanSummary | null>(null)
|
|
48
|
+
const isLoading = ref(false)
|
|
49
|
+
const loadError = ref<string | null>(null)
|
|
50
|
+
|
|
51
|
+
async function load(): Promise<void> {
|
|
52
|
+
isLoading.value = true
|
|
53
|
+
loadError.value = null
|
|
54
|
+
const plan = toValue(planReference) || undefined
|
|
55
|
+
try {
|
|
56
|
+
summary.value = await publicFetch<RegistrationPlanSummary>(
|
|
57
|
+
REGISTRATION_PLAN_ENDPOINT,
|
|
58
|
+
{ query: plan ? { [REGISTER_PLAN_PARAM]: plan } : {} },
|
|
59
|
+
)
|
|
60
|
+
rememberChosenPlan(summary.value.requestedPlan?._id ?? null)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
loadError.value =
|
|
63
|
+
resolveError(error, { fallbackKey: REGISTRATION_LOAD_ERROR_KEY })
|
|
64
|
+
?.message ?? ''
|
|
65
|
+
} finally {
|
|
66
|
+
isLoading.value = false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onPublicLocaleChange(load)
|
|
71
|
+
|
|
72
|
+
return { summary, isLoading, loadError, load }
|
|
73
|
+
}
|