@usethrottle/auth 0.6.0 → 0.7.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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/react/components/index.cjs +24 -7
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +2 -1
- package/dist/react/components/index.d.ts +2 -1
- package/dist/react/components/index.js +24 -7
- package/dist/react/components/index.js.map +1 -1
- package/dist/react/index.d.cts +5 -0
- package/dist/react/index.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -96,7 +96,10 @@ interface Order {
|
|
|
96
96
|
billingAddress: unknown | null;
|
|
97
97
|
shippingAddress: unknown | null;
|
|
98
98
|
discountCode: string | null;
|
|
99
|
+
/** Set only when the order is linked to exactly one subscription. Read `subscriptionIds`. */
|
|
99
100
|
subscriptionId: string | null;
|
|
101
|
+
/** Every subscription this order created, in line order. One cart can hold several. */
|
|
102
|
+
subscriptionIds: string[];
|
|
100
103
|
/**
|
|
101
104
|
* The invoice raised for this order, when one exists. Resolved on the
|
|
102
105
|
* detail read only — the list would need a lookup per row.
|
|
@@ -120,6 +123,8 @@ interface OrderLineItem {
|
|
|
120
123
|
discountAmount: number;
|
|
121
124
|
total: number;
|
|
122
125
|
imageUrl: string | null;
|
|
126
|
+
/** The subscription this line created, or null for a one-time line. */
|
|
127
|
+
subscriptionId: string | null;
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
130
|
* What `getOrder` returns. Deliberately NOT folded into `Order`: the list route
|
package/dist/index.d.ts
CHANGED
|
@@ -96,7 +96,10 @@ interface Order {
|
|
|
96
96
|
billingAddress: unknown | null;
|
|
97
97
|
shippingAddress: unknown | null;
|
|
98
98
|
discountCode: string | null;
|
|
99
|
+
/** Set only when the order is linked to exactly one subscription. Read `subscriptionIds`. */
|
|
99
100
|
subscriptionId: string | null;
|
|
101
|
+
/** Every subscription this order created, in line order. One cart can hold several. */
|
|
102
|
+
subscriptionIds: string[];
|
|
100
103
|
/**
|
|
101
104
|
* The invoice raised for this order, when one exists. Resolved on the
|
|
102
105
|
* detail read only — the list would need a lookup per row.
|
|
@@ -120,6 +123,8 @@ interface OrderLineItem {
|
|
|
120
123
|
discountAmount: number;
|
|
121
124
|
total: number;
|
|
122
125
|
imageUrl: string | null;
|
|
126
|
+
/** The subscription this line created, or null for a one-time line. */
|
|
127
|
+
subscriptionId: string | null;
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
130
|
* What `getOrder` returns. Deliberately NOT folded into `Order`: the list route
|
|
@@ -780,6 +780,7 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
780
780
|
"orderDetail.cancelButton",
|
|
781
781
|
"orderDetail.returnButton",
|
|
782
782
|
"orderDetail.invoiceButton",
|
|
783
|
+
"orderDetail.subscriptionButton",
|
|
783
784
|
"orderDetail.actions",
|
|
784
785
|
"invoiceDetail.layout",
|
|
785
786
|
"invoiceDetail.main",
|
|
@@ -1187,7 +1188,8 @@ var enUS = {
|
|
|
1187
1188
|
quantity: "Qty",
|
|
1188
1189
|
shippingAddress: "Shipping address",
|
|
1189
1190
|
billingAddress: "Billing address",
|
|
1190
|
-
viewSubscription: "View subscription"
|
|
1191
|
+
viewSubscription: "View subscription",
|
|
1192
|
+
viewSubscriptionFor: "View subscription for"
|
|
1191
1193
|
},
|
|
1192
1194
|
invoices: {
|
|
1193
1195
|
empty: "No invoices yet",
|
|
@@ -3862,6 +3864,16 @@ function OrderTimeline(props) {
|
|
|
3862
3864
|
] });
|
|
3863
3865
|
}
|
|
3864
3866
|
|
|
3867
|
+
// src/react/components/account/order-subscription-links.ts
|
|
3868
|
+
function orderSubscriptionLinks(order, labels) {
|
|
3869
|
+
const ids = order.subscriptionIds?.length ? order.subscriptionIds : order.subscriptionId ? [order.subscriptionId] : [];
|
|
3870
|
+
if (ids.length === 1) return [{ id: ids[0], label: labels.single }];
|
|
3871
|
+
return ids.map((id, index) => {
|
|
3872
|
+
const name = order.lineItems.find((li) => li.subscriptionId === id)?.name;
|
|
3873
|
+
return { id, label: name ? `${labels.named} ${name}` : `${labels.single} ${index + 1}` };
|
|
3874
|
+
});
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3865
3877
|
// src/react/components/account/OrderDetail.tsx
|
|
3866
3878
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3867
3879
|
var CAN_PAY = /* @__PURE__ */ new Set(["draft", "pending"]);
|
|
@@ -4022,14 +4034,19 @@ function OrderDetail(props) {
|
|
|
4022
4034
|
children: t.orders.reorder
|
|
4023
4035
|
}
|
|
4024
4036
|
) : null,
|
|
4025
|
-
|
|
4037
|
+
props.onViewSubscription ? orderSubscriptionLinks(order, {
|
|
4038
|
+
single: t.orders.viewSubscription,
|
|
4039
|
+
named: t.orders.viewSubscriptionFor
|
|
4040
|
+
}).map((link) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4026
4041
|
Button,
|
|
4027
4042
|
{
|
|
4028
4043
|
variant: "secondary",
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4044
|
+
elementKey: "orderDetail.subscriptionButton",
|
|
4045
|
+
onClick: () => props.onViewSubscription(link.id),
|
|
4046
|
+
children: link.label
|
|
4047
|
+
},
|
|
4048
|
+
link.id
|
|
4049
|
+
)) : null,
|
|
4033
4050
|
showReturn ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4034
4051
|
Button,
|
|
4035
4052
|
{
|
|
@@ -4415,7 +4432,7 @@ function cadenceNoun(cadence) {
|
|
|
4415
4432
|
|
|
4416
4433
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
4417
4434
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4418
|
-
var CAN_PAUSE = /* @__PURE__ */ new Set(["active"
|
|
4435
|
+
var CAN_PAUSE = /* @__PURE__ */ new Set(["active"]);
|
|
4419
4436
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
4420
4437
|
var CAN_CANCEL2 = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
4421
4438
|
var isInstallment = (sub) => sub.totalPayments != null;
|