@usethrottle/auth 0.6.1 → 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 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
- order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
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
- onClick: () => props.onViewSubscription(order.subscriptionId),
4030
- children: t.orders.viewSubscription
4031
- }
4032
- ) : null,
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
  {