@usethrottle/auth 0.7.0 → 0.8.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/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/react/components/index.cjs +41 -8
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +5 -0
- package/dist/react/components/index.d.ts +5 -0
- package/dist/react/components/index.js +41 -8
- package/dist/react/components/index.js.map +1 -1
- package/dist/react/index.d.cts +15 -0
- package/dist/react/index.d.ts +15 -0
- package/package.json +1 -1
|
@@ -324,6 +324,11 @@ declare const enUS: {
|
|
|
324
324
|
cancelledOn: string;
|
|
325
325
|
trialEnds: string;
|
|
326
326
|
installmentProgress: string;
|
|
327
|
+
installmentTotal: string;
|
|
328
|
+
installmentNext: string;
|
|
329
|
+
/** Spec §5: a varied schedule's dated list; dates are estimates, hence "~". */
|
|
330
|
+
upcomingPayments: string;
|
|
331
|
+
upcomingPayment: string;
|
|
327
332
|
cancelButton: string;
|
|
328
333
|
cancelAtPeriodEnd: string;
|
|
329
334
|
cancelNow: string;
|
|
@@ -324,6 +324,11 @@ declare const enUS: {
|
|
|
324
324
|
cancelledOn: string;
|
|
325
325
|
trialEnds: string;
|
|
326
326
|
installmentProgress: string;
|
|
327
|
+
installmentTotal: string;
|
|
328
|
+
installmentNext: string;
|
|
329
|
+
/** Spec §5: a varied schedule's dated list; dates are estimates, hence "~". */
|
|
330
|
+
upcomingPayments: string;
|
|
331
|
+
upcomingPayment: string;
|
|
327
332
|
cancelButton: string;
|
|
328
333
|
cancelAtPeriodEnd: string;
|
|
329
334
|
cancelNow: string;
|
|
@@ -674,6 +674,11 @@ var enUS = {
|
|
|
674
674
|
cancelledOn: "Cancelled on",
|
|
675
675
|
trialEnds: "Trial ends",
|
|
676
676
|
installmentProgress: "Payment {paid} of {total}",
|
|
677
|
+
installmentTotal: "{amount} total",
|
|
678
|
+
installmentNext: "Next {amount} on {date}",
|
|
679
|
+
/** Spec §5: a varied schedule's dated list; dates are estimates, hence "~". */
|
|
680
|
+
upcomingPayments: "Upcoming payments",
|
|
681
|
+
upcomingPayment: "{amount} \xB7 ~{date}",
|
|
677
682
|
cancelButton: "Cancel",
|
|
678
683
|
cancelAtPeriodEnd: "Cancel at period end",
|
|
679
684
|
cancelNow: "Cancel immediately",
|
|
@@ -3737,6 +3742,18 @@ function isIntervalUnit(value) {
|
|
|
3737
3742
|
return typeof value === "string" && INTERVAL_UNITS.includes(value);
|
|
3738
3743
|
}
|
|
3739
3744
|
|
|
3745
|
+
// ../core-cadence/src/schedule.ts
|
|
3746
|
+
function isVariedSchedule(rows) {
|
|
3747
|
+
if (!rows || rows.length === 0) return false;
|
|
3748
|
+
return rows.some(
|
|
3749
|
+
(r, i) => r.discount !== 0 || r.amount !== rows[0].amount || i > 1 && (r.intervalUnit !== rows[1].intervalUnit || r.intervalCount !== rows[1].intervalCount)
|
|
3750
|
+
);
|
|
3751
|
+
}
|
|
3752
|
+
function upcomingSchedulePayments(rows) {
|
|
3753
|
+
if (!rows || !isVariedSchedule(rows)) return [];
|
|
3754
|
+
return rows.filter((r) => r.status !== "paid" && r.dueAt != null);
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3740
3757
|
// ../core-cadence/src/labels.ts
|
|
3741
3758
|
var NAMED_NOUN = {
|
|
3742
3759
|
weekly: "week",
|
|
@@ -3752,6 +3769,10 @@ function cadenceNoun(cadence) {
|
|
|
3752
3769
|
}
|
|
3753
3770
|
return cadence.interval;
|
|
3754
3771
|
}
|
|
3772
|
+
function scheduleDeal(sub) {
|
|
3773
|
+
if (!sub.paymentSchedule || sub.scheduleTotal == null || !isVariedSchedule(sub.paymentSchedule)) return null;
|
|
3774
|
+
return { total: sub.scheduleTotal, payments: sub.paymentSchedule.length };
|
|
3775
|
+
}
|
|
3755
3776
|
|
|
3756
3777
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
3757
3778
|
import { Fragment as Fragment8, jsx as jsx42, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
@@ -3778,7 +3799,20 @@ function SubscriptionsPanel(props) {
|
|
|
3778
3799
|
await run(fn);
|
|
3779
3800
|
})();
|
|
3780
3801
|
};
|
|
3781
|
-
const priceLabel = (sub) =>
|
|
3802
|
+
const priceLabel = (sub) => {
|
|
3803
|
+
const deal = scheduleDeal(sub);
|
|
3804
|
+
return deal ? t.subscriptions.installmentTotal.replace("{amount}", formatMoney(deal.total, sub.currency, locale)) : `${formatMoney(sub.amount, sub.currency, locale)} / ${cadenceNoun(sub)}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
3805
|
+
};
|
|
3806
|
+
const nextPaymentLabel = (sub) => {
|
|
3807
|
+
if (!isVariedSchedule(sub.paymentSchedule) || !sub.paymentSchedule || sub.nextPaymentAmount == null) return null;
|
|
3808
|
+
const upcoming = sub.paymentSchedule.find((r) => r.status !== "paid");
|
|
3809
|
+
return t.subscriptions.installmentNext.replace("{amount}", formatMoney(sub.nextPaymentAmount, sub.currency, locale)).replace("{date}", formatDate(upcoming?.dueAt ?? sub.currentPeriodEnd, locale));
|
|
3810
|
+
};
|
|
3811
|
+
const upcomingList = (sub) => {
|
|
3812
|
+
const upcoming = upcomingSchedulePayments(sub.paymentSchedule);
|
|
3813
|
+
if (upcoming.length === 0) return null;
|
|
3814
|
+
return /* @__PURE__ */ jsx42("ul", { className: "throttle-muted", "aria-label": t.subscriptions.upcomingPayments, children: upcoming.map((r) => /* @__PURE__ */ jsx42("li", { children: t.subscriptions.upcomingPayment.replace("{amount}", formatMoney(r.net, sub.currency, locale)).replace("{date}", formatDate(r.dueAt, locale)) }, r.dueAt)) });
|
|
3815
|
+
};
|
|
3782
3816
|
const renewsLabel = (sub) => formatDate(
|
|
3783
3817
|
sub.status === "completed" ? sub.completedAt ?? sub.currentPeriodEnd : sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd,
|
|
3784
3818
|
locale
|
|
@@ -3860,7 +3894,9 @@ function SubscriptionsPanel(props) {
|
|
|
3860
3894
|
columns: [
|
|
3861
3895
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => /* @__PURE__ */ jsxs32(Fragment8, { children: [
|
|
3862
3896
|
sub.planName ?? sub.planReference,
|
|
3863
|
-
sub.totalPayments != null ? /* @__PURE__ */ jsx42("div", { className: "throttle-muted", children: t.subscriptions.installmentProgress.replace("{paid}", String(Math.min(sub.paymentsMade ?? 0, sub.totalPayments))).replace("{total}", String(sub.totalPayments)) }) : null
|
|
3897
|
+
sub.totalPayments != null ? /* @__PURE__ */ jsx42("div", { className: "throttle-muted", children: t.subscriptions.installmentProgress.replace("{paid}", String(Math.min(sub.paymentsMade ?? 0, sub.totalPayments))).replace("{total}", String(sub.totalPayments)) }) : null,
|
|
3898
|
+
nextPaymentLabel(sub) ? /* @__PURE__ */ jsx42("div", { className: "throttle-muted", children: nextPaymentLabel(sub) }) : null,
|
|
3899
|
+
upcomingList(sub)
|
|
3864
3900
|
] }) },
|
|
3865
3901
|
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ jsx42("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
|
|
3866
3902
|
{ key: "renews", label: t.subscriptions.columnRenews, render: (sub) => renewsLabel(sub) },
|
|
@@ -3878,12 +3914,9 @@ function SubscriptionsPanel(props) {
|
|
|
3878
3914
|
/* @__PURE__ */ jsx42(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
|
|
3879
3915
|
] }),
|
|
3880
3916
|
sub.totalPayments != null ? /* @__PURE__ */ jsx42("div", { className: "throttle-muted", children: t.subscriptions.installmentProgress.replace("{paid}", String(Math.min(sub.paymentsMade ?? 0, sub.totalPayments))).replace("{total}", String(sub.totalPayments)) }) : null,
|
|
3881
|
-
/* @__PURE__ */
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
cadenceNoun(sub),
|
|
3885
|
-
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
3886
|
-
] }),
|
|
3917
|
+
nextPaymentLabel(sub) ? /* @__PURE__ */ jsx42("div", { className: "throttle-muted", children: nextPaymentLabel(sub) }) : null,
|
|
3918
|
+
upcomingList(sub),
|
|
3919
|
+
/* @__PURE__ */ jsx42("p", { className: "throttle-muted", children: priceLabel(sub) }),
|
|
3887
3920
|
sub.status === "completed" ? /* @__PURE__ */ jsxs32("p", { className: "throttle-muted", children: [
|
|
3888
3921
|
t.subscriptions.statusLabels.completed,
|
|
3889
3922
|
" ",
|