@antelopejs/dms-saas 0.3.13 → 0.3.14

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.
@@ -13,10 +13,16 @@ const FREE_PLAN_PRICE = 0;
13
13
  const EXPIRY_YEAR_MODULO = 100;
14
14
  const EXPIRY_PAD_LENGTH = 2;
15
15
  const KEY_PREFIX = "saas.workspace.billing.payment_method";
16
+ const FULL_DATE_FORMAT: Intl.DateTimeFormatOptions = {
17
+ year: "numeric",
18
+ month: "long",
19
+ day: "numeric",
20
+ };
16
21
 
17
22
  const { data, error, load, refresh } = useBillingStatus();
18
23
  const { data: plan, load: loadPlan } = useTenantPlan();
19
24
  const { open: openPlanComparison } = usePlanComparison();
25
+ const { t, locale } = useI18n();
20
26
 
21
27
  const card = computed(() => data.value?.paymentMethod ?? null);
22
28
  const needsUpdate = computed(() => data.value?.status === PAST_DUE_STATUS);
@@ -27,6 +33,21 @@ const isFreePlan = computed(
27
33
  // manages the card rather than shown a misleading "no card".
28
34
  const isTenantOwner = computed(() => !!data.value?.isTenantOwner);
29
35
  const hasStripeCustomer = computed(() => !!data.value?.hasStripeCustomer);
36
+ // A gift on the top plan needs no card: offering an upgrade there is noise.
37
+ const complimentaryAccess = computed(() =>
38
+ resolveComplimentaryAccess(plan.value),
39
+ );
40
+
41
+ const complimentaryNote = computed(() => {
42
+ const endsOn = formatDate(
43
+ complimentaryAccess.value?.endsAt,
44
+ locale.value,
45
+ FULL_DATE_FORMAT,
46
+ );
47
+ return endsOn
48
+ ? t(`${KEY_PREFIX}.complimentary_until_note`, { date: endsOn })
49
+ : t(`${KEY_PREFIX}.complimentary_note`);
50
+ });
30
51
 
31
52
  // "You'll be asked for a card on upgrade" is only true without a Stripe
32
53
  // customer: once one exists, a missing card is added through the portal.
@@ -35,6 +56,9 @@ const noCardKey = computed(() =>
35
56
  );
36
57
 
37
58
  const headerBadge = computed<PaymentMethodBadge>(() => {
59
+ if (complimentaryAccess.value) {
60
+ return { color: "success", key: "complimentary" };
61
+ }
38
62
  if (!card.value) return { color: "warning", key: "missing" };
39
63
  if (needsUpdate.value) return { color: "warning", key: "needs_update" };
40
64
  if (isFreePlan.value) return { color: "success", key: "verified" };
@@ -84,7 +108,15 @@ onMounted(() => {
84
108
  </p>
85
109
 
86
110
  <div v-else class="flex flex-col gap-4">
87
- <template v-if="card">
111
+ <div
112
+ v-if="complimentaryAccess"
113
+ class="border-default flex flex-wrap items-center gap-3 rounded-lg border border-dashed p-3"
114
+ >
115
+ <UIcon name="i-ph-gift" class="text-muted size-5" />
116
+ <span class="text-muted grow text-sm">{{ complimentaryNote }}</span>
117
+ </div>
118
+
119
+ <template v-else-if="card">
88
120
  <div
89
121
  class="border-default flex flex-wrap items-center gap-3 rounded-lg border p-3"
90
122
  >
@@ -0,0 +1,23 @@
1
+ import type { TenantPlanResponse } from "./useTenantPlan";
2
+
3
+ type ComplimentaryAccessState = Pick<
4
+ TenantPlanResponse,
5
+ "isPlanChangeLocked" | "freeUntil"
6
+ >;
7
+
8
+ /** A complimentary gift still in force, with its end date when it has one. */
9
+ export interface ComplimentaryAccess {
10
+ endsAt: string | null;
11
+ }
12
+
13
+ /**
14
+ * `isPlanChangeLocked` is the server applying `isComplimentaryPlanLocked`:
15
+ * reading it instead of comparing `freeUntil` to the browser clock keeps the
16
+ * billing page aligned with what the plan endpoints actually allow.
17
+ */
18
+ export function resolveComplimentaryAccess(
19
+ plan: ComplimentaryAccessState | null,
20
+ ): ComplimentaryAccess | null {
21
+ if (!plan?.isPlanChangeLocked) return null;
22
+ return { endsAt: plan.freeUntil };
23
+ }
@@ -1005,7 +1005,10 @@
1005
1005
  "add": "Upgrade to a paid plan",
1006
1006
  "owner_only": "The payment method is managed by the workspace owner.",
1007
1007
  "update_note": "The last charge on this card was declined: update it in the Stripe portal, then settle the unpaid invoice.",
1008
- "free_note": "Verified — never charged while the workspace stays on a free plan."
1008
+ "free_note": "Verified — never charged while the workspace stays on a free plan.",
1009
+ "complimentary": "complimentary",
1010
+ "complimentary_note": "Complimentary access: no card is needed.",
1011
+ "complimentary_until_note": "Complimentary access until {date}: no card is needed until then."
1009
1012
  },
1010
1013
  "billing_email": {
1011
1014
  "label": "Billing e-mail",
@@ -1005,7 +1005,10 @@
1005
1005
  "add": "Passer à un plan payant",
1006
1006
  "owner_only": "Le moyen de paiement est géré par le propriétaire du workspace.",
1007
1007
  "update_note": "Le dernier prélèvement sur cette carte a été refusé : mettez-la à jour dans le portail Stripe, puis réglez la facture impayée.",
1008
- "free_note": "Vérifiée — jamais débitée tant que le workspace reste sur un plan gratuit."
1008
+ "free_note": "Vérifiée — jamais débitée tant que le workspace reste sur un plan gratuit.",
1009
+ "complimentary": "offert",
1010
+ "complimentary_note": "Accès offert : aucune carte n'est nécessaire.",
1011
+ "complimentary_until_note": "Accès offert jusqu'au {date} : aucune carte n'est nécessaire d'ici là."
1009
1012
  },
1010
1013
  "billing_email": {
1011
1014
  "label": "E-mail de facturation",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-saas",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",