@usethrottle/auth 0.3.1 → 0.4.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/{chunk-NCSTIPJF.js → chunk-HQP5QTHQ.js} +3 -1
- package/dist/{chunk-NCSTIPJF.js.map → chunk-HQP5QTHQ.js.map} +1 -1
- package/dist/{chunk-ST77QX7X.js → chunk-K7RCWADI.js} +18 -1
- package/dist/chunk-K7RCWADI.js.map +1 -0
- package/dist/{chunk-2DREGJUF.js → chunk-TKSBAC7W.js} +2 -2
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/react/components/index.cjs +894 -626
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +62 -6
- package/dist/react/components/index.d.ts +62 -6
- package/dist/react/components/index.js +850 -601
- package/dist/react/components/index.js.map +1 -1
- package/dist/react/forms/index.cjs +17 -0
- package/dist/react/forms/index.cjs.map +1 -1
- package/dist/react/forms/index.js +2 -2
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +40 -0
- package/dist/react/index.d.ts +40 -0
- package/dist/react/index.js +2 -2
- package/dist/styles.css +47 -3
- package/package.json +1 -1
- package/dist/chunk-ST77QX7X.js.map +0 -1
- /package/dist/{chunk-2DREGJUF.js.map → chunk-TKSBAC7W.js.map} +0 -0
|
@@ -79,7 +79,7 @@ __export(components_exports, {
|
|
|
79
79
|
module.exports = __toCommonJS(components_exports);
|
|
80
80
|
|
|
81
81
|
// src/react/components/provider.tsx
|
|
82
|
-
var
|
|
82
|
+
var import_react31 = require("react");
|
|
83
83
|
|
|
84
84
|
// src/errors.ts
|
|
85
85
|
var ThrottleAuthError = class extends Error {
|
|
@@ -459,6 +459,8 @@ function createAccount(auth) {
|
|
|
459
459
|
getInvoicePdfUrl: (id) => call("GET", `/me/invoices/${seg(id)}/pdf`),
|
|
460
460
|
listSubscriptions: (page) => call("GET", `/me/subscriptions${query(page)}`),
|
|
461
461
|
getSubscription: (id) => call("GET", `/me/subscriptions/${seg(id)}`),
|
|
462
|
+
cancelOrder: (id, opts) => call("POST", `/me/orders/${seg(id)}/cancel`, opts),
|
|
463
|
+
requestOrderReturn: (id, input) => call("POST", `/me/orders/${seg(id)}/return-request`, input),
|
|
462
464
|
cancelSubscription: (id, opts) => call("POST", `/me/subscriptions/${seg(id)}/cancel`, opts),
|
|
463
465
|
pauseSubscription: (id) => call("POST", `/me/subscriptions/${seg(id)}/pause`),
|
|
464
466
|
resumeSubscription: (id) => call("POST", `/me/subscriptions/${seg(id)}/resume`),
|
|
@@ -771,6 +773,23 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
771
773
|
"orderDetail.payButton",
|
|
772
774
|
"orderDetail.trackButton",
|
|
773
775
|
"orderDetail.reorderButton",
|
|
776
|
+
// Two-column detail layout, shared by the order and invoice pages.
|
|
777
|
+
"orderDetail.layout",
|
|
778
|
+
"orderDetail.main",
|
|
779
|
+
"orderDetail.rail",
|
|
780
|
+
"orderDetail.cancelButton",
|
|
781
|
+
"orderDetail.returnButton",
|
|
782
|
+
"orderDetail.invoiceButton",
|
|
783
|
+
"orderDetail.actions",
|
|
784
|
+
"invoiceDetail.layout",
|
|
785
|
+
"invoiceDetail.main",
|
|
786
|
+
"invoiceDetail.rail",
|
|
787
|
+
"invoiceDetail.lineItems",
|
|
788
|
+
"invoiceDetail.lineItem",
|
|
789
|
+
"invoiceDetail.orderLink",
|
|
790
|
+
"invoiceDetail.subscriptionLink",
|
|
791
|
+
"invoiceDetail.payButton",
|
|
792
|
+
"invoiceDetail.actions",
|
|
774
793
|
"fieldRow",
|
|
775
794
|
"confirm.header",
|
|
776
795
|
"confirm.title",
|
|
@@ -921,6 +940,23 @@ function messageForError(err) {
|
|
|
921
940
|
return "We could not find that.";
|
|
922
941
|
case "payment_method_in_use":
|
|
923
942
|
return e.message || "That payment method is in use and cannot be removed.";
|
|
943
|
+
// Order and return refusals. Every one of these is a state the buyer can
|
|
944
|
+
// see and act on — the order shipped, the money was taken, that quantity
|
|
945
|
+
// is already on another return — and the server's message names which and
|
|
946
|
+
// what to do instead. Flattening them to "Something went wrong" sent a
|
|
947
|
+
// buyer to support for something the screen could have answered. Same
|
|
948
|
+
// argument as payment_method_in_use above.
|
|
949
|
+
case "order_not_cancellable":
|
|
950
|
+
case "order_already_paid":
|
|
951
|
+
case "order_not_returnable":
|
|
952
|
+
case "quantity_exceeds_returnable":
|
|
953
|
+
case "no_items":
|
|
954
|
+
case "unknown_line_item":
|
|
955
|
+
case "return_rejected":
|
|
956
|
+
return e.message || "That change is not possible for this order.";
|
|
957
|
+
case "orders_unavailable":
|
|
958
|
+
case "returns_unavailable":
|
|
959
|
+
return "That is unavailable right now. Please contact support.";
|
|
924
960
|
case "validation_error": {
|
|
925
961
|
const first2 = e.details?.[0];
|
|
926
962
|
if (first2?.path && first2?.message) {
|
|
@@ -1091,6 +1127,17 @@ var enUS = {
|
|
|
1091
1127
|
payNow: "Pay now",
|
|
1092
1128
|
track: "Track shipment",
|
|
1093
1129
|
reorder: "Order again",
|
|
1130
|
+
cancelOrder: "Cancel order",
|
|
1131
|
+
cancelOrderConfirm: "Cancel this order?",
|
|
1132
|
+
cancelOrderBody: "This cannot be undone. Nothing has been charged, so there is nothing to refund.",
|
|
1133
|
+
cancelOrderAction: "Cancel order",
|
|
1134
|
+
requestReturn: "Request a return",
|
|
1135
|
+
requestReturnConfirm: "Request a return for this order?",
|
|
1136
|
+
requestReturnBody: "The merchant reviews your request and will be in touch. Nothing is refunded until they approve it.",
|
|
1137
|
+
requestReturnAction: "Send request",
|
|
1138
|
+
returnRequested: "Return requested. The merchant will be in touch.",
|
|
1139
|
+
downloadInvoice: "Download invoice",
|
|
1140
|
+
summary: "Summary",
|
|
1094
1141
|
empty: "No orders yet",
|
|
1095
1142
|
emptyDescription: "Orders you place will appear here.",
|
|
1096
1143
|
gatedDescription: "Verify your email to see your order history.",
|
|
@@ -1154,6 +1201,12 @@ var enUS = {
|
|
|
1154
1201
|
refunded: "Refunded",
|
|
1155
1202
|
period: "Period",
|
|
1156
1203
|
downloadButton: "Download PDF",
|
|
1204
|
+
items: "Items",
|
|
1205
|
+
summary: "Summary",
|
|
1206
|
+
viewOrder: "View order",
|
|
1207
|
+
viewSubscription: "View subscription",
|
|
1208
|
+
payButton: "Pay this invoice",
|
|
1209
|
+
billedTo: "Billed to",
|
|
1157
1210
|
/** Display copy for `invoice.status` — the wire values are paid|open|void. */
|
|
1158
1211
|
statusLabels: { paid: "Paid", open: "Open", void: "Void" },
|
|
1159
1212
|
downloadUnavailable: "This invoice is not available to download right now."
|
|
@@ -1468,11 +1521,13 @@ var THROTTLE_STYLES = `
|
|
|
1468
1521
|
align-items: center;
|
|
1469
1522
|
justify-content: center;
|
|
1470
1523
|
cursor: pointer;
|
|
1524
|
+
/* A label that wraps turns a control into a two-line block of text. */
|
|
1525
|
+
white-space: nowrap;
|
|
1471
1526
|
transition: opacity var(--throttle-transition), background-color var(--throttle-transition), border-color var(--throttle-transition), filter var(--throttle-transition), box-shadow var(--throttle-transition);
|
|
1472
1527
|
}
|
|
1473
1528
|
.throttle-button:disabled { opacity: .55; cursor: not-allowed; }
|
|
1474
1529
|
.throttle-button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--throttle-color-background), 0 0 0 4px var(--throttle-color-primary); }
|
|
1475
|
-
.throttle-button--primary { background: var(--throttle-color-primary); color: var(--throttle-color-primary-foreground); width: 100
|
|
1530
|
+
.throttle-button--primary { background: var(--throttle-color-primary); color: var(--throttle-color-primary-foreground); width: var(--throttle-button-width, 100%); }
|
|
1476
1531
|
.throttle-button--primary:hover:not(:disabled) { filter: brightness(0.92); }
|
|
1477
1532
|
.throttle-button--secondary { background: var(--throttle-color-surface); color: var(--throttle-color-foreground); border-color: var(--throttle-color-border-control); }
|
|
1478
1533
|
.throttle-button--secondary:hover:not(:disabled) { background: var(--throttle-color-muted); }
|
|
@@ -1639,6 +1694,10 @@ var THROTTLE_STYLES = `
|
|
|
1639
1694
|
.throttle-addresses { grid-template-columns: 1fr; }
|
|
1640
1695
|
.throttle-fieldrow { grid-template-columns: 1fr; }
|
|
1641
1696
|
.throttle-tabs__rail { width: 100%; }
|
|
1697
|
+
/* One column, and the rail stops sticking \u2014 on a phone a sticky summary
|
|
1698
|
+
covers the very line items it is summarising. */
|
|
1699
|
+
.throttle-detail { grid-template-columns: 1fr; }
|
|
1700
|
+
.throttle-detail__rail { position: static; }
|
|
1642
1701
|
}
|
|
1643
1702
|
|
|
1644
1703
|
.throttle-table { width: 100%; border-collapse: collapse; text-align: left; }
|
|
@@ -1716,12 +1775,50 @@ var THROTTLE_STYLES = `
|
|
|
1716
1775
|
padding: var(--throttle-space-3) 0;
|
|
1717
1776
|
}
|
|
1718
1777
|
.throttle-rowitem:first-child { border-top: none; padding-top: 0; }
|
|
1719
|
-
.throttle-actions {
|
|
1778
|
+
.throttle-actions {
|
|
1779
|
+
display: flex; gap: var(--throttle-space-2); flex-wrap: wrap; align-items: center;
|
|
1780
|
+
/* Primary buttons are full-width so a form's submit fills its card. In a row
|
|
1781
|
+
of sibling actions that same rule made every button claim 100% and then
|
|
1782
|
+
shrink to share the line, squeezing Resume to 59px so its label wrapped to
|
|
1783
|
+
two lines inside a 48px box. A custom property INHERITS to the buttons, so
|
|
1784
|
+
the row opts them back to content width without a descendant selector \u2014
|
|
1785
|
+
those outrank the merchant overrides in appearance.elements. */
|
|
1786
|
+
--throttle-button-width: auto;
|
|
1787
|
+
}
|
|
1720
1788
|
.throttle-table__money { display: block; text-align: right; font-variant-numeric: tabular-nums; }
|
|
1721
|
-
.throttle-lineitem { display: flex; align-items:
|
|
1789
|
+
.throttle-lineitem { display: flex; align-items: flex-start; gap: var(--throttle-space-3); padding: var(--throttle-space-2) 0; }
|
|
1790
|
+
/* The UA's 1em paragraph margins pushed a two-line item to 96px, so five
|
|
1791
|
+
items filled a screen with mostly whitespace. These carry the spacing
|
|
1792
|
+
instead. Separate classes, not a ".throttle-lineitem p" descendant
|
|
1793
|
+
selector -- those outrank the merchant's appearance.elements overrides. */
|
|
1794
|
+
.throttle-lineitem__desc { margin: var(--throttle-space-1) 0 0; color: var(--throttle-color-muted-foreground); }
|
|
1795
|
+
.throttle-lineitem__meta { margin: var(--throttle-space-1) 0 0; color: var(--throttle-color-muted-foreground); font-size: var(--throttle-font-size-sm); }
|
|
1722
1796
|
.throttle-lineitem__image { width: 48px; height: 48px; object-fit: cover; border-radius: var(--throttle-radius-sm); flex: none; }
|
|
1723
1797
|
.throttle-totals { display: flex; flex-direction: column; gap: var(--throttle-space-1); }
|
|
1724
1798
|
|
|
1799
|
+
/* Order and invoice detail: the record on the left, what it costs and what
|
|
1800
|
+
you can do about it on the right. The rail sticks so the total and the
|
|
1801
|
+
actions stay reachable on an order with thirty lines, which is exactly when
|
|
1802
|
+
a buyer most wants them. Collapses below, where a sticky rail would eat a
|
|
1803
|
+
phone screen. */
|
|
1804
|
+
.throttle-detail { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: var(--throttle-space-6); align-items: start; }
|
|
1805
|
+
.throttle-detail__main { display: flex; flex-direction: column; gap: var(--throttle-space-5); min-width: 0; }
|
|
1806
|
+
.throttle-detail__rail {
|
|
1807
|
+
display: flex; flex-direction: column; gap: var(--throttle-space-4);
|
|
1808
|
+
position: sticky; top: var(--throttle-space-4);
|
|
1809
|
+
padding: var(--throttle-space-4);
|
|
1810
|
+
border: var(--throttle-border-width) solid var(--throttle-color-border);
|
|
1811
|
+
border-radius: var(--throttle-radius-md);
|
|
1812
|
+
background: var(--throttle-color-surface);
|
|
1813
|
+
}
|
|
1814
|
+
/* The one number the buyer came for. */
|
|
1815
|
+
.throttle-detail__headline { font-size: var(--throttle-font-size-xl); font-weight: 600; line-height: 1.2; }
|
|
1816
|
+
.throttle-detail__section { display: flex; flex-direction: column; gap: var(--throttle-space-2); }
|
|
1817
|
+
.throttle-detail__label { font-size: var(--throttle-font-size-sm); font-weight: 500; color: var(--throttle-color-muted-foreground); letter-spacing: .04em; text-transform: uppercase; }
|
|
1818
|
+
/* A rail action column: full width, stacked, so the primary reads as primary. */
|
|
1819
|
+
.throttle-detail__actions { display: flex; flex-direction: column; gap: var(--throttle-space-2); --throttle-button-width: 100%; }
|
|
1820
|
+
.throttle-detail__link { display: inline-flex; align-items: center; gap: var(--throttle-space-1); }
|
|
1821
|
+
|
|
1725
1822
|
@media (prefers-reduced-motion: reduce) {
|
|
1726
1823
|
.throttle-button, .throttle-field__input, .throttle-dropdown__item, .throttle-dropdown__trigger, .throttle-tabs__tab, .throttle-table__row, .throttle-modal__close {
|
|
1727
1824
|
transition: none;
|
|
@@ -1983,12 +2080,20 @@ function Modal(props) {
|
|
|
1983
2080
|
var import_react9 = require("react");
|
|
1984
2081
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1985
2082
|
var ConfirmContext = (0, import_react9.createContext)(null);
|
|
1986
|
-
function ConfirmProvider({
|
|
2083
|
+
function ConfirmProvider({
|
|
2084
|
+
children,
|
|
2085
|
+
stepUpOpen = false,
|
|
2086
|
+
onStepUpResolve
|
|
2087
|
+
}) {
|
|
1987
2088
|
const [request2, setRequest] = (0, import_react9.useState)(null);
|
|
2089
|
+
const [password, setPassword] = (0, import_react9.useState)("");
|
|
1988
2090
|
const { t } = useCopy();
|
|
1989
2091
|
const a = useAppearance();
|
|
1990
2092
|
const titleId = (0, import_react9.useId)();
|
|
1991
2093
|
const settle = (0, import_react9.useRef)(null);
|
|
2094
|
+
(0, import_react9.useEffect)(() => {
|
|
2095
|
+
if (!stepUpOpen) setPassword("");
|
|
2096
|
+
}, [stepUpOpen]);
|
|
1992
2097
|
const answer = (0, import_react9.useCallback)((value) => {
|
|
1993
2098
|
settle.current?.(value);
|
|
1994
2099
|
settle.current = null;
|
|
@@ -2001,9 +2106,47 @@ function ConfirmProvider({ children }) {
|
|
|
2001
2106
|
settle.current = resolve;
|
|
2002
2107
|
});
|
|
2003
2108
|
}, []);
|
|
2109
|
+
const showStepUp = stepUpOpen && Boolean(onStepUpResolve);
|
|
2110
|
+
const open = showStepUp || request2 !== null;
|
|
2111
|
+
const close = () => {
|
|
2112
|
+
if (showStepUp) onStepUpResolve(null);
|
|
2113
|
+
else answer(false);
|
|
2114
|
+
};
|
|
2004
2115
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ConfirmContext.Provider, { value: ask, children: [
|
|
2005
2116
|
children,
|
|
2006
|
-
|
|
2117
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { open: true, onClose: close, labelledBy: titleId, size: "compact", children: showStepUp ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { onSubmit: (e) => {
|
|
2118
|
+
e.preventDefault();
|
|
2119
|
+
onStepUpResolve(password);
|
|
2120
|
+
}, children: [
|
|
2121
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-modal__title"), children: t.stepUp.title }) }),
|
|
2122
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
|
|
2123
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "throttle-muted", children: t.stepUp.description }),
|
|
2124
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2125
|
+
Field,
|
|
2126
|
+
{
|
|
2127
|
+
label: t.stepUp.password,
|
|
2128
|
+
type: "password",
|
|
2129
|
+
autoComplete: "current-password",
|
|
2130
|
+
value: password,
|
|
2131
|
+
onChange: setPassword,
|
|
2132
|
+
required: true,
|
|
2133
|
+
elementKey: "stepUp.passwordField"
|
|
2134
|
+
}
|
|
2135
|
+
),
|
|
2136
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "throttle-actions", children: [
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
|
|
2138
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2139
|
+
Button,
|
|
2140
|
+
{
|
|
2141
|
+
variant: "secondary",
|
|
2142
|
+
elementKey: "stepUp.cancelButton",
|
|
2143
|
+
onClick: () => onStepUpResolve(null),
|
|
2144
|
+
children: t.stepUp.cancelButton
|
|
2145
|
+
}
|
|
2146
|
+
)
|
|
2147
|
+
] })
|
|
2148
|
+
] })
|
|
2149
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
2007
2150
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { id: titleId, ...a.el("confirm.title", "throttle-modal__title"), children: request2.title }) }),
|
|
2008
2151
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
|
|
2009
2152
|
request2.body ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "throttle-muted", children: request2.body }) : null,
|
|
@@ -2020,7 +2163,7 @@ function ConfirmProvider({ children }) {
|
|
|
2020
2163
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { elementKey: "confirm.cancelButton", variant: "secondary", onClick: () => answer(false), children: request2.cancelLabel ?? t.common.keepIt })
|
|
2021
2164
|
] })
|
|
2022
2165
|
] })
|
|
2023
|
-
] }) : null
|
|
2166
|
+
] }) }) : null
|
|
2024
2167
|
] });
|
|
2025
2168
|
}
|
|
2026
2169
|
function useConfirm() {
|
|
@@ -2228,69 +2371,24 @@ function Badge(props) {
|
|
|
2228
2371
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
|
|
2229
2372
|
}
|
|
2230
2373
|
|
|
2231
|
-
// src/react/components/auth/StepUpDialog.tsx
|
|
2232
|
-
var import_react11 = require("react");
|
|
2233
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2234
|
-
function StepUpDialog(props) {
|
|
2235
|
-
const a = useAppearance();
|
|
2236
|
-
const cardClass = useCardClass();
|
|
2237
|
-
const { t } = useCopy();
|
|
2238
|
-
const [password, setPassword] = (0, import_react11.useState)("");
|
|
2239
|
-
const titleId = (0, import_react11.useId)();
|
|
2240
|
-
(0, import_react11.useEffect)(() => {
|
|
2241
|
-
if (!props.open) setPassword("");
|
|
2242
|
-
}, [props.open]);
|
|
2243
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Modal, { open: props.open, onClose: () => props.onResolve(null), labelledBy: titleId, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ...a.el("stepUp.root", cardClass), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2244
|
-
"form",
|
|
2245
|
-
{
|
|
2246
|
-
onSubmit: (e) => {
|
|
2247
|
-
e.preventDefault();
|
|
2248
|
-
props.onResolve(password);
|
|
2249
|
-
},
|
|
2250
|
-
children: [
|
|
2251
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "throttle-card__header", children: [
|
|
2252
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-card__title"), children: t.stepUp.title }),
|
|
2253
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "throttle-card__description", children: t.stepUp.description })
|
|
2254
|
-
] }),
|
|
2255
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardBody, { children: [
|
|
2256
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2257
|
-
Field,
|
|
2258
|
-
{
|
|
2259
|
-
label: t.stepUp.password,
|
|
2260
|
-
type: "password",
|
|
2261
|
-
autoComplete: "current-password",
|
|
2262
|
-
value: password,
|
|
2263
|
-
onChange: setPassword,
|
|
2264
|
-
required: true,
|
|
2265
|
-
elementKey: "stepUp.passwordField"
|
|
2266
|
-
}
|
|
2267
|
-
),
|
|
2268
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
|
|
2269
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", elementKey: "stepUp.cancelButton", onClick: () => props.onResolve(null), children: t.stepUp.cancelButton })
|
|
2270
|
-
] })
|
|
2271
|
-
]
|
|
2272
|
-
}
|
|
2273
|
-
) }) });
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
2374
|
// src/react/components/auth/AuthModal.tsx
|
|
2277
|
-
var
|
|
2375
|
+
var import_react18 = require("react");
|
|
2278
2376
|
|
|
2279
2377
|
// src/react/components/auth/AuthFlow.tsx
|
|
2280
|
-
var
|
|
2378
|
+
var import_react17 = require("react");
|
|
2281
2379
|
|
|
2282
2380
|
// src/react/components/auth/SignIn.tsx
|
|
2283
|
-
var
|
|
2381
|
+
var import_react12 = require("react");
|
|
2284
2382
|
|
|
2285
2383
|
// src/react/components/useAction.ts
|
|
2286
|
-
var
|
|
2384
|
+
var import_react11 = require("react");
|
|
2287
2385
|
function useAction() {
|
|
2288
2386
|
const { errorMessage } = useCopy();
|
|
2289
|
-
const [submitting, setSubmitting] = (0,
|
|
2290
|
-
const [error, setError] = (0,
|
|
2291
|
-
const [notice, setNotice] = (0,
|
|
2292
|
-
const inFlight = (0,
|
|
2293
|
-
const run = (0,
|
|
2387
|
+
const [submitting, setSubmitting] = (0, import_react11.useState)(false);
|
|
2388
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
2389
|
+
const [notice, setNotice] = (0, import_react11.useState)(null);
|
|
2390
|
+
const inFlight = (0, import_react11.useRef)(false);
|
|
2391
|
+
const run = (0, import_react11.useCallback)(
|
|
2294
2392
|
async (fn) => {
|
|
2295
2393
|
if (inFlight.current) return;
|
|
2296
2394
|
inFlight.current = true;
|
|
@@ -2313,7 +2411,7 @@ function useAction() {
|
|
|
2313
2411
|
}
|
|
2314
2412
|
|
|
2315
2413
|
// src/react/components/auth/SignIn.tsx
|
|
2316
|
-
var
|
|
2414
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2317
2415
|
function SignIn(props) {
|
|
2318
2416
|
const a = useAppearance(props.appearance);
|
|
2319
2417
|
const cardClass = useCardClass();
|
|
@@ -2321,14 +2419,14 @@ function SignIn(props) {
|
|
|
2321
2419
|
const { t } = useCopy(props.localization);
|
|
2322
2420
|
const { auth } = useAuth();
|
|
2323
2421
|
const { submitting, error, run } = useAction();
|
|
2324
|
-
const [email, setEmail] = (0,
|
|
2325
|
-
const [password, setPassword] = (0,
|
|
2422
|
+
const [email, setEmail] = (0, import_react12.useState)("");
|
|
2423
|
+
const [password, setPassword] = (0, import_react12.useState)("");
|
|
2326
2424
|
const variant = props.variant ?? "quiet";
|
|
2327
2425
|
const branded = variant === "branded";
|
|
2328
2426
|
const grouped = variant === "grouped";
|
|
2329
2427
|
const logo = useBrandLogo(props.logo);
|
|
2330
|
-
const forgotLink = props.onForgotPassword ? /* @__PURE__ */ (0,
|
|
2331
|
-
const emailField = /* @__PURE__ */ (0,
|
|
2428
|
+
const forgotLink = props.onForgotPassword ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", size: "xs", elementKey: "signIn.forgotLink", onClick: props.onForgotPassword, children: t.signIn.forgotLink }) : null;
|
|
2429
|
+
const emailField = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2332
2430
|
Field,
|
|
2333
2431
|
{
|
|
2334
2432
|
label: t.signIn.email,
|
|
@@ -2341,7 +2439,7 @@ function SignIn(props) {
|
|
|
2341
2439
|
grouped
|
|
2342
2440
|
}
|
|
2343
2441
|
);
|
|
2344
|
-
const passwordField = /* @__PURE__ */ (0,
|
|
2442
|
+
const passwordField = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2345
2443
|
Field,
|
|
2346
2444
|
{
|
|
2347
2445
|
label: t.signIn.password,
|
|
@@ -2355,7 +2453,7 @@ function SignIn(props) {
|
|
|
2355
2453
|
labelExtra: grouped ? void 0 : forgotLink
|
|
2356
2454
|
}
|
|
2357
2455
|
);
|
|
2358
|
-
return /* @__PURE__ */ (0,
|
|
2456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2359
2457
|
"form",
|
|
2360
2458
|
{
|
|
2361
2459
|
...a.el("signIn.root", cardClass),
|
|
@@ -2367,7 +2465,7 @@ function SignIn(props) {
|
|
|
2367
2465
|
});
|
|
2368
2466
|
},
|
|
2369
2467
|
children: [
|
|
2370
|
-
/* @__PURE__ */ (0,
|
|
2468
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2371
2469
|
CardHeader,
|
|
2372
2470
|
{
|
|
2373
2471
|
title: t.signIn.title,
|
|
@@ -2378,24 +2476,24 @@ function SignIn(props) {
|
|
|
2378
2476
|
branded
|
|
2379
2477
|
}
|
|
2380
2478
|
),
|
|
2381
|
-
/* @__PURE__ */ (0,
|
|
2382
|
-
grouped ? /* @__PURE__ */ (0,
|
|
2479
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardBody, { children: [
|
|
2480
|
+
grouped ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(FieldGroup, { children: [
|
|
2383
2481
|
emailField,
|
|
2384
2482
|
passwordField
|
|
2385
|
-
] }) : /* @__PURE__ */ (0,
|
|
2483
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2386
2484
|
emailField,
|
|
2387
2485
|
passwordField
|
|
2388
2486
|
] }),
|
|
2389
|
-
grouped && forgotLink ? /* @__PURE__ */ (0,
|
|
2390
|
-
error ? /* @__PURE__ */ (0,
|
|
2391
|
-
/* @__PURE__ */ (0,
|
|
2487
|
+
grouped && forgotLink ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "throttle-field-group__forgot", children: forgotLink }) : null,
|
|
2488
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2489
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signIn.submitButton", children: t.signIn.submitButton })
|
|
2392
2490
|
] }),
|
|
2393
|
-
props.onSignUp ? /* @__PURE__ */ (0,
|
|
2394
|
-
/* @__PURE__ */ (0,
|
|
2491
|
+
props.onSignUp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardFooter, { ruled: !branded, children: [
|
|
2492
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "throttle-muted", children: [
|
|
2395
2493
|
t.signIn.switchPrompt,
|
|
2396
2494
|
" "
|
|
2397
2495
|
] }),
|
|
2398
|
-
/* @__PURE__ */ (0,
|
|
2496
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", elementKey: "signIn.switchLink", onClick: props.onSignUp, children: t.signIn.switchLink })
|
|
2399
2497
|
] }) : null
|
|
2400
2498
|
]
|
|
2401
2499
|
}
|
|
@@ -2403,8 +2501,8 @@ function SignIn(props) {
|
|
|
2403
2501
|
}
|
|
2404
2502
|
|
|
2405
2503
|
// src/react/components/auth/SignUp.tsx
|
|
2406
|
-
var
|
|
2407
|
-
var
|
|
2504
|
+
var import_react13 = require("react");
|
|
2505
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2408
2506
|
function SignUp(props) {
|
|
2409
2507
|
const a = useAppearance(props.appearance);
|
|
2410
2508
|
const cardClass = useCardClass();
|
|
@@ -2412,13 +2510,13 @@ function SignUp(props) {
|
|
|
2412
2510
|
const { t } = useCopy(props.localization);
|
|
2413
2511
|
const { auth } = useAuth();
|
|
2414
2512
|
const { submitting, error, notice, run } = useAction();
|
|
2415
|
-
const [email, setEmail] = (0,
|
|
2416
|
-
const [password, setPassword] = (0,
|
|
2513
|
+
const [email, setEmail] = (0, import_react13.useState)("");
|
|
2514
|
+
const [password, setPassword] = (0, import_react13.useState)("");
|
|
2417
2515
|
const variant = props.variant ?? "quiet";
|
|
2418
2516
|
const branded = variant === "branded";
|
|
2419
2517
|
const grouped = variant === "grouped";
|
|
2420
2518
|
const logo = useBrandLogo(props.logo);
|
|
2421
|
-
const emailField = /* @__PURE__ */ (0,
|
|
2519
|
+
const emailField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2422
2520
|
Field,
|
|
2423
2521
|
{
|
|
2424
2522
|
label: t.signUp.email,
|
|
@@ -2431,7 +2529,7 @@ function SignUp(props) {
|
|
|
2431
2529
|
grouped
|
|
2432
2530
|
}
|
|
2433
2531
|
);
|
|
2434
|
-
const passwordField = /* @__PURE__ */ (0,
|
|
2532
|
+
const passwordField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2435
2533
|
Field,
|
|
2436
2534
|
{
|
|
2437
2535
|
label: t.signUp.password,
|
|
@@ -2444,7 +2542,7 @@ function SignUp(props) {
|
|
|
2444
2542
|
grouped
|
|
2445
2543
|
}
|
|
2446
2544
|
);
|
|
2447
|
-
return /* @__PURE__ */ (0,
|
|
2545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2448
2546
|
"form",
|
|
2449
2547
|
{
|
|
2450
2548
|
...a.el("signUp.root", cardClass),
|
|
@@ -2460,7 +2558,7 @@ function SignUp(props) {
|
|
|
2460
2558
|
});
|
|
2461
2559
|
},
|
|
2462
2560
|
children: [
|
|
2463
|
-
/* @__PURE__ */ (0,
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2464
2562
|
CardHeader,
|
|
2465
2563
|
{
|
|
2466
2564
|
title: t.signUp.title,
|
|
@@ -2471,24 +2569,24 @@ function SignUp(props) {
|
|
|
2471
2569
|
branded
|
|
2472
2570
|
}
|
|
2473
2571
|
),
|
|
2474
|
-
/* @__PURE__ */ (0,
|
|
2475
|
-
grouped ? /* @__PURE__ */ (0,
|
|
2572
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardBody, { children: [
|
|
2573
|
+
grouped ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(FieldGroup, { children: [
|
|
2476
2574
|
emailField,
|
|
2477
2575
|
passwordField
|
|
2478
|
-
] }) : /* @__PURE__ */ (0,
|
|
2576
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2479
2577
|
emailField,
|
|
2480
2578
|
passwordField
|
|
2481
2579
|
] }),
|
|
2482
|
-
error ? /* @__PURE__ */ (0,
|
|
2483
|
-
notice ? /* @__PURE__ */ (0,
|
|
2484
|
-
/* @__PURE__ */ (0,
|
|
2580
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2581
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "info", children: notice }) : null,
|
|
2582
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signUp.submitButton", children: t.signUp.submitButton })
|
|
2485
2583
|
] }),
|
|
2486
|
-
props.onSignIn ? /* @__PURE__ */ (0,
|
|
2487
|
-
/* @__PURE__ */ (0,
|
|
2584
|
+
props.onSignIn ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardFooter, { ruled: !branded, children: [
|
|
2585
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "throttle-muted", children: [
|
|
2488
2586
|
t.signUp.switchPrompt,
|
|
2489
2587
|
" "
|
|
2490
2588
|
] }),
|
|
2491
|
-
/* @__PURE__ */ (0,
|
|
2589
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { variant: "link", elementKey: "signUp.switchLink", onClick: props.onSignIn, children: t.signUp.switchLink })
|
|
2492
2590
|
] }) : null
|
|
2493
2591
|
]
|
|
2494
2592
|
}
|
|
@@ -2496,8 +2594,8 @@ function SignUp(props) {
|
|
|
2496
2594
|
}
|
|
2497
2595
|
|
|
2498
2596
|
// src/react/components/auth/ForgotPassword.tsx
|
|
2499
|
-
var
|
|
2500
|
-
var
|
|
2597
|
+
var import_react14 = require("react");
|
|
2598
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2501
2599
|
function ForgotPassword(props) {
|
|
2502
2600
|
const a = useAppearance(props.appearance);
|
|
2503
2601
|
const cardClass = useCardClass();
|
|
@@ -2505,10 +2603,10 @@ function ForgotPassword(props) {
|
|
|
2505
2603
|
const { t } = useCopy(props.localization);
|
|
2506
2604
|
const { auth } = useAuth();
|
|
2507
2605
|
const { submitting, error, notice, run } = useAction();
|
|
2508
|
-
const [email, setEmail] = (0,
|
|
2606
|
+
const [email, setEmail] = (0, import_react14.useState)("");
|
|
2509
2607
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
2510
2608
|
const logo = useBrandLogo(props.logo);
|
|
2511
|
-
return /* @__PURE__ */ (0,
|
|
2609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2512
2610
|
"form",
|
|
2513
2611
|
{
|
|
2514
2612
|
...a.el("forgotPassword.root", cardClass),
|
|
@@ -2520,7 +2618,7 @@ function ForgotPassword(props) {
|
|
|
2520
2618
|
});
|
|
2521
2619
|
},
|
|
2522
2620
|
children: [
|
|
2523
|
-
/* @__PURE__ */ (0,
|
|
2621
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2524
2622
|
CardHeader,
|
|
2525
2623
|
{
|
|
2526
2624
|
title: t.forgotPassword.title,
|
|
@@ -2531,8 +2629,8 @@ function ForgotPassword(props) {
|
|
|
2531
2629
|
branded
|
|
2532
2630
|
}
|
|
2533
2631
|
),
|
|
2534
|
-
/* @__PURE__ */ (0,
|
|
2535
|
-
/* @__PURE__ */ (0,
|
|
2632
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CardBody, { children: [
|
|
2633
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2536
2634
|
Field,
|
|
2537
2635
|
{
|
|
2538
2636
|
label: t.forgotPassword.email,
|
|
@@ -2544,19 +2642,19 @@ function ForgotPassword(props) {
|
|
|
2544
2642
|
elementKey: "forgotPassword.emailField"
|
|
2545
2643
|
}
|
|
2546
2644
|
),
|
|
2547
|
-
error ? /* @__PURE__ */ (0,
|
|
2548
|
-
notice ? /* @__PURE__ */ (0,
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2645
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2646
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2647
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { type: "submit", loading: submitting, elementKey: "forgotPassword.submitButton", children: t.forgotPassword.submitButton })
|
|
2550
2648
|
] }),
|
|
2551
|
-
props.onBack ? /* @__PURE__ */ (0,
|
|
2649
|
+
props.onBack ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CardFooter, { ruled: !branded, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "link", elementKey: "forgotPassword.backLink", onClick: props.onBack, children: t.forgotPassword.backLink }) }) : null
|
|
2552
2650
|
]
|
|
2553
2651
|
}
|
|
2554
2652
|
) }) });
|
|
2555
2653
|
}
|
|
2556
2654
|
|
|
2557
2655
|
// src/react/components/auth/ResetPassword.tsx
|
|
2558
|
-
var
|
|
2559
|
-
var
|
|
2656
|
+
var import_react15 = require("react");
|
|
2657
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2560
2658
|
function ResetPassword(props) {
|
|
2561
2659
|
const a = useAppearance(props.appearance);
|
|
2562
2660
|
const cardClass = useCardClass();
|
|
@@ -2564,11 +2662,11 @@ function ResetPassword(props) {
|
|
|
2564
2662
|
const { t } = useCopy(props.localization);
|
|
2565
2663
|
const { auth } = useAuth();
|
|
2566
2664
|
const { submitting, error, notice, run } = useAction();
|
|
2567
|
-
const [password, setPassword] = (0,
|
|
2665
|
+
const [password, setPassword] = (0, import_react15.useState)("");
|
|
2568
2666
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
2569
2667
|
const logo = useBrandLogo(props.logo);
|
|
2570
|
-
return /* @__PURE__ */ (0,
|
|
2571
|
-
/* @__PURE__ */ (0,
|
|
2668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { ...a.el("resetPassword.root", cardClass), children: [
|
|
2669
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2572
2670
|
CardHeader,
|
|
2573
2671
|
{
|
|
2574
2672
|
title: t.resetPassword.title,
|
|
@@ -2578,11 +2676,11 @@ function ResetPassword(props) {
|
|
|
2578
2676
|
branded
|
|
2579
2677
|
}
|
|
2580
2678
|
),
|
|
2581
|
-
/* @__PURE__ */ (0,
|
|
2679
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardBody, { children: !props.token ? (
|
|
2582
2680
|
// No form at all without a token. A submit button that can only
|
|
2583
2681
|
// fail is worse than an explanation.
|
|
2584
|
-
/* @__PURE__ */ (0,
|
|
2585
|
-
) : /* @__PURE__ */ (0,
|
|
2682
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: t.resetPassword.missingToken })
|
|
2683
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2586
2684
|
"form",
|
|
2587
2685
|
{
|
|
2588
2686
|
onSubmit: (e) => {
|
|
@@ -2593,8 +2691,8 @@ function ResetPassword(props) {
|
|
|
2593
2691
|
return t.resetPassword.doneNotice;
|
|
2594
2692
|
});
|
|
2595
2693
|
},
|
|
2596
|
-
children: /* @__PURE__ */ (0,
|
|
2597
|
-
/* @__PURE__ */ (0,
|
|
2694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "throttle-stack", children: [
|
|
2695
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2598
2696
|
Field,
|
|
2599
2697
|
{
|
|
2600
2698
|
label: t.resetPassword.password,
|
|
@@ -2606,9 +2704,9 @@ function ResetPassword(props) {
|
|
|
2606
2704
|
elementKey: "resetPassword.passwordField"
|
|
2607
2705
|
}
|
|
2608
2706
|
),
|
|
2609
|
-
error ? /* @__PURE__ */ (0,
|
|
2610
|
-
notice ? /* @__PURE__ */ (0,
|
|
2611
|
-
/* @__PURE__ */ (0,
|
|
2707
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2708
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2709
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { type: "submit", loading: submitting, elementKey: "resetPassword.submitButton", children: t.resetPassword.submitButton })
|
|
2612
2710
|
] })
|
|
2613
2711
|
}
|
|
2614
2712
|
) })
|
|
@@ -2616,8 +2714,8 @@ function ResetPassword(props) {
|
|
|
2616
2714
|
}
|
|
2617
2715
|
|
|
2618
2716
|
// src/react/components/auth/VerifyEmail.tsx
|
|
2619
|
-
var
|
|
2620
|
-
var
|
|
2717
|
+
var import_react16 = require("react");
|
|
2718
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2621
2719
|
function VerifyEmail(props) {
|
|
2622
2720
|
const a = useAppearance(props.appearance);
|
|
2623
2721
|
const cardClass = useCardClass();
|
|
@@ -2625,12 +2723,12 @@ function VerifyEmail(props) {
|
|
|
2625
2723
|
const { t, errorMessage } = useCopy(props.localization);
|
|
2626
2724
|
const { auth } = useAuth();
|
|
2627
2725
|
const { submitting, notice, run } = useAction();
|
|
2628
|
-
const [state, setState] = (0,
|
|
2629
|
-
const [error, setError] = (0,
|
|
2726
|
+
const [state, setState] = (0, import_react16.useState)(props.token ? "verifying" : "idle");
|
|
2727
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
2630
2728
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
2631
2729
|
const logo = useBrandLogo(props.logo);
|
|
2632
|
-
const attempted = (0,
|
|
2633
|
-
(0,
|
|
2730
|
+
const attempted = (0, import_react16.useRef)(null);
|
|
2731
|
+
(0, import_react16.useEffect)(() => {
|
|
2634
2732
|
const token = props.token;
|
|
2635
2733
|
if (!token || attempted.current === token) return;
|
|
2636
2734
|
attempted.current = token;
|
|
@@ -2643,8 +2741,8 @@ function VerifyEmail(props) {
|
|
|
2643
2741
|
setState("failed");
|
|
2644
2742
|
});
|
|
2645
2743
|
}, [props.token, auth]);
|
|
2646
|
-
return /* @__PURE__ */ (0,
|
|
2647
|
-
/* @__PURE__ */ (0,
|
|
2744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { ...a.el("verifyEmail.root", cardClass), children: [
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2648
2746
|
CardHeader,
|
|
2649
2747
|
{
|
|
2650
2748
|
title: t.verifyEmail.title,
|
|
@@ -2654,17 +2752,17 @@ function VerifyEmail(props) {
|
|
|
2654
2752
|
branded
|
|
2655
2753
|
}
|
|
2656
2754
|
),
|
|
2657
|
-
/* @__PURE__ */ (0,
|
|
2658
|
-
state === "verifying" ? /* @__PURE__ */ (0,
|
|
2659
|
-
/* @__PURE__ */ (0,
|
|
2755
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(CardBody, { children: [
|
|
2756
|
+
state === "verifying" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { children: [
|
|
2757
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Spinner, {}),
|
|
2660
2758
|
" ",
|
|
2661
2759
|
t.verifyEmail.verifying
|
|
2662
2760
|
] }) : null,
|
|
2663
|
-
state === "done" ? /* @__PURE__ */ (0,
|
|
2664
|
-
state === "failed" && error ? /* @__PURE__ */ (0,
|
|
2665
|
-
state === "idle" ? /* @__PURE__ */ (0,
|
|
2666
|
-
notice ? /* @__PURE__ */ (0,
|
|
2667
|
-
state !== "done" ? /* @__PURE__ */ (0,
|
|
2761
|
+
state === "done" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: t.verifyEmail.success }) : null,
|
|
2762
|
+
state === "failed" && error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2763
|
+
state === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "throttle-muted", children: t.verifyEmail.instructions }) : null,
|
|
2764
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2765
|
+
state !== "done" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2668
2766
|
Button,
|
|
2669
2767
|
{
|
|
2670
2768
|
variant: "secondary",
|
|
@@ -2682,7 +2780,7 @@ function VerifyEmail(props) {
|
|
|
2682
2780
|
}
|
|
2683
2781
|
|
|
2684
2782
|
// src/react/components/auth/AuthFlow.tsx
|
|
2685
|
-
var
|
|
2783
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2686
2784
|
var HASH_FOR = {
|
|
2687
2785
|
signIn: "#/sign-in",
|
|
2688
2786
|
signUp: "#/sign-up",
|
|
@@ -2708,9 +2806,9 @@ function readLocation() {
|
|
|
2708
2806
|
function AuthFlow(props) {
|
|
2709
2807
|
const a = useAppearance(props.appearance);
|
|
2710
2808
|
const controlled = props.view !== void 0;
|
|
2711
|
-
const [internal, setInternal] = (0,
|
|
2712
|
-
const [urlToken, setUrlToken] = (0,
|
|
2713
|
-
(0,
|
|
2809
|
+
const [internal, setInternal] = (0, import_react17.useState)(props.initialView ?? "signIn");
|
|
2810
|
+
const [urlToken, setUrlToken] = (0, import_react17.useState)(void 0);
|
|
2811
|
+
(0, import_react17.useEffect)(() => {
|
|
2714
2812
|
const found = readLocation();
|
|
2715
2813
|
if (found.token) setUrlToken(found.token);
|
|
2716
2814
|
if (found.view && !controlled && props.initialView === void 0) setInternal(found.view);
|
|
@@ -2724,7 +2822,7 @@ function AuthFlow(props) {
|
|
|
2724
2822
|
window.location.hash = HASH_FOR[next];
|
|
2725
2823
|
}
|
|
2726
2824
|
};
|
|
2727
|
-
(0,
|
|
2825
|
+
(0, import_react17.useEffect)(() => {
|
|
2728
2826
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
2729
2827
|
const onHashChange = () => {
|
|
2730
2828
|
if (controlled) return;
|
|
@@ -2740,8 +2838,8 @@ function AuthFlow(props) {
|
|
|
2740
2838
|
return () => window.removeEventListener("hashchange", onHashChange);
|
|
2741
2839
|
}, [props.routing, controlled]);
|
|
2742
2840
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
2743
|
-
return /* @__PURE__ */ (0,
|
|
2744
|
-
view === "signIn" ? /* @__PURE__ */ (0,
|
|
2841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ...a.el("authFlow.root"), children: [
|
|
2842
|
+
view === "signIn" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2745
2843
|
SignIn,
|
|
2746
2844
|
{
|
|
2747
2845
|
...shared,
|
|
@@ -2750,19 +2848,19 @@ function AuthFlow(props) {
|
|
|
2750
2848
|
onSignUp: () => go("signUp")
|
|
2751
2849
|
}
|
|
2752
2850
|
) : null,
|
|
2753
|
-
view === "signUp" ? /* @__PURE__ */ (0,
|
|
2754
|
-
view === "forgotPassword" ? /* @__PURE__ */ (0,
|
|
2755
|
-
view === "resetPassword" ? /* @__PURE__ */ (0,
|
|
2756
|
-
view === "verifyEmail" ? /* @__PURE__ */ (0,
|
|
2851
|
+
view === "signUp" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SignUp, { ...shared, onSuccess: props.afterSignUp, onSignIn: () => go("signIn") }) : null,
|
|
2852
|
+
view === "forgotPassword" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ForgotPassword, { ...shared, onBack: () => go("signIn") }) : null,
|
|
2853
|
+
view === "resetPassword" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ResetPassword, { ...shared, token, onSuccess: () => go("signIn") }) : null,
|
|
2854
|
+
view === "verifyEmail" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VerifyEmail, { ...shared, token }) : null
|
|
2757
2855
|
] }) });
|
|
2758
2856
|
}
|
|
2759
2857
|
|
|
2760
2858
|
// src/react/components/auth/AuthModal.tsx
|
|
2761
|
-
var
|
|
2859
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2762
2860
|
function AuthModal(props) {
|
|
2763
2861
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2764
|
-
const titleId = (0,
|
|
2765
|
-
return /* @__PURE__ */ (0,
|
|
2862
|
+
const titleId = (0, import_react18.useId)();
|
|
2863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2766
2864
|
Modal,
|
|
2767
2865
|
{
|
|
2768
2866
|
open: props.open,
|
|
@@ -2772,8 +2870,8 @@ function AuthModal(props) {
|
|
|
2772
2870
|
overlayKey: "authModal.overlay",
|
|
2773
2871
|
containerKey: "authModal.container",
|
|
2774
2872
|
children: [
|
|
2775
|
-
/* @__PURE__ */ (0,
|
|
2776
|
-
/* @__PURE__ */ (0,
|
|
2873
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h2", { id: titleId, style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: "Account" }),
|
|
2874
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2777
2875
|
AuthFlow,
|
|
2778
2876
|
{
|
|
2779
2877
|
initialView: props.initialView,
|
|
@@ -2789,14 +2887,14 @@ function AuthModal(props) {
|
|
|
2789
2887
|
}
|
|
2790
2888
|
|
|
2791
2889
|
// src/react/components/account/AccountModal.tsx
|
|
2792
|
-
var
|
|
2890
|
+
var import_react30 = require("react");
|
|
2793
2891
|
|
|
2794
2892
|
// src/react/components/account/AccountDashboard.tsx
|
|
2795
|
-
var
|
|
2893
|
+
var import_react29 = require("react");
|
|
2796
2894
|
|
|
2797
2895
|
// src/react/components/account/VerifyEmailBanner.tsx
|
|
2798
|
-
var
|
|
2799
|
-
var
|
|
2896
|
+
var import_react19 = require("react");
|
|
2897
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2800
2898
|
var DISMISS_KEY = "throttle-auth:verify-banner-dismissed";
|
|
2801
2899
|
function readDismissed() {
|
|
2802
2900
|
try {
|
|
@@ -2817,14 +2915,14 @@ function VerifyEmailBanner(props) {
|
|
|
2817
2915
|
const { t } = useCopy(props.localization);
|
|
2818
2916
|
const { auth, status, emailVerified } = useAuth();
|
|
2819
2917
|
const { submitting, notice, error, run } = useAction();
|
|
2820
|
-
const [dismissed, setDismissed] = (0,
|
|
2918
|
+
const [dismissed, setDismissed] = (0, import_react19.useState)(readDismissed);
|
|
2821
2919
|
if (status !== "authenticated" || emailVerified || dismissed) return null;
|
|
2822
|
-
return /* @__PURE__ */ (0,
|
|
2823
|
-
/* @__PURE__ */ (0,
|
|
2824
|
-
notice ? /* @__PURE__ */ (0,
|
|
2825
|
-
error ? /* @__PURE__ */ (0,
|
|
2826
|
-
/* @__PURE__ */ (0,
|
|
2827
|
-
/* @__PURE__ */ (0,
|
|
2920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { ...a.el("verifyBanner.root", "throttle-banner"), children: [
|
|
2921
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { ...a.el("verifyBanner.message"), children: t.verifyBanner.message }),
|
|
2922
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2923
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2924
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "throttle-actions", children: [
|
|
2925
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2828
2926
|
Button,
|
|
2829
2927
|
{
|
|
2830
2928
|
variant: "secondary",
|
|
@@ -2837,7 +2935,7 @@ function VerifyEmailBanner(props) {
|
|
|
2837
2935
|
children: t.verifyBanner.resendButton
|
|
2838
2936
|
}
|
|
2839
2937
|
),
|
|
2840
|
-
/* @__PURE__ */ (0,
|
|
2938
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2841
2939
|
Button,
|
|
2842
2940
|
{
|
|
2843
2941
|
variant: "link",
|
|
@@ -2854,9 +2952,9 @@ function VerifyEmailBanner(props) {
|
|
|
2854
2952
|
}
|
|
2855
2953
|
|
|
2856
2954
|
// src/react/components/account/icons.tsx
|
|
2857
|
-
var
|
|
2955
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2858
2956
|
function Glyph(props) {
|
|
2859
|
-
return /* @__PURE__ */ (0,
|
|
2957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2860
2958
|
"svg",
|
|
2861
2959
|
{
|
|
2862
2960
|
className: "throttle-tabs__railicon",
|
|
@@ -2875,43 +2973,43 @@ function Glyph(props) {
|
|
|
2875
2973
|
);
|
|
2876
2974
|
}
|
|
2877
2975
|
var ACCOUNT_ICONS = {
|
|
2878
|
-
profile: /* @__PURE__ */ (0,
|
|
2879
|
-
/* @__PURE__ */ (0,
|
|
2880
|
-
/* @__PURE__ */ (0,
|
|
2976
|
+
profile: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2977
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("circle", { cx: "12", cy: "8", r: "4" }),
|
|
2978
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M4 21c0-4 3.6-6 8-6s8 2 8 6" })
|
|
2881
2979
|
] }),
|
|
2882
|
-
addresses: /* @__PURE__ */ (0,
|
|
2883
|
-
/* @__PURE__ */ (0,
|
|
2884
|
-
/* @__PURE__ */ (0,
|
|
2980
|
+
addresses: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M12 21s7-5.3 7-11a7 7 0 1 0-14 0c0 5.7 7 11 7 11Z" }),
|
|
2982
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("circle", { cx: "12", cy: "10", r: "2.5" })
|
|
2885
2983
|
] }),
|
|
2886
|
-
paymentMethods: /* @__PURE__ */ (0,
|
|
2887
|
-
/* @__PURE__ */ (0,
|
|
2888
|
-
/* @__PURE__ */ (0,
|
|
2984
|
+
paymentMethods: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2985
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("rect", { x: "2.5", y: "5.5", width: "19", height: "13", rx: "2.5" }),
|
|
2986
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M2.5 10h19" })
|
|
2889
2987
|
] }),
|
|
2890
|
-
orders: /* @__PURE__ */ (0,
|
|
2891
|
-
/* @__PURE__ */ (0,
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
2893
|
-
/* @__PURE__ */ (0,
|
|
2988
|
+
orders: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2989
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M4 7h16v13H4z" }),
|
|
2990
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M8 7V4h8v3" }),
|
|
2991
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M8 12h8" })
|
|
2894
2992
|
] }),
|
|
2895
|
-
invoices: /* @__PURE__ */ (0,
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
2897
|
-
/* @__PURE__ */ (0,
|
|
2993
|
+
invoices: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2994
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M6 3h12v18l-3-2-3 2-3-2-3 2Z" }),
|
|
2995
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M9 8h6M9 12h6" })
|
|
2898
2996
|
] }),
|
|
2899
|
-
subscriptions: /* @__PURE__ */ (0,
|
|
2900
|
-
/* @__PURE__ */ (0,
|
|
2901
|
-
/* @__PURE__ */ (0,
|
|
2902
|
-
/* @__PURE__ */ (0,
|
|
2997
|
+
subscriptions: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2998
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M3 12a9 9 0 0 1 15.5-6.2" }),
|
|
2999
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M21 12a9 9 0 0 1-15.5 6.2" }),
|
|
3000
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M18 3v4h-4M6 21v-4h4" })
|
|
2903
3001
|
] }),
|
|
2904
|
-
security: /* @__PURE__ */ (0,
|
|
2905
|
-
/* @__PURE__ */ (0,
|
|
2906
|
-
/* @__PURE__ */ (0,
|
|
3002
|
+
security: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
3003
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M12 3 4 6.5V12c0 5 3.4 8.3 8 9 4.6-.7 8-4 8-9V6.5Z" }),
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "m9 12 2 2 4-4" })
|
|
2907
3005
|
] })
|
|
2908
3006
|
};
|
|
2909
3007
|
|
|
2910
3008
|
// src/react/components/account/ProfilePanel.tsx
|
|
2911
|
-
var
|
|
3009
|
+
var import_react21 = require("react");
|
|
2912
3010
|
|
|
2913
3011
|
// src/react/hooks.ts
|
|
2914
|
-
var
|
|
3012
|
+
var import_react20 = require("react");
|
|
2915
3013
|
function asError(err) {
|
|
2916
3014
|
if (err instanceof ThrottleAuthError) return err;
|
|
2917
3015
|
const anyErr = err;
|
|
@@ -2923,19 +3021,19 @@ function asError(err) {
|
|
|
2923
3021
|
}
|
|
2924
3022
|
function useResource(empty, load, deps) {
|
|
2925
3023
|
const { status, emailVerified } = useAuth();
|
|
2926
|
-
const [data, setData] = (0,
|
|
2927
|
-
const [isLoading, setIsLoading] = (0,
|
|
2928
|
-
const [error, setError] = (0,
|
|
2929
|
-
const gen = (0,
|
|
2930
|
-
const alive = (0,
|
|
2931
|
-
(0,
|
|
3024
|
+
const [data, setData] = (0, import_react20.useState)(empty);
|
|
3025
|
+
const [isLoading, setIsLoading] = (0, import_react20.useState)(status === "loading");
|
|
3026
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
3027
|
+
const gen = (0, import_react20.useRef)(0);
|
|
3028
|
+
const alive = (0, import_react20.useRef)(true);
|
|
3029
|
+
(0, import_react20.useEffect)(() => {
|
|
2932
3030
|
alive.current = true;
|
|
2933
3031
|
return () => {
|
|
2934
3032
|
alive.current = false;
|
|
2935
3033
|
gen.current++;
|
|
2936
3034
|
};
|
|
2937
3035
|
}, []);
|
|
2938
|
-
const refetch = (0,
|
|
3036
|
+
const refetch = (0, import_react20.useCallback)(async () => {
|
|
2939
3037
|
const mine = ++gen.current;
|
|
2940
3038
|
setIsLoading(true);
|
|
2941
3039
|
try {
|
|
@@ -2950,7 +3048,7 @@ function useResource(empty, load, deps) {
|
|
|
2950
3048
|
if (alive.current && gen.current === mine) setIsLoading(false);
|
|
2951
3049
|
}
|
|
2952
3050
|
}, deps);
|
|
2953
|
-
(0,
|
|
3051
|
+
(0, import_react20.useEffect)(() => {
|
|
2954
3052
|
if (status !== "authenticated") {
|
|
2955
3053
|
gen.current++;
|
|
2956
3054
|
setData(empty);
|
|
@@ -2965,7 +3063,7 @@ function useResource(empty, load, deps) {
|
|
|
2965
3063
|
function useCustomer() {
|
|
2966
3064
|
const { account } = useAuth();
|
|
2967
3065
|
const res = useResource(null, () => account.getProfile(), [account]);
|
|
2968
|
-
const update = (0,
|
|
3066
|
+
const update = (0, import_react20.useCallback)(async (patch) => {
|
|
2969
3067
|
await account.updateProfile(patch);
|
|
2970
3068
|
await res.refetch();
|
|
2971
3069
|
}, [account, res]);
|
|
@@ -3034,32 +3132,32 @@ function useInvoice(id) {
|
|
|
3034
3132
|
}
|
|
3035
3133
|
|
|
3036
3134
|
// src/react/components/account/PanelState.tsx
|
|
3037
|
-
var
|
|
3135
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3038
3136
|
function PanelState(props) {
|
|
3039
3137
|
const { t, errorMessage } = useCopy();
|
|
3040
3138
|
const { data, isLoading, error, refetch } = props.resource;
|
|
3041
3139
|
const empty = props.isEmpty(data);
|
|
3042
|
-
if (isLoading && empty) return /* @__PURE__ */ (0,
|
|
3043
|
-
const errorBanner = error ? /* @__PURE__ */ (0,
|
|
3044
|
-
/* @__PURE__ */ (0,
|
|
3045
|
-
/* @__PURE__ */ (0,
|
|
3140
|
+
if (isLoading && empty) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Skeleton, { count: props.skeletonRows ?? 3 });
|
|
3141
|
+
const errorBanner = error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "throttle-stack", children: [
|
|
3142
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "error", children: errorMessage(error) }),
|
|
3143
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { variant: "secondary", onClick: () => void refetch(), children: t.common.retry })
|
|
3046
3144
|
] }) : null;
|
|
3047
3145
|
const gatedByVerification = error?.code === "verification_required";
|
|
3048
3146
|
if (gatedByVerification && empty) {
|
|
3049
|
-
return /* @__PURE__ */ (0,
|
|
3147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription ?? props.emptyDescription });
|
|
3050
3148
|
}
|
|
3051
3149
|
if (error && empty) return errorBanner;
|
|
3052
3150
|
if (empty) {
|
|
3053
|
-
return props.gated ? /* @__PURE__ */ (0,
|
|
3151
|
+
return props.gated ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.emptyDescription });
|
|
3054
3152
|
}
|
|
3055
|
-
return /* @__PURE__ */ (0,
|
|
3153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
3056
3154
|
errorBanner,
|
|
3057
3155
|
props.children(data)
|
|
3058
3156
|
] });
|
|
3059
3157
|
}
|
|
3060
3158
|
|
|
3061
3159
|
// src/react/components/account/ProfilePanel.tsx
|
|
3062
|
-
var
|
|
3160
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3063
3161
|
function ProfilePanel(props) {
|
|
3064
3162
|
const a = useAppearance(props.appearance);
|
|
3065
3163
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3067,9 +3165,9 @@ function ProfilePanel(props) {
|
|
|
3067
3165
|
const { status } = useAuth();
|
|
3068
3166
|
const resource = useCustomer();
|
|
3069
3167
|
const { submitting, error, notice, run } = useAction();
|
|
3070
|
-
const [form, setForm] = (0,
|
|
3071
|
-
const edited = (0,
|
|
3072
|
-
(0,
|
|
3168
|
+
const [form, setForm] = (0, import_react21.useState)({ firstName: "", lastName: "", phone: "", company: "" });
|
|
3169
|
+
const edited = (0, import_react21.useRef)(false);
|
|
3170
|
+
(0, import_react21.useEffect)(() => {
|
|
3073
3171
|
const c = resource.data;
|
|
3074
3172
|
if (!c || edited.current) return;
|
|
3075
3173
|
setForm({
|
|
@@ -3080,14 +3178,14 @@ function ProfilePanel(props) {
|
|
|
3080
3178
|
});
|
|
3081
3179
|
}, [resource.data]);
|
|
3082
3180
|
if (status === "unauthenticated") return null;
|
|
3083
|
-
return /* @__PURE__ */ (0,
|
|
3181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ...a.el("profilePanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3084
3182
|
PanelState,
|
|
3085
3183
|
{
|
|
3086
3184
|
resource,
|
|
3087
3185
|
isEmpty: (c) => c === null,
|
|
3088
3186
|
emptyTitle: t.common.somethingWentWrong,
|
|
3089
3187
|
skeletonRows: 4,
|
|
3090
|
-
children: (customer) => /* @__PURE__ */ (0,
|
|
3188
|
+
children: (customer) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
3091
3189
|
"form",
|
|
3092
3190
|
{
|
|
3093
3191
|
...a.el("profilePanel.form", "throttle-stack"),
|
|
@@ -3105,7 +3203,7 @@ function ProfilePanel(props) {
|
|
|
3105
3203
|
});
|
|
3106
3204
|
},
|
|
3107
3205
|
children: [
|
|
3108
|
-
/* @__PURE__ */ (0,
|
|
3206
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3109
3207
|
Field,
|
|
3110
3208
|
{
|
|
3111
3209
|
label: t.profile.email,
|
|
@@ -3117,8 +3215,8 @@ function ProfilePanel(props) {
|
|
|
3117
3215
|
hint: t.profile.emailReadOnly
|
|
3118
3216
|
}
|
|
3119
3217
|
),
|
|
3120
|
-
/* @__PURE__ */ (0,
|
|
3121
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(FieldRow, { children: [
|
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3122
3220
|
Field,
|
|
3123
3221
|
{
|
|
3124
3222
|
label: t.profile.firstName,
|
|
@@ -3130,7 +3228,7 @@ function ProfilePanel(props) {
|
|
|
3130
3228
|
}
|
|
3131
3229
|
}
|
|
3132
3230
|
),
|
|
3133
|
-
/* @__PURE__ */ (0,
|
|
3231
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3134
3232
|
Field,
|
|
3135
3233
|
{
|
|
3136
3234
|
label: t.profile.lastName,
|
|
@@ -3143,8 +3241,8 @@ function ProfilePanel(props) {
|
|
|
3143
3241
|
}
|
|
3144
3242
|
)
|
|
3145
3243
|
] }),
|
|
3146
|
-
/* @__PURE__ */ (0,
|
|
3147
|
-
/* @__PURE__ */ (0,
|
|
3244
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(FieldRow, { children: [
|
|
3245
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3148
3246
|
Field,
|
|
3149
3247
|
{
|
|
3150
3248
|
label: t.profile.phone,
|
|
@@ -3157,7 +3255,7 @@ function ProfilePanel(props) {
|
|
|
3157
3255
|
}
|
|
3158
3256
|
}
|
|
3159
3257
|
),
|
|
3160
|
-
/* @__PURE__ */ (0,
|
|
3258
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3161
3259
|
Field,
|
|
3162
3260
|
{
|
|
3163
3261
|
label: t.profile.company,
|
|
@@ -3170,9 +3268,9 @@ function ProfilePanel(props) {
|
|
|
3170
3268
|
}
|
|
3171
3269
|
)
|
|
3172
3270
|
] }),
|
|
3173
|
-
error ? /* @__PURE__ */ (0,
|
|
3174
|
-
notice ? /* @__PURE__ */ (0,
|
|
3175
|
-
/* @__PURE__ */ (0,
|
|
3271
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3272
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
3273
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
3176
3274
|
]
|
|
3177
3275
|
}
|
|
3178
3276
|
)
|
|
@@ -3181,16 +3279,16 @@ function ProfilePanel(props) {
|
|
|
3181
3279
|
}
|
|
3182
3280
|
|
|
3183
3281
|
// src/react/components/account/AddressesPanel.tsx
|
|
3184
|
-
var
|
|
3282
|
+
var import_react23 = require("react");
|
|
3185
3283
|
|
|
3186
3284
|
// src/react/components/account/AddressForm.tsx
|
|
3187
|
-
var
|
|
3188
|
-
var
|
|
3285
|
+
var import_react22 = require("react");
|
|
3286
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3189
3287
|
function AddressForm(props) {
|
|
3190
3288
|
const a = useAppearance();
|
|
3191
3289
|
const { t } = useCopy();
|
|
3192
3290
|
const i = props.initial;
|
|
3193
|
-
const [form, setForm] = (0,
|
|
3291
|
+
const [form, setForm] = (0, import_react22.useState)({
|
|
3194
3292
|
label: i?.label ?? "",
|
|
3195
3293
|
firstName: i?.firstName ?? "",
|
|
3196
3294
|
lastName: i?.lastName ?? "",
|
|
@@ -3204,7 +3302,7 @@ function AddressForm(props) {
|
|
|
3204
3302
|
phone: i?.phone ?? ""
|
|
3205
3303
|
});
|
|
3206
3304
|
const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
|
|
3207
|
-
return /* @__PURE__ */ (0,
|
|
3305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3208
3306
|
"form",
|
|
3209
3307
|
{
|
|
3210
3308
|
...a.el("addressesPanel.form", "throttle-stack"),
|
|
@@ -3226,15 +3324,15 @@ function AddressForm(props) {
|
|
|
3226
3324
|
});
|
|
3227
3325
|
},
|
|
3228
3326
|
children: [
|
|
3229
|
-
/* @__PURE__ */ (0,
|
|
3230
|
-
/* @__PURE__ */ (0,
|
|
3231
|
-
/* @__PURE__ */ (0,
|
|
3327
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
|
|
3328
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
|
|
3329
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" })
|
|
3232
3330
|
] }),
|
|
3233
|
-
/* @__PURE__ */ (0,
|
|
3234
|
-
/* @__PURE__ */ (0,
|
|
3235
|
-
/* @__PURE__ */ (0,
|
|
3331
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
|
|
3332
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
|
|
3333
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" })
|
|
3236
3334
|
] }),
|
|
3237
|
-
/* @__PURE__ */ (0,
|
|
3335
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3238
3336
|
Field,
|
|
3239
3337
|
{
|
|
3240
3338
|
label: t.addresses.addressLine1,
|
|
@@ -3244,7 +3342,7 @@ function AddressForm(props) {
|
|
|
3244
3342
|
autoComplete: "address-line1"
|
|
3245
3343
|
}
|
|
3246
3344
|
),
|
|
3247
|
-
/* @__PURE__ */ (0,
|
|
3345
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3248
3346
|
Field,
|
|
3249
3347
|
{
|
|
3250
3348
|
label: t.addresses.addressLine2,
|
|
@@ -3253,9 +3351,9 @@ function AddressForm(props) {
|
|
|
3253
3351
|
autoComplete: "address-line2"
|
|
3254
3352
|
}
|
|
3255
3353
|
),
|
|
3256
|
-
/* @__PURE__ */ (0,
|
|
3257
|
-
/* @__PURE__ */ (0,
|
|
3258
|
-
/* @__PURE__ */ (0,
|
|
3354
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
|
|
3355
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
|
|
3356
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3259
3357
|
Field,
|
|
3260
3358
|
{
|
|
3261
3359
|
label: t.addresses.stateProvince,
|
|
@@ -3265,8 +3363,8 @@ function AddressForm(props) {
|
|
|
3265
3363
|
}
|
|
3266
3364
|
)
|
|
3267
3365
|
] }),
|
|
3268
|
-
/* @__PURE__ */ (0,
|
|
3269
|
-
/* @__PURE__ */ (0,
|
|
3366
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
|
|
3367
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3270
3368
|
Field,
|
|
3271
3369
|
{
|
|
3272
3370
|
label: t.addresses.postalCode,
|
|
@@ -3275,7 +3373,7 @@ function AddressForm(props) {
|
|
|
3275
3373
|
autoComplete: "postal-code"
|
|
3276
3374
|
}
|
|
3277
3375
|
),
|
|
3278
|
-
/* @__PURE__ */ (0,
|
|
3376
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3279
3377
|
Field,
|
|
3280
3378
|
{
|
|
3281
3379
|
label: t.addresses.countryCode,
|
|
@@ -3287,11 +3385,11 @@ function AddressForm(props) {
|
|
|
3287
3385
|
}
|
|
3288
3386
|
)
|
|
3289
3387
|
] }),
|
|
3290
|
-
/* @__PURE__ */ (0,
|
|
3291
|
-
props.error ? /* @__PURE__ */ (0,
|
|
3292
|
-
/* @__PURE__ */ (0,
|
|
3293
|
-
/* @__PURE__ */ (0,
|
|
3294
|
-
/* @__PURE__ */ (0,
|
|
3388
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.phone, type: "tel", value: form.phone, onChange: set("phone"), autoComplete: "tel" }),
|
|
3389
|
+
props.error ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { tone: "error", children: props.error }) : null,
|
|
3390
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "throttle-actions", children: [
|
|
3391
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { type: "submit", loading: props.submitting, children: t.common.save }),
|
|
3392
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "link", onClick: props.onCancel, children: t.common.cancel })
|
|
3295
3393
|
] })
|
|
3296
3394
|
]
|
|
3297
3395
|
}
|
|
@@ -3299,7 +3397,7 @@ function AddressForm(props) {
|
|
|
3299
3397
|
}
|
|
3300
3398
|
|
|
3301
3399
|
// src/react/components/account/AddressesPanel.tsx
|
|
3302
|
-
var
|
|
3400
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3303
3401
|
function AddressesPanel(props) {
|
|
3304
3402
|
const a = useAppearance(props.appearance);
|
|
3305
3403
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3307,7 +3405,7 @@ function AddressesPanel(props) {
|
|
|
3307
3405
|
const resource = useAddresses();
|
|
3308
3406
|
const { submitting, error, run } = useAction();
|
|
3309
3407
|
const confirm = useConfirm();
|
|
3310
|
-
const [editing, setEditing] = (0,
|
|
3408
|
+
const [editing, setEditing] = (0, import_react23.useState)(null);
|
|
3311
3409
|
const variant = props.variant ?? "rows";
|
|
3312
3410
|
const rowsVariant = variant === "rows";
|
|
3313
3411
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -3315,9 +3413,9 @@ function AddressesPanel(props) {
|
|
|
3315
3413
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3316
3414
|
const close = () => setEditing(null);
|
|
3317
3415
|
const formatAddress = (address) => [address.addressLine2, address.city, address.stateProvince, address.postalCode, address.countryCode].filter(Boolean).join(", ");
|
|
3318
|
-
return /* @__PURE__ */ (0,
|
|
3319
|
-
!editing && error ? /* @__PURE__ */ (0,
|
|
3320
|
-
editing ? /* @__PURE__ */ (0,
|
|
3416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...a.el("addressesPanel.root", "throttle-panel"), children: [
|
|
3417
|
+
!editing && error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3418
|
+
editing ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3321
3419
|
AddressForm,
|
|
3322
3420
|
{
|
|
3323
3421
|
initial: editing === "new" ? void 0 : editing,
|
|
@@ -3330,16 +3428,16 @@ function AddressesPanel(props) {
|
|
|
3330
3428
|
close();
|
|
3331
3429
|
})
|
|
3332
3430
|
}
|
|
3333
|
-
) : /* @__PURE__ */ (0,
|
|
3334
|
-
/* @__PURE__ */ (0,
|
|
3335
|
-
/* @__PURE__ */ (0,
|
|
3431
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
3432
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
|
|
3433
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3336
3434
|
PanelState,
|
|
3337
3435
|
{
|
|
3338
3436
|
resource,
|
|
3339
3437
|
isEmpty: (rows) => rows.length === 0,
|
|
3340
3438
|
emptyTitle: t.addresses.empty,
|
|
3341
3439
|
emptyDescription: t.addresses.emptyDescription,
|
|
3342
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3440
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3343
3441
|
DataTable,
|
|
3344
3442
|
{
|
|
3345
3443
|
tableKey: "addressesPanel.table",
|
|
@@ -3348,13 +3446,13 @@ function AddressesPanel(props) {
|
|
|
3348
3446
|
rows,
|
|
3349
3447
|
columns: [
|
|
3350
3448
|
{ key: "label", label: t.addresses.label, render: (address) => address.label || address.addressLine1 },
|
|
3351
|
-
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ (0,
|
|
3449
|
+
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
3352
3450
|
address.addressLine1,
|
|
3353
3451
|
formatAddress(address) ? `, ${formatAddress(address)}` : ""
|
|
3354
3452
|
] }) },
|
|
3355
|
-
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ (0,
|
|
3356
|
-
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ (0,
|
|
3357
|
-
!address.isDefault ? /* @__PURE__ */ (0,
|
|
3453
|
+
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null },
|
|
3454
|
+
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
|
|
3455
|
+
!address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3358
3456
|
Button,
|
|
3359
3457
|
{
|
|
3360
3458
|
variant: "secondary",
|
|
@@ -3363,7 +3461,7 @@ function AddressesPanel(props) {
|
|
|
3363
3461
|
children: t.addresses.makeDefault
|
|
3364
3462
|
}
|
|
3365
3463
|
) : null,
|
|
3366
|
-
/* @__PURE__ */ (0,
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3367
3465
|
Button,
|
|
3368
3466
|
{
|
|
3369
3467
|
variant: "secondary",
|
|
@@ -3372,7 +3470,7 @@ function AddressesPanel(props) {
|
|
|
3372
3470
|
children: t.common.edit
|
|
3373
3471
|
}
|
|
3374
3472
|
),
|
|
3375
|
-
/* @__PURE__ */ (0,
|
|
3473
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3376
3474
|
Button,
|
|
3377
3475
|
{
|
|
3378
3476
|
variant: "danger",
|
|
@@ -3388,17 +3486,17 @@ function AddressesPanel(props) {
|
|
|
3388
3486
|
] }) }
|
|
3389
3487
|
]
|
|
3390
3488
|
}
|
|
3391
|
-
) : /* @__PURE__ */ (0,
|
|
3392
|
-
/* @__PURE__ */ (0,
|
|
3393
|
-
/* @__PURE__ */ (0,
|
|
3394
|
-
/* @__PURE__ */ (0,
|
|
3395
|
-
address.isDefault ? /* @__PURE__ */ (0,
|
|
3489
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...a.el("addressesPanel.list", listBase), children: rows.map((address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...a.el("addressesPanel.item", itemBase), children: [
|
|
3490
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { children: [
|
|
3491
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-row", children: [
|
|
3492
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("strong", { children: address.label || address.addressLine1 }),
|
|
3493
|
+
address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null
|
|
3396
3494
|
] }),
|
|
3397
|
-
/* @__PURE__ */ (0,
|
|
3398
|
-
/* @__PURE__ */ (0,
|
|
3495
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "throttle-muted", children: address.addressLine1 }),
|
|
3496
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "throttle-muted", children: formatAddress(address) })
|
|
3399
3497
|
] }),
|
|
3400
|
-
/* @__PURE__ */ (0,
|
|
3401
|
-
!address.isDefault ? /* @__PURE__ */ (0,
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
|
|
3499
|
+
!address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3402
3500
|
Button,
|
|
3403
3501
|
{
|
|
3404
3502
|
variant: actionVariant("secondary"),
|
|
@@ -3407,7 +3505,7 @@ function AddressesPanel(props) {
|
|
|
3407
3505
|
children: t.addresses.makeDefault
|
|
3408
3506
|
}
|
|
3409
3507
|
) : null,
|
|
3410
|
-
/* @__PURE__ */ (0,
|
|
3508
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3411
3509
|
Button,
|
|
3412
3510
|
{
|
|
3413
3511
|
variant: actionVariant("secondary"),
|
|
@@ -3416,7 +3514,7 @@ function AddressesPanel(props) {
|
|
|
3416
3514
|
children: t.common.edit
|
|
3417
3515
|
}
|
|
3418
3516
|
),
|
|
3419
|
-
/* @__PURE__ */ (0,
|
|
3517
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3420
3518
|
Button,
|
|
3421
3519
|
{
|
|
3422
3520
|
variant: actionVariant("danger"),
|
|
@@ -3438,23 +3536,23 @@ function AddressesPanel(props) {
|
|
|
3438
3536
|
}
|
|
3439
3537
|
|
|
3440
3538
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
3441
|
-
var
|
|
3539
|
+
var import_react25 = require("react");
|
|
3442
3540
|
|
|
3443
3541
|
// src/react/components/account/AddCardDialog.tsx
|
|
3444
|
-
var
|
|
3445
|
-
var
|
|
3542
|
+
var import_react24 = require("react");
|
|
3543
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3446
3544
|
function AddCardDialog(props) {
|
|
3447
3545
|
const { account } = useAuth();
|
|
3448
|
-
const titleId = (0,
|
|
3546
|
+
const titleId = (0, import_react24.useId)();
|
|
3449
3547
|
const { t } = useCopy(props.localization);
|
|
3450
|
-
const [src, setSrc] = (0,
|
|
3451
|
-
const [error, setError] = (0,
|
|
3452
|
-
const [busy, setBusy] = (0,
|
|
3453
|
-
const onAdded = (0,
|
|
3454
|
-
const onClose = (0,
|
|
3548
|
+
const [src, setSrc] = (0, import_react24.useState)(null);
|
|
3549
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
3550
|
+
const [busy, setBusy] = (0, import_react24.useState)(false);
|
|
3551
|
+
const onAdded = (0, import_react24.useRef)(props.onAdded);
|
|
3552
|
+
const onClose = (0, import_react24.useRef)(props.onClose);
|
|
3455
3553
|
onAdded.current = props.onAdded;
|
|
3456
3554
|
onClose.current = props.onClose;
|
|
3457
|
-
(0,
|
|
3555
|
+
(0, import_react24.useEffect)(() => {
|
|
3458
3556
|
if (!props.open) {
|
|
3459
3557
|
setSrc(null);
|
|
3460
3558
|
setError(null);
|
|
@@ -3482,7 +3580,7 @@ function AddCardDialog(props) {
|
|
|
3482
3580
|
live = false;
|
|
3483
3581
|
};
|
|
3484
3582
|
}, [props.open, account]);
|
|
3485
|
-
(0,
|
|
3583
|
+
(0, import_react24.useEffect)(() => {
|
|
3486
3584
|
if (!src) return;
|
|
3487
3585
|
const frameOrigin = (() => {
|
|
3488
3586
|
try {
|
|
@@ -3517,11 +3615,11 @@ function AddCardDialog(props) {
|
|
|
3517
3615
|
return () => window.removeEventListener("message", onMessage);
|
|
3518
3616
|
}, [src, account, t]);
|
|
3519
3617
|
if (!props.open) return null;
|
|
3520
|
-
return /* @__PURE__ */ (0,
|
|
3521
|
-
/* @__PURE__ */ (0,
|
|
3522
|
-
/* @__PURE__ */ (0,
|
|
3523
|
-
error ? /* @__PURE__ */ (0,
|
|
3524
|
-
busy ? /* @__PURE__ */ (0,
|
|
3618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
|
|
3619
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-modal__header", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h2", { id: titleId, className: "throttle-modal__title", children: t.paymentMethods.addTitle }) }),
|
|
3620
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-modal__body", children: [
|
|
3621
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3622
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spinner, {}) }) : src ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3525
3623
|
"iframe",
|
|
3526
3624
|
{
|
|
3527
3625
|
className: "throttle-cardframe",
|
|
@@ -3529,13 +3627,13 @@ function AddCardDialog(props) {
|
|
|
3529
3627
|
title: t.paymentMethods.addTitle,
|
|
3530
3628
|
sandbox: "allow-scripts allow-forms allow-same-origin"
|
|
3531
3629
|
}
|
|
3532
|
-
) : !error ? /* @__PURE__ */ (0,
|
|
3630
|
+
) : !error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spinner, {}) }) : null
|
|
3533
3631
|
] })
|
|
3534
3632
|
] });
|
|
3535
3633
|
}
|
|
3536
3634
|
|
|
3537
3635
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
3538
|
-
var
|
|
3636
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3539
3637
|
function PaymentMethodsPanel(props) {
|
|
3540
3638
|
const a = useAppearance(props.appearance);
|
|
3541
3639
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3544,7 +3642,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3544
3642
|
const resource = useSavedCards();
|
|
3545
3643
|
const { submitting, error, run } = useAction();
|
|
3546
3644
|
const confirm = useConfirm();
|
|
3547
|
-
const [adding, setAdding] = (0,
|
|
3645
|
+
const [adding, setAdding] = (0, import_react25.useState)(false);
|
|
3548
3646
|
const variant = props.variant ?? "rows";
|
|
3549
3647
|
const rowsVariant = variant === "rows";
|
|
3550
3648
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -3552,10 +3650,10 @@ function PaymentMethodsPanel(props) {
|
|
|
3552
3650
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3553
3651
|
const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
|
|
3554
3652
|
const expiryLabel = (card) => card.cardExpMonth && card.cardExpYear ? `${String(card.cardExpMonth).padStart(2, "0")}/${card.cardExpYear}` : "";
|
|
3555
|
-
return /* @__PURE__ */ (0,
|
|
3556
|
-
error ? /* @__PURE__ */ (0,
|
|
3557
|
-
emailVerified ? /* @__PURE__ */ (0,
|
|
3558
|
-
/* @__PURE__ */ (0,
|
|
3653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
|
|
3654
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3655
|
+
emailVerified ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
|
|
3656
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3559
3657
|
AddCardDialog,
|
|
3560
3658
|
{
|
|
3561
3659
|
open: adding,
|
|
@@ -3566,7 +3664,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3566
3664
|
localization: props.localization
|
|
3567
3665
|
}
|
|
3568
3666
|
),
|
|
3569
|
-
/* @__PURE__ */ (0,
|
|
3667
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3570
3668
|
PanelState,
|
|
3571
3669
|
{
|
|
3572
3670
|
resource,
|
|
@@ -3575,7 +3673,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3575
3673
|
isEmpty: (rows) => rows.length === 0,
|
|
3576
3674
|
emptyTitle: t.paymentMethods.empty,
|
|
3577
3675
|
emptyDescription: t.paymentMethods.emptyDescription,
|
|
3578
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3676
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3579
3677
|
DataTable,
|
|
3580
3678
|
{
|
|
3581
3679
|
tableKey: "paymentMethodsPanel.table",
|
|
@@ -3585,9 +3683,9 @@ function PaymentMethodsPanel(props) {
|
|
|
3585
3683
|
columns: [
|
|
3586
3684
|
{ key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
|
|
3587
3685
|
{ key: "expires", label: t.paymentMethods.expires, render: (card) => expiryLabel(card) },
|
|
3588
|
-
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0,
|
|
3589
|
-
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0,
|
|
3590
|
-
!card.isDefault ? /* @__PURE__ */ (0,
|
|
3686
|
+
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
|
|
3687
|
+
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-actions", children: [
|
|
3688
|
+
!card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3591
3689
|
Button,
|
|
3592
3690
|
{
|
|
3593
3691
|
variant: "secondary",
|
|
@@ -3597,7 +3695,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3597
3695
|
children: t.paymentMethods.makeDefault
|
|
3598
3696
|
}
|
|
3599
3697
|
) : null,
|
|
3600
|
-
/* @__PURE__ */ (0,
|
|
3698
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3601
3699
|
Button,
|
|
3602
3700
|
{
|
|
3603
3701
|
variant: "danger",
|
|
@@ -3613,13 +3711,13 @@ function PaymentMethodsPanel(props) {
|
|
|
3613
3711
|
] }) }
|
|
3614
3712
|
]
|
|
3615
3713
|
}
|
|
3616
|
-
) : /* @__PURE__ */ (0,
|
|
3617
|
-
/* @__PURE__ */ (0,
|
|
3618
|
-
/* @__PURE__ */ (0,
|
|
3619
|
-
/* @__PURE__ */ (0,
|
|
3620
|
-
card.isDefault ? /* @__PURE__ */ (0,
|
|
3714
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
|
|
3715
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { children: [
|
|
3716
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-row", children: [
|
|
3717
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("strong", { children: cardLabel(card) }),
|
|
3718
|
+
card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
|
|
3621
3719
|
] }),
|
|
3622
|
-
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0,
|
|
3720
|
+
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "throttle-muted", children: [
|
|
3623
3721
|
t.paymentMethods.expires,
|
|
3624
3722
|
" ",
|
|
3625
3723
|
String(card.cardExpMonth).padStart(2, "0"),
|
|
@@ -3627,8 +3725,8 @@ function PaymentMethodsPanel(props) {
|
|
|
3627
3725
|
card.cardExpYear
|
|
3628
3726
|
] }) : null
|
|
3629
3727
|
] }),
|
|
3630
|
-
/* @__PURE__ */ (0,
|
|
3631
|
-
!card.isDefault ? /* @__PURE__ */ (0,
|
|
3728
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-actions", children: [
|
|
3729
|
+
!card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3632
3730
|
Button,
|
|
3633
3731
|
{
|
|
3634
3732
|
variant: actionVariant("secondary"),
|
|
@@ -3638,7 +3736,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3638
3736
|
children: t.paymentMethods.makeDefault
|
|
3639
3737
|
}
|
|
3640
3738
|
) : null,
|
|
3641
|
-
/* @__PURE__ */ (0,
|
|
3739
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3642
3740
|
Button,
|
|
3643
3741
|
{
|
|
3644
3742
|
variant: actionVariant("danger"),
|
|
@@ -3659,7 +3757,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3659
3757
|
}
|
|
3660
3758
|
|
|
3661
3759
|
// src/react/components/account/OrdersPanel.tsx
|
|
3662
|
-
var
|
|
3760
|
+
var import_react26 = require("react");
|
|
3663
3761
|
|
|
3664
3762
|
// src/react/components/format.ts
|
|
3665
3763
|
function formatMoney(minorUnits, currency, locale) {
|
|
@@ -3691,7 +3789,7 @@ function formatDate(value, locale) {
|
|
|
3691
3789
|
}
|
|
3692
3790
|
|
|
3693
3791
|
// src/react/components/account/OrderStatus.tsx
|
|
3694
|
-
var
|
|
3792
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3695
3793
|
function copyKey(wire) {
|
|
3696
3794
|
return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
3697
3795
|
}
|
|
@@ -3699,21 +3797,21 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
|
|
|
3699
3797
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
|
|
3700
3798
|
function StatusBadge(props) {
|
|
3701
3799
|
const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
3702
|
-
return /* @__PURE__ */ (0,
|
|
3800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
|
|
3703
3801
|
}
|
|
3704
3802
|
function OrderStatus(props) {
|
|
3705
3803
|
const labels = props.t.orders.statusLabels;
|
|
3706
3804
|
const payLabels = props.t.orders.paymentLabels;
|
|
3707
3805
|
const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
3708
3806
|
const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
|
|
3709
|
-
return /* @__PURE__ */ (0,
|
|
3710
|
-
/* @__PURE__ */ (0,
|
|
3711
|
-
money ? /* @__PURE__ */ (0,
|
|
3807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3808
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
|
|
3809
|
+
money ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
|
|
3712
3810
|
] });
|
|
3713
3811
|
}
|
|
3714
3812
|
|
|
3715
3813
|
// src/react/components/account/AddressBlock.tsx
|
|
3716
|
-
var
|
|
3814
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3717
3815
|
function addressLines(address) {
|
|
3718
3816
|
if (!address || typeof address !== "object") return [];
|
|
3719
3817
|
const a = address;
|
|
@@ -3733,14 +3831,14 @@ function AddressBlock(props) {
|
|
|
3733
3831
|
const a = useAppearance();
|
|
3734
3832
|
const lines = addressLines(props.address);
|
|
3735
3833
|
if (lines.length === 0) return null;
|
|
3736
|
-
return /* @__PURE__ */ (0,
|
|
3737
|
-
/* @__PURE__ */ (0,
|
|
3738
|
-
lines.map((l) => /* @__PURE__ */ (0,
|
|
3834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { ...a.el(props.elementKey ?? "orderDetail.address", "throttle-addressblock"), children: [
|
|
3835
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
|
|
3836
|
+
lines.map((l) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "throttle-addressblock__line throttle-muted", children: l }, l))
|
|
3739
3837
|
] });
|
|
3740
3838
|
}
|
|
3741
3839
|
|
|
3742
3840
|
// src/react/components/account/OrderTimeline.tsx
|
|
3743
|
-
var
|
|
3841
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3744
3842
|
function orderTimeline(order, labels) {
|
|
3745
3843
|
const entries = [{ label: labels.placed, at: order.createdAt }];
|
|
3746
3844
|
if (order.completedAt) entries.push({ label: labels.completed, at: order.completedAt });
|
|
@@ -3751,32 +3849,40 @@ function orderTimeline(order, labels) {
|
|
|
3751
3849
|
function OrderTimeline(props) {
|
|
3752
3850
|
const a = useAppearance();
|
|
3753
3851
|
if (props.entries.length <= 1) return null;
|
|
3754
|
-
return /* @__PURE__ */ (0,
|
|
3755
|
-
/* @__PURE__ */ (0,
|
|
3756
|
-
props.entries.map((e) => /* @__PURE__ */ (0,
|
|
3757
|
-
/* @__PURE__ */ (0,
|
|
3758
|
-
/* @__PURE__ */ (0,
|
|
3759
|
-
/* @__PURE__ */ (0,
|
|
3852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ...a.el("orderDetail.timeline", "throttle-timeline"), children: [
|
|
3853
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
|
|
3854
|
+
props.entries.map((e) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "throttle-timeline__row", children: [
|
|
3855
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-timeline__dot", "aria-hidden": "true" }),
|
|
3856
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-timeline__label", children: e.label }),
|
|
3857
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-muted", children: formatDate(e.at, props.locale) })
|
|
3760
3858
|
] }, `${e.label}-${e.at}`))
|
|
3761
3859
|
] });
|
|
3762
3860
|
}
|
|
3763
3861
|
|
|
3764
3862
|
// src/react/components/account/OrderDetail.tsx
|
|
3765
|
-
var
|
|
3863
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3766
3864
|
var CAN_PAY = /* @__PURE__ */ new Set(["draft", "pending"]);
|
|
3767
3865
|
var CAN_REORDER = /* @__PURE__ */ new Set(["fulfilled", "cancelled", "closed"]);
|
|
3866
|
+
var CAN_CANCEL = /* @__PURE__ */ new Set(["draft", "pending", "processing"]);
|
|
3867
|
+
var SETTLED_PAYMENT = /* @__PURE__ */ new Set(["captured", "paid", "partially_refunded", "refunded"]);
|
|
3868
|
+
var CAN_RETURN = /* @__PURE__ */ new Set(["fulfilled", "partially_fulfilled", "closed"]);
|
|
3768
3869
|
function Line(props) {
|
|
3769
|
-
return /* @__PURE__ */ (0,
|
|
3770
|
-
/* @__PURE__ */ (0,
|
|
3771
|
-
/* @__PURE__ */ (0,
|
|
3870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
|
|
3871
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-muted", children: props.label }),
|
|
3872
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: props.strong ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: props.value }) : props.value })
|
|
3772
3873
|
] });
|
|
3773
3874
|
}
|
|
3774
3875
|
function OrderDetail(props) {
|
|
3775
3876
|
const a = useAppearance(props.appearance);
|
|
3776
3877
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3777
3878
|
const { t, locale } = useCopy(props.localization);
|
|
3879
|
+
const { account } = useAuth();
|
|
3778
3880
|
const resource = useOrder(props.orderId);
|
|
3779
|
-
|
|
3881
|
+
const { submitting, error, run } = useAction();
|
|
3882
|
+
const confirm = useConfirm();
|
|
3883
|
+
const allowCancel = props.allowCancel ?? true;
|
|
3884
|
+
const allowReturn = props.allowReturn ?? true;
|
|
3885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
|
|
3780
3886
|
props.onBack ? (
|
|
3781
3887
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
3782
3888
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -3784,136 +3890,216 @@ function OrderDetail(props) {
|
|
|
3784
3890
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
3785
3891
|
// its own width. A CSS fix would need a compound selector, and
|
|
3786
3892
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
3787
|
-
/* @__PURE__ */ (0,
|
|
3893
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
3788
3894
|
) : null,
|
|
3789
|
-
/* @__PURE__ */ (0,
|
|
3895
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3896
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3790
3897
|
PanelState,
|
|
3791
3898
|
{
|
|
3792
3899
|
resource,
|
|
3793
3900
|
isEmpty: (o) => o === null,
|
|
3794
3901
|
emptyTitle: t.orders.empty,
|
|
3795
3902
|
skeletonRows: 5,
|
|
3796
|
-
children: (order) =>
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
)
|
|
3841
|
-
] }),
|
|
3842
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3843
|
-
OrderTimeline,
|
|
3844
|
-
{
|
|
3845
|
-
heading: t.orders.history,
|
|
3846
|
-
locale,
|
|
3847
|
-
entries: orderTimeline(order, {
|
|
3848
|
-
placed: t.orders.placed,
|
|
3849
|
-
completed: t.orders.completed,
|
|
3850
|
-
cancelled: t.orders.cancelledAt,
|
|
3851
|
-
closed: t.orders.closedAt
|
|
3852
|
-
})
|
|
3853
|
-
}
|
|
3854
|
-
),
|
|
3855
|
-
(() => {
|
|
3856
|
-
const target = {
|
|
3857
|
-
id: order.id,
|
|
3858
|
-
orderNumber: order.orderNumber,
|
|
3859
|
-
currency: order.currency,
|
|
3860
|
-
lineItems: order.lineItems.map((li) => ({
|
|
3861
|
-
name: li.name,
|
|
3862
|
-
unitPrice: li.unitPrice,
|
|
3863
|
-
quantity: li.quantity
|
|
3864
|
-
}))
|
|
3865
|
-
};
|
|
3866
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-actions", children: [
|
|
3867
|
-
props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3868
|
-
Button,
|
|
3869
|
-
{
|
|
3870
|
-
elementKey: "orderDetail.payButton",
|
|
3871
|
-
onClick: () => props.onPayNow(target),
|
|
3872
|
-
children: t.orders.payNow
|
|
3873
|
-
}
|
|
3874
|
-
) : null,
|
|
3875
|
-
props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3876
|
-
Button,
|
|
3877
|
-
{
|
|
3878
|
-
variant: "secondary",
|
|
3879
|
-
elementKey: "orderDetail.trackButton",
|
|
3880
|
-
onClick: () => props.onTrackShipment(target),
|
|
3881
|
-
children: t.orders.track
|
|
3882
|
-
}
|
|
3883
|
-
) : null,
|
|
3884
|
-
props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3885
|
-
Button,
|
|
3903
|
+
children: (order) => {
|
|
3904
|
+
const target = {
|
|
3905
|
+
id: order.id,
|
|
3906
|
+
orderNumber: order.orderNumber,
|
|
3907
|
+
currency: order.currency,
|
|
3908
|
+
lineItems: order.lineItems.map((li) => ({
|
|
3909
|
+
name: li.name,
|
|
3910
|
+
unitPrice: li.unitPrice,
|
|
3911
|
+
quantity: li.quantity
|
|
3912
|
+
}))
|
|
3913
|
+
};
|
|
3914
|
+
const money = (v) => formatMoney(v, order.currency, locale);
|
|
3915
|
+
const paid = SETTLED_PAYMENT.has(order.paymentStatus);
|
|
3916
|
+
const showCancel = allowCancel && CAN_CANCEL.has(order.status) && !paid;
|
|
3917
|
+
const showReturn = allowReturn && CAN_RETURN.has(order.status);
|
|
3918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.layout", "throttle-detail"), children: [
|
|
3919
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.main", "throttle-detail__main"), children: [
|
|
3920
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
|
|
3921
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
|
|
3922
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { children: order.orderNumber }),
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
|
|
3924
|
+
] }),
|
|
3925
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) })
|
|
3926
|
+
] }),
|
|
3927
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
|
|
3928
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.items }),
|
|
3929
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
|
|
3930
|
+
item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
|
|
3931
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { style: { flex: 1 }, children: [
|
|
3932
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: item.name }),
|
|
3933
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-lineitem__desc", children: item.description }) : null,
|
|
3934
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "throttle-lineitem__meta", children: [
|
|
3935
|
+
t.orders.quantity,
|
|
3936
|
+
" ",
|
|
3937
|
+
item.quantity,
|
|
3938
|
+
" \xD7 ",
|
|
3939
|
+
money(item.unitPrice)
|
|
3940
|
+
] })
|
|
3941
|
+
] }),
|
|
3942
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: money(item.total) })
|
|
3943
|
+
] }, item.id)) })
|
|
3944
|
+
] }),
|
|
3945
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3946
|
+
OrderTimeline,
|
|
3886
3947
|
{
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3948
|
+
heading: t.orders.history,
|
|
3949
|
+
locale,
|
|
3950
|
+
entries: orderTimeline(order, {
|
|
3951
|
+
placed: t.orders.placed,
|
|
3952
|
+
completed: t.orders.completed,
|
|
3953
|
+
cancelled: t.orders.cancelledAt,
|
|
3954
|
+
closed: t.orders.closedAt
|
|
3955
|
+
})
|
|
3891
3956
|
}
|
|
3892
|
-
)
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3957
|
+
),
|
|
3958
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
|
|
3959
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3960
|
+
AddressBlock,
|
|
3961
|
+
{
|
|
3962
|
+
heading: t.orders.shipTo,
|
|
3963
|
+
address: order.shippingAddress,
|
|
3964
|
+
elementKey: "orderDetail.shippingAddress"
|
|
3965
|
+
}
|
|
3966
|
+
),
|
|
3967
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3968
|
+
AddressBlock,
|
|
3969
|
+
{
|
|
3970
|
+
heading: t.orders.billTo,
|
|
3971
|
+
address: order.billingAddress,
|
|
3972
|
+
elementKey: "orderDetail.billingAddress"
|
|
3973
|
+
}
|
|
3974
|
+
)
|
|
3975
|
+
] })
|
|
3976
|
+
] }),
|
|
3977
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("aside", { ...a.el("orderDetail.rail", "throttle-detail__rail"), children: [
|
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
|
|
3979
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.total }),
|
|
3980
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__headline", children: money(order.total) })
|
|
3981
|
+
] }),
|
|
3982
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
|
|
3983
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: money(order.subtotal) }),
|
|
3984
|
+
order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: money(-order.discountTotal) }) : null,
|
|
3985
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: money(order.shippingTotal) }),
|
|
3986
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: money(order.taxTotal) })
|
|
3987
|
+
] }),
|
|
3988
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.actions", "throttle-detail__actions"), children: [
|
|
3989
|
+
props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { elementKey: "orderDetail.payButton", onClick: () => props.onPayNow(target), children: t.orders.payNow }) : null,
|
|
3990
|
+
order.invoiceId ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3991
|
+
Button,
|
|
3992
|
+
{
|
|
3993
|
+
variant: "secondary",
|
|
3994
|
+
loading: submitting,
|
|
3995
|
+
elementKey: "orderDetail.invoiceButton",
|
|
3996
|
+
onClick: () => void run(async () => {
|
|
3997
|
+
const { url } = await account.getInvoicePdfUrl(order.invoiceId);
|
|
3998
|
+
const opened = window.open(url, "_blank", "noopener,noreferrer");
|
|
3999
|
+
if (!opened) window.location.assign(url);
|
|
4000
|
+
}),
|
|
4001
|
+
children: t.orders.downloadInvoice
|
|
4002
|
+
}
|
|
4003
|
+
) : null,
|
|
4004
|
+
props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4005
|
+
Button,
|
|
4006
|
+
{
|
|
4007
|
+
variant: "secondary",
|
|
4008
|
+
elementKey: "orderDetail.trackButton",
|
|
4009
|
+
onClick: () => props.onTrackShipment(target),
|
|
4010
|
+
children: t.orders.track
|
|
4011
|
+
}
|
|
4012
|
+
) : null,
|
|
4013
|
+
props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4014
|
+
Button,
|
|
4015
|
+
{
|
|
4016
|
+
variant: "secondary",
|
|
4017
|
+
elementKey: "orderDetail.reorderButton",
|
|
4018
|
+
onClick: () => props.onReorder(target),
|
|
4019
|
+
children: t.orders.reorder
|
|
4020
|
+
}
|
|
4021
|
+
) : null,
|
|
4022
|
+
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4023
|
+
Button,
|
|
4024
|
+
{
|
|
4025
|
+
variant: "secondary",
|
|
4026
|
+
onClick: () => props.onViewSubscription(order.subscriptionId),
|
|
4027
|
+
children: t.orders.viewSubscription
|
|
4028
|
+
}
|
|
4029
|
+
) : null,
|
|
4030
|
+
showReturn ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4031
|
+
Button,
|
|
4032
|
+
{
|
|
4033
|
+
variant: "secondary",
|
|
4034
|
+
disabled: submitting,
|
|
4035
|
+
elementKey: "orderDetail.returnButton",
|
|
4036
|
+
onClick: () => void (async () => {
|
|
4037
|
+
if (!await confirm({
|
|
4038
|
+
title: t.orders.requestReturnConfirm,
|
|
4039
|
+
body: t.orders.requestReturnBody,
|
|
4040
|
+
confirmLabel: t.orders.requestReturnAction
|
|
4041
|
+
})) return;
|
|
4042
|
+
await run(async () => {
|
|
4043
|
+
await account.requestOrderReturn(order.id, {
|
|
4044
|
+
items: order.lineItems.map((li) => ({
|
|
4045
|
+
lineItemId: li.id,
|
|
4046
|
+
quantity: li.quantity
|
|
4047
|
+
}))
|
|
4048
|
+
});
|
|
4049
|
+
await resource.refetch();
|
|
4050
|
+
});
|
|
4051
|
+
})(),
|
|
4052
|
+
children: t.orders.requestReturn
|
|
4053
|
+
}
|
|
4054
|
+
) : null,
|
|
4055
|
+
showCancel ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4056
|
+
Button,
|
|
4057
|
+
{
|
|
4058
|
+
variant: "danger",
|
|
4059
|
+
disabled: submitting,
|
|
4060
|
+
elementKey: "orderDetail.cancelButton",
|
|
4061
|
+
onClick: () => void (async () => {
|
|
4062
|
+
if (!await confirm({
|
|
4063
|
+
title: t.orders.cancelOrderConfirm,
|
|
4064
|
+
body: t.orders.cancelOrderBody,
|
|
4065
|
+
confirmLabel: t.orders.cancelOrderAction,
|
|
4066
|
+
tone: "danger"
|
|
4067
|
+
})) return;
|
|
4068
|
+
await run(async () => {
|
|
4069
|
+
await account.cancelOrder(order.id);
|
|
4070
|
+
await resource.refetch();
|
|
4071
|
+
});
|
|
4072
|
+
})(),
|
|
4073
|
+
children: t.orders.cancelOrder
|
|
4074
|
+
}
|
|
4075
|
+
) : null
|
|
4076
|
+
] })
|
|
4077
|
+
] })
|
|
4078
|
+
] });
|
|
4079
|
+
}
|
|
3897
4080
|
}
|
|
3898
4081
|
)
|
|
3899
4082
|
] }) }) });
|
|
3900
4083
|
}
|
|
3901
4084
|
|
|
3902
4085
|
// src/react/components/account/OrdersPanel.tsx
|
|
3903
|
-
var
|
|
4086
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3904
4087
|
function OrdersPanel(props) {
|
|
3905
4088
|
const a = useAppearance(props.appearance);
|
|
3906
4089
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3907
4090
|
const { t, locale } = useCopy(props.localization);
|
|
3908
4091
|
const { emailVerified } = useAuth();
|
|
3909
4092
|
const resource = useOrders();
|
|
3910
|
-
const [openId, setOpenId] = (0,
|
|
4093
|
+
const [openId, setOpenId] = (0, import_react26.useState)(props.initialOpenId ?? null);
|
|
4094
|
+
(0, import_react26.useEffect)(() => {
|
|
4095
|
+
if (props.initialOpenId) setOpenId(props.initialOpenId);
|
|
4096
|
+
}, [props.initialOpenId]);
|
|
3911
4097
|
const variant = props.variant ?? "table";
|
|
3912
4098
|
const rowsVariant = variant === "rows";
|
|
3913
4099
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3914
4100
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3915
4101
|
if (openId) {
|
|
3916
|
-
return /* @__PURE__ */ (0,
|
|
4102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3917
4103
|
OrderDetail,
|
|
3918
4104
|
{
|
|
3919
4105
|
orderId: openId,
|
|
@@ -3922,12 +4108,14 @@ function OrdersPanel(props) {
|
|
|
3922
4108
|
onReorder: props.onReorder,
|
|
3923
4109
|
onTrackShipment: props.onTrackShipment,
|
|
3924
4110
|
onViewSubscription: props.onViewSubscription,
|
|
4111
|
+
allowCancel: props.allowCancel,
|
|
4112
|
+
allowReturn: props.allowReturn,
|
|
3925
4113
|
appearance: props.appearance,
|
|
3926
4114
|
localization: props.localization
|
|
3927
4115
|
}
|
|
3928
4116
|
);
|
|
3929
4117
|
}
|
|
3930
|
-
return /* @__PURE__ */ (0,
|
|
4118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3931
4119
|
PanelState,
|
|
3932
4120
|
{
|
|
3933
4121
|
resource,
|
|
@@ -3936,7 +4124,7 @@ function OrdersPanel(props) {
|
|
|
3936
4124
|
isEmpty: (rows) => rows.length === 0,
|
|
3937
4125
|
emptyTitle: t.orders.empty,
|
|
3938
4126
|
emptyDescription: t.orders.emptyDescription,
|
|
3939
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
4127
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3940
4128
|
DataTable,
|
|
3941
4129
|
{
|
|
3942
4130
|
tableKey: "ordersPanel.table",
|
|
@@ -3950,25 +4138,25 @@ function OrdersPanel(props) {
|
|
|
3950
4138
|
{
|
|
3951
4139
|
key: "status",
|
|
3952
4140
|
label: t.orders.status,
|
|
3953
|
-
render: (o) => /* @__PURE__ */ (0,
|
|
4141
|
+
render: (o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3954
4142
|
},
|
|
3955
4143
|
{
|
|
3956
4144
|
key: "total",
|
|
3957
4145
|
label: t.orders.total,
|
|
3958
|
-
render: (o) => /* @__PURE__ */ (0,
|
|
4146
|
+
render: (o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
|
|
3959
4147
|
}
|
|
3960
4148
|
]
|
|
3961
4149
|
}
|
|
3962
|
-
) : /* @__PURE__ */ (0,
|
|
3963
|
-
/* @__PURE__ */ (0,
|
|
3964
|
-
/* @__PURE__ */ (0,
|
|
3965
|
-
/* @__PURE__ */ (0,
|
|
3966
|
-
/* @__PURE__ */ (0,
|
|
4150
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("ordersPanel.item", itemBase), children: [
|
|
4151
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { children: [
|
|
4152
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
|
|
4153
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("strong", { children: o.orderNumber }),
|
|
4154
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3967
4155
|
] }),
|
|
3968
|
-
/* @__PURE__ */ (0,
|
|
3969
|
-
/* @__PURE__ */ (0,
|
|
4156
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
|
|
4157
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
|
|
3970
4158
|
] }),
|
|
3971
|
-
/* @__PURE__ */ (0,
|
|
4159
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3972
4160
|
Button,
|
|
3973
4161
|
{
|
|
3974
4162
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3983,14 +4171,15 @@ function OrdersPanel(props) {
|
|
|
3983
4171
|
}
|
|
3984
4172
|
|
|
3985
4173
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3986
|
-
var
|
|
4174
|
+
var import_react27 = require("react");
|
|
3987
4175
|
|
|
3988
4176
|
// src/react/components/account/InvoiceDetail.tsx
|
|
3989
|
-
var
|
|
4177
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4178
|
+
var PAYABLE = /* @__PURE__ */ new Set(["open"]);
|
|
3990
4179
|
function Line2(props) {
|
|
3991
|
-
return /* @__PURE__ */ (0,
|
|
3992
|
-
/* @__PURE__ */ (0,
|
|
3993
|
-
/* @__PURE__ */ (0,
|
|
4180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
|
|
4181
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-muted", children: props.label }),
|
|
4182
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: props.value })
|
|
3994
4183
|
] });
|
|
3995
4184
|
}
|
|
3996
4185
|
function InvoiceDetail(props) {
|
|
@@ -4000,84 +4189,147 @@ function InvoiceDetail(props) {
|
|
|
4000
4189
|
const { account } = useAuth();
|
|
4001
4190
|
const resource = useInvoice(props.invoiceId);
|
|
4002
4191
|
const { submitting, error, run } = useAction();
|
|
4003
|
-
return /* @__PURE__ */ (0,
|
|
4192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
|
|
4004
4193
|
props.onBack ? (
|
|
4005
|
-
// Wrapped on purpose
|
|
4006
|
-
// direct child
|
|
4007
|
-
|
|
4008
|
-
// centred label. The wrapper takes the stretch; the button keeps
|
|
4009
|
-
// its own width. A CSS fix would need a compound selector, and
|
|
4010
|
-
// those outrank the merchant overrides in `appearance.elements`.
|
|
4011
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
4194
|
+
// Wrapped on purpose — see OrderDetail's back button for why a
|
|
4195
|
+
// direct flex child stretched to 748px.
|
|
4196
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
4012
4197
|
) : null,
|
|
4013
|
-
/* @__PURE__ */ (0,
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
children:
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4198
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
4199
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => {
|
|
4200
|
+
const money = (v) => formatMoney(v, invoice.currency, locale);
|
|
4201
|
+
const lines = invoice.lineItems ?? [];
|
|
4202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.layout", "throttle-detail"), children: [
|
|
4203
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.main", "throttle-detail__main"), children: [
|
|
4204
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
|
|
4205
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
|
|
4206
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: invoice.number }),
|
|
4207
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
|
|
4208
|
+
] }),
|
|
4209
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-muted", children: [
|
|
4210
|
+
t.invoices.issued,
|
|
4211
|
+
" ",
|
|
4212
|
+
formatDate(invoice.issuedAt, locale)
|
|
4213
|
+
] })
|
|
4214
|
+
] }),
|
|
4215
|
+
lines.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
|
|
4216
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.items }),
|
|
4217
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.el("invoiceDetail.lineItems", "throttle-stack"), children: lines.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.lineItem", "throttle-lineitem"), children: [
|
|
4218
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { style: { flex: 1 }, children: [
|
|
4219
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: item.name }),
|
|
4220
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "throttle-lineitem__desc", children: item.description }) : null,
|
|
4221
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-lineitem__meta", children: [
|
|
4222
|
+
t.orders.quantity,
|
|
4223
|
+
" ",
|
|
4224
|
+
item.quantity,
|
|
4225
|
+
" \xD7 ",
|
|
4226
|
+
money(item.unitPrice)
|
|
4227
|
+
] })
|
|
4228
|
+
] }),
|
|
4229
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: money(item.total) })
|
|
4230
|
+
] }, i)) })
|
|
4231
|
+
] }) : null
|
|
4232
|
+
] }),
|
|
4233
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("aside", { ...a.el("invoiceDetail.rail", "throttle-detail__rail"), children: [
|
|
4234
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
|
|
4235
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.total }),
|
|
4236
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__headline", children: money(invoice.total) })
|
|
4237
|
+
] }),
|
|
4238
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
|
|
4239
|
+
invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
|
|
4240
|
+
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4241
|
+
Line2,
|
|
4242
|
+
{
|
|
4243
|
+
label: t.invoices.period,
|
|
4244
|
+
value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
|
|
4245
|
+
}
|
|
4246
|
+
) : null,
|
|
4247
|
+
invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.refunded, value: money(invoice.amountRefunded) }) : null
|
|
4248
|
+
] }),
|
|
4249
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.actions", "throttle-detail__actions"), children: [
|
|
4250
|
+
props.onPay && PAYABLE.has(invoice.status) ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4251
|
+
Button,
|
|
4252
|
+
{
|
|
4253
|
+
elementKey: "invoiceDetail.payButton",
|
|
4254
|
+
onClick: () => props.onPay({
|
|
4255
|
+
id: invoice.id,
|
|
4256
|
+
number: invoice.number,
|
|
4257
|
+
total: invoice.total,
|
|
4258
|
+
currency: invoice.currency
|
|
4259
|
+
}),
|
|
4260
|
+
children: t.invoices.payButton
|
|
4261
|
+
}
|
|
4262
|
+
) : null,
|
|
4263
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4264
|
+
Button,
|
|
4265
|
+
{
|
|
4266
|
+
variant: "secondary",
|
|
4267
|
+
loading: submitting,
|
|
4268
|
+
elementKey: "invoiceDetail.downloadButton",
|
|
4269
|
+
onClick: () => void run(async () => {
|
|
4270
|
+
const { url } = await account.getInvoicePdfUrl(invoice.id);
|
|
4271
|
+
const opened = window.open(url, "_blank", "noopener,noreferrer");
|
|
4272
|
+
if (!opened) window.location.assign(url);
|
|
4273
|
+
}),
|
|
4274
|
+
children: t.invoices.downloadButton
|
|
4275
|
+
}
|
|
4276
|
+
),
|
|
4277
|
+
invoice.orderId && props.onViewOrder ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4278
|
+
Button,
|
|
4279
|
+
{
|
|
4280
|
+
variant: "secondary",
|
|
4281
|
+
elementKey: "invoiceDetail.orderLink",
|
|
4282
|
+
onClick: () => props.onViewOrder(invoice.orderId),
|
|
4283
|
+
children: invoice.orderNumber ? `${t.invoices.viewOrder} ${invoice.orderNumber}` : t.invoices.viewOrder
|
|
4284
|
+
}
|
|
4285
|
+
) : null,
|
|
4286
|
+
invoice.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4287
|
+
Button,
|
|
4288
|
+
{
|
|
4289
|
+
variant: "secondary",
|
|
4290
|
+
elementKey: "invoiceDetail.subscriptionLink",
|
|
4291
|
+
onClick: () => props.onViewSubscription(invoice.subscriptionId),
|
|
4292
|
+
children: t.invoices.viewSubscription
|
|
4293
|
+
}
|
|
4294
|
+
) : null
|
|
4295
|
+
] })
|
|
4296
|
+
] })
|
|
4297
|
+
] });
|
|
4298
|
+
} })
|
|
4053
4299
|
] }) }) });
|
|
4054
4300
|
}
|
|
4055
4301
|
|
|
4056
4302
|
// src/react/components/account/InvoicesPanel.tsx
|
|
4057
|
-
var
|
|
4303
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4058
4304
|
function InvoicesPanel(props) {
|
|
4059
4305
|
const a = useAppearance(props.appearance);
|
|
4060
4306
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4061
4307
|
const { t, locale } = useCopy(props.localization);
|
|
4062
4308
|
const { emailVerified } = useAuth();
|
|
4063
4309
|
const resource = useInvoices();
|
|
4064
|
-
const [openId, setOpenId] = (0,
|
|
4310
|
+
const [openId, setOpenId] = (0, import_react27.useState)(props.initialOpenId ?? null);
|
|
4311
|
+
(0, import_react27.useEffect)(() => {
|
|
4312
|
+
if (props.initialOpenId) setOpenId(props.initialOpenId);
|
|
4313
|
+
}, [props.initialOpenId]);
|
|
4065
4314
|
const variant = props.variant ?? "table";
|
|
4066
4315
|
const rowsVariant = variant === "rows";
|
|
4067
4316
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
4068
4317
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
4069
4318
|
if (openId) {
|
|
4070
|
-
return /* @__PURE__ */ (0,
|
|
4319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4071
4320
|
InvoiceDetail,
|
|
4072
4321
|
{
|
|
4073
4322
|
invoiceId: openId,
|
|
4074
4323
|
onBack: () => setOpenId(null),
|
|
4324
|
+
onViewOrder: props.onViewOrder,
|
|
4325
|
+
onViewSubscription: props.onViewSubscription,
|
|
4326
|
+
onPay: props.onPay,
|
|
4075
4327
|
appearance: props.appearance,
|
|
4076
4328
|
localization: props.localization
|
|
4077
4329
|
}
|
|
4078
4330
|
);
|
|
4079
4331
|
}
|
|
4080
|
-
return /* @__PURE__ */ (0,
|
|
4332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4081
4333
|
PanelState,
|
|
4082
4334
|
{
|
|
4083
4335
|
resource,
|
|
@@ -4086,7 +4338,7 @@ function InvoicesPanel(props) {
|
|
|
4086
4338
|
isEmpty: (rows) => rows.length === 0,
|
|
4087
4339
|
emptyTitle: t.invoices.empty,
|
|
4088
4340
|
emptyDescription: t.invoices.emptyDescription,
|
|
4089
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
4341
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4090
4342
|
DataTable,
|
|
4091
4343
|
{
|
|
4092
4344
|
tableKey: "invoicesPanel.table",
|
|
@@ -4097,24 +4349,24 @@ function InvoicesPanel(props) {
|
|
|
4097
4349
|
columns: [
|
|
4098
4350
|
{ key: "number", label: t.invoices.number },
|
|
4099
4351
|
{ key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
|
|
4100
|
-
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0,
|
|
4352
|
+
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
|
|
4101
4353
|
{
|
|
4102
4354
|
key: "total",
|
|
4103
4355
|
label: t.invoices.total,
|
|
4104
|
-
render: (i) => /* @__PURE__ */ (0,
|
|
4356
|
+
render: (i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
|
|
4105
4357
|
}
|
|
4106
4358
|
]
|
|
4107
4359
|
}
|
|
4108
|
-
) : /* @__PURE__ */ (0,
|
|
4109
|
-
/* @__PURE__ */ (0,
|
|
4110
|
-
/* @__PURE__ */ (0,
|
|
4111
|
-
/* @__PURE__ */ (0,
|
|
4112
|
-
/* @__PURE__ */ (0,
|
|
4360
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ...a.el("invoicesPanel.item", itemBase), children: [
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { children: [
|
|
4362
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "throttle-row", children: [
|
|
4363
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: i.number }),
|
|
4364
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
|
|
4113
4365
|
] }),
|
|
4114
|
-
/* @__PURE__ */ (0,
|
|
4115
|
-
/* @__PURE__ */ (0,
|
|
4366
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
|
|
4367
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
|
|
4116
4368
|
] }),
|
|
4117
|
-
/* @__PURE__ */ (0,
|
|
4369
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4118
4370
|
Button,
|
|
4119
4371
|
{
|
|
4120
4372
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -4129,10 +4381,10 @@ function InvoicesPanel(props) {
|
|
|
4129
4381
|
}
|
|
4130
4382
|
|
|
4131
4383
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
4132
|
-
var
|
|
4384
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4133
4385
|
var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
|
|
4134
4386
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
4135
|
-
var
|
|
4387
|
+
var CAN_CANCEL2 = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
4136
4388
|
function SubscriptionsPanel(props) {
|
|
4137
4389
|
const a = useAppearance(props.appearance);
|
|
4138
4390
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -4145,7 +4397,7 @@ function SubscriptionsPanel(props) {
|
|
|
4145
4397
|
const rowsVariant = variant === "rows";
|
|
4146
4398
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
4147
4399
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
4148
|
-
const actionVariant = (base) =>
|
|
4400
|
+
const actionVariant = (base) => base;
|
|
4149
4401
|
const confirmThen = (fn, ask) => () => {
|
|
4150
4402
|
void (async () => {
|
|
4151
4403
|
if (!await confirm({ ...ask, tone: ask.tone ?? "neutral" })) return;
|
|
@@ -4154,8 +4406,8 @@ function SubscriptionsPanel(props) {
|
|
|
4154
4406
|
};
|
|
4155
4407
|
const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
4156
4408
|
const renewsLabel = (sub) => formatDate(sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd, locale);
|
|
4157
|
-
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0,
|
|
4158
|
-
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0,
|
|
4409
|
+
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-actions", children: [
|
|
4410
|
+
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4159
4411
|
Button,
|
|
4160
4412
|
{
|
|
4161
4413
|
variant: variantFor("secondary"),
|
|
@@ -4168,7 +4420,7 @@ function SubscriptionsPanel(props) {
|
|
|
4168
4420
|
children: t.subscriptions.pauseButton
|
|
4169
4421
|
}
|
|
4170
4422
|
) : null,
|
|
4171
|
-
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0,
|
|
4423
|
+
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4172
4424
|
Button,
|
|
4173
4425
|
{
|
|
4174
4426
|
variant: variantFor("secondary"),
|
|
@@ -4181,7 +4433,7 @@ function SubscriptionsPanel(props) {
|
|
|
4181
4433
|
children: t.subscriptions.resumeButton
|
|
4182
4434
|
}
|
|
4183
4435
|
) : null,
|
|
4184
|
-
|
|
4436
|
+
CAN_CANCEL2.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4185
4437
|
Button,
|
|
4186
4438
|
{
|
|
4187
4439
|
variant: variantFor("secondary"),
|
|
@@ -4195,7 +4447,7 @@ function SubscriptionsPanel(props) {
|
|
|
4195
4447
|
children: t.subscriptions.cancelAtPeriodEnd
|
|
4196
4448
|
}
|
|
4197
4449
|
) : null,
|
|
4198
|
-
|
|
4450
|
+
CAN_CANCEL2.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4199
4451
|
Button,
|
|
4200
4452
|
{
|
|
4201
4453
|
variant: variantFor("danger"),
|
|
@@ -4210,9 +4462,9 @@ function SubscriptionsPanel(props) {
|
|
|
4210
4462
|
}
|
|
4211
4463
|
) : null
|
|
4212
4464
|
] });
|
|
4213
|
-
return /* @__PURE__ */ (0,
|
|
4214
|
-
error ? /* @__PURE__ */ (0,
|
|
4215
|
-
/* @__PURE__ */ (0,
|
|
4465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
|
|
4466
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
4467
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4216
4468
|
PanelState,
|
|
4217
4469
|
{
|
|
4218
4470
|
resource,
|
|
@@ -4221,7 +4473,7 @@ function SubscriptionsPanel(props) {
|
|
|
4221
4473
|
isEmpty: (rows) => rows.length === 0,
|
|
4222
4474
|
emptyTitle: t.subscriptions.empty,
|
|
4223
4475
|
emptyDescription: t.subscriptions.emptyDescription,
|
|
4224
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
4476
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4225
4477
|
DataTable,
|
|
4226
4478
|
{
|
|
4227
4479
|
tableKey: "subscriptionsPanel.table",
|
|
@@ -4230,42 +4482,42 @@ function SubscriptionsPanel(props) {
|
|
|
4230
4482
|
rows,
|
|
4231
4483
|
columns: [
|
|
4232
4484
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
|
|
4233
|
-
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0,
|
|
4485
|
+
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
|
|
4234
4486
|
{ key: "renews", label: t.subscriptions.columnRenews, render: (sub) => renewsLabel(sub) },
|
|
4235
|
-
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0,
|
|
4236
|
-
/* @__PURE__ */ (0,
|
|
4237
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
4487
|
+
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
|
|
4488
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
|
|
4489
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
4238
4490
|
] }) },
|
|
4239
4491
|
{ key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
|
|
4240
4492
|
]
|
|
4241
4493
|
}
|
|
4242
|
-
) : /* @__PURE__ */ (0,
|
|
4243
|
-
/* @__PURE__ */ (0,
|
|
4244
|
-
/* @__PURE__ */ (0,
|
|
4245
|
-
/* @__PURE__ */ (0,
|
|
4246
|
-
/* @__PURE__ */ (0,
|
|
4494
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
|
|
4495
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
4496
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
|
|
4497
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("strong", { children: sub.planName ?? sub.planReference }),
|
|
4498
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
|
|
4247
4499
|
] }),
|
|
4248
|
-
/* @__PURE__ */ (0,
|
|
4500
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
4249
4501
|
formatMoney(sub.amount, sub.currency, locale),
|
|
4250
4502
|
" / ",
|
|
4251
4503
|
sub.interval,
|
|
4252
4504
|
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
4253
4505
|
] }),
|
|
4254
|
-
sub.status === "cancelled" ? /* @__PURE__ */ (0,
|
|
4506
|
+
sub.status === "cancelled" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
4255
4507
|
t.subscriptions.cancelledOn,
|
|
4256
4508
|
" ",
|
|
4257
4509
|
formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
|
|
4258
|
-
] }) : /* @__PURE__ */ (0,
|
|
4510
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
4259
4511
|
sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
|
|
4260
4512
|
" ",
|
|
4261
4513
|
formatDate(sub.currentPeriodEnd, locale)
|
|
4262
4514
|
] }),
|
|
4263
|
-
sub.trialEnd ? /* @__PURE__ */ (0,
|
|
4515
|
+
sub.trialEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
4264
4516
|
t.subscriptions.trialEnds,
|
|
4265
4517
|
" ",
|
|
4266
4518
|
formatDate(sub.trialEnd, locale)
|
|
4267
4519
|
] }) : null,
|
|
4268
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
4520
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
4269
4521
|
] }),
|
|
4270
4522
|
lifecycleActions(sub, actionVariant)
|
|
4271
4523
|
] }, sub.id)) })
|
|
@@ -4275,7 +4527,7 @@ function SubscriptionsPanel(props) {
|
|
|
4275
4527
|
}
|
|
4276
4528
|
|
|
4277
4529
|
// src/react/components/account/SecurityPanel.tsx
|
|
4278
|
-
var
|
|
4530
|
+
var import_react28 = require("react");
|
|
4279
4531
|
|
|
4280
4532
|
// src/react/components/account/device.ts
|
|
4281
4533
|
var BROWSERS = [
|
|
@@ -4308,7 +4560,7 @@ function describeDevice(userAgent) {
|
|
|
4308
4560
|
}
|
|
4309
4561
|
|
|
4310
4562
|
// src/react/components/account/SecurityPanel.tsx
|
|
4311
|
-
var
|
|
4563
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
4312
4564
|
function SecurityPanel(props) {
|
|
4313
4565
|
const a = useAppearance(props.appearance);
|
|
4314
4566
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -4318,16 +4570,16 @@ function SecurityPanel(props) {
|
|
|
4318
4570
|
const rowsVariant = variant === "rows";
|
|
4319
4571
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
4320
4572
|
const revokeVariant = rowsVariant ? "linkDanger" : "danger";
|
|
4321
|
-
const [password, setPassword] = (0,
|
|
4573
|
+
const [password, setPassword] = (0, import_react28.useState)("");
|
|
4322
4574
|
const passwordAction = useAction();
|
|
4323
4575
|
const sessionAction = useAction();
|
|
4324
|
-
const [sessions, setSessions] = (0,
|
|
4325
|
-
const [listError, setListError] = (0,
|
|
4326
|
-
const errorMessageRef = (0,
|
|
4327
|
-
(0,
|
|
4576
|
+
const [sessions, setSessions] = (0, import_react28.useState)(null);
|
|
4577
|
+
const [listError, setListError] = (0, import_react28.useState)(null);
|
|
4578
|
+
const errorMessageRef = (0, import_react28.useRef)(errorMessage);
|
|
4579
|
+
(0, import_react28.useEffect)(() => {
|
|
4328
4580
|
errorMessageRef.current = errorMessage;
|
|
4329
4581
|
});
|
|
4330
|
-
const load = (0,
|
|
4582
|
+
const load = (0, import_react28.useCallback)(async () => {
|
|
4331
4583
|
try {
|
|
4332
4584
|
setSessions(await auth.listSessions());
|
|
4333
4585
|
setListError(null);
|
|
@@ -4335,12 +4587,12 @@ function SecurityPanel(props) {
|
|
|
4335
4587
|
setListError(errorMessageRef.current(err));
|
|
4336
4588
|
}
|
|
4337
4589
|
}, [auth]);
|
|
4338
|
-
(0,
|
|
4590
|
+
(0, import_react28.useEffect)(() => {
|
|
4339
4591
|
void load();
|
|
4340
4592
|
}, [load]);
|
|
4341
4593
|
const others = (sessions ?? []).filter((s) => !s.current);
|
|
4342
|
-
return /* @__PURE__ */ (0,
|
|
4343
|
-
/* @__PURE__ */ (0,
|
|
4594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
|
|
4595
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
4344
4596
|
"form",
|
|
4345
4597
|
{
|
|
4346
4598
|
...a.el("securityPanel.passwordForm", "throttle-stack"),
|
|
@@ -4353,8 +4605,8 @@ function SecurityPanel(props) {
|
|
|
4353
4605
|
});
|
|
4354
4606
|
},
|
|
4355
4607
|
children: [
|
|
4356
|
-
/* @__PURE__ */ (0,
|
|
4357
|
-
/* @__PURE__ */ (0,
|
|
4608
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h3", { children: t.security.passwordTitle }),
|
|
4609
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4358
4610
|
Field,
|
|
4359
4611
|
{
|
|
4360
4612
|
label: t.security.newPassword,
|
|
@@ -4365,21 +4617,21 @@ function SecurityPanel(props) {
|
|
|
4365
4617
|
onChange: setPassword
|
|
4366
4618
|
}
|
|
4367
4619
|
),
|
|
4368
|
-
passwordAction.error ? /* @__PURE__ */ (0,
|
|
4369
|
-
passwordAction.notice ? /* @__PURE__ */ (0,
|
|
4370
|
-
/* @__PURE__ */ (0,
|
|
4620
|
+
passwordAction.error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: passwordAction.error }) : null,
|
|
4621
|
+
passwordAction.notice ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "success", children: passwordAction.notice }) : null,
|
|
4622
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
|
|
4371
4623
|
]
|
|
4372
4624
|
}
|
|
4373
4625
|
),
|
|
4374
|
-
/* @__PURE__ */ (0,
|
|
4375
|
-
/* @__PURE__ */ (0,
|
|
4376
|
-
listError ? /* @__PURE__ */ (0,
|
|
4377
|
-
/* @__PURE__ */ (0,
|
|
4378
|
-
/* @__PURE__ */ (0,
|
|
4626
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
|
|
4627
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h3", { children: t.security.sessionsTitle }),
|
|
4628
|
+
listError ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
4629
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: listError }),
|
|
4630
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
|
|
4379
4631
|
] }) : null,
|
|
4380
|
-
sessionAction.error ? /* @__PURE__ */ (0,
|
|
4381
|
-
sessions === null && !listError ? /* @__PURE__ */ (0,
|
|
4382
|
-
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0,
|
|
4632
|
+
sessionAction.error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: sessionAction.error }) : null,
|
|
4633
|
+
sessions === null && !listError ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Skeleton, { count: 2 }) : null,
|
|
4634
|
+
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4383
4635
|
DataTable,
|
|
4384
4636
|
{
|
|
4385
4637
|
tableKey: "securityPanel.table",
|
|
@@ -4387,12 +4639,12 @@ function SecurityPanel(props) {
|
|
|
4387
4639
|
rowKey: (session) => session.id,
|
|
4388
4640
|
rows: sessions,
|
|
4389
4641
|
columns: [
|
|
4390
|
-
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0,
|
|
4391
|
-
/* @__PURE__ */ (0,
|
|
4392
|
-
session.current ? /* @__PURE__ */ (0,
|
|
4642
|
+
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
|
|
4643
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
4644
|
+
session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
4393
4645
|
] }) },
|
|
4394
4646
|
{ key: "lastActive", label: t.security.lastActive, render: (session) => formatDate(session.lastUsedAt, locale) },
|
|
4395
|
-
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0,
|
|
4647
|
+
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4396
4648
|
Button,
|
|
4397
4649
|
{
|
|
4398
4650
|
variant: "danger",
|
|
@@ -4407,19 +4659,19 @@ function SecurityPanel(props) {
|
|
|
4407
4659
|
) : null }
|
|
4408
4660
|
]
|
|
4409
4661
|
}
|
|
4410
|
-
) : (sessions ?? []).map((session) => /* @__PURE__ */ (0,
|
|
4411
|
-
/* @__PURE__ */ (0,
|
|
4412
|
-
/* @__PURE__ */ (0,
|
|
4413
|
-
/* @__PURE__ */ (0,
|
|
4414
|
-
session.current ? /* @__PURE__ */ (0,
|
|
4662
|
+
) : (sessions ?? []).map((session) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
|
|
4663
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { children: [
|
|
4664
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
|
|
4665
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
4666
|
+
session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
4415
4667
|
] }),
|
|
4416
|
-
/* @__PURE__ */ (0,
|
|
4668
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
|
|
4417
4669
|
t.security.lastActive,
|
|
4418
4670
|
" ",
|
|
4419
4671
|
formatDate(session.lastUsedAt, locale)
|
|
4420
4672
|
] })
|
|
4421
4673
|
] }),
|
|
4422
|
-
!session.current ? /* @__PURE__ */ (0,
|
|
4674
|
+
!session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4423
4675
|
Button,
|
|
4424
4676
|
{
|
|
4425
4677
|
variant: revokeVariant,
|
|
@@ -4433,8 +4685,8 @@ function SecurityPanel(props) {
|
|
|
4433
4685
|
}
|
|
4434
4686
|
) : null
|
|
4435
4687
|
] }, session.id)),
|
|
4436
|
-
sessions !== null && others.length === 0 ? /* @__PURE__ */ (0,
|
|
4437
|
-
others.length > 0 ? /* @__PURE__ */ (0,
|
|
4688
|
+
sessions !== null && others.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
|
|
4689
|
+
others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4438
4690
|
Button,
|
|
4439
4691
|
{
|
|
4440
4692
|
variant: "danger",
|
|
@@ -4454,7 +4706,7 @@ function SecurityPanel(props) {
|
|
|
4454
4706
|
}
|
|
4455
4707
|
|
|
4456
4708
|
// src/react/components/account/AccountDashboard.tsx
|
|
4457
|
-
var
|
|
4709
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4458
4710
|
var ACCOUNT_TABS = [
|
|
4459
4711
|
"profile",
|
|
4460
4712
|
"addresses",
|
|
@@ -4483,9 +4735,10 @@ function AccountDashboard(props) {
|
|
|
4483
4735
|
const { status } = useAuth();
|
|
4484
4736
|
const shown = props.tabs ?? [...ACCOUNT_TABS];
|
|
4485
4737
|
const controlled = props.tab !== void 0;
|
|
4486
|
-
const [internal, setInternal] = (0,
|
|
4487
|
-
const
|
|
4488
|
-
(0,
|
|
4738
|
+
const [internal, setInternal] = (0, import_react29.useState)(shown[0] ?? "profile");
|
|
4739
|
+
const [openOrderId, setOpenOrderId] = (0, import_react29.useState)(null);
|
|
4740
|
+
const idBase = (0, import_react29.useId)();
|
|
4741
|
+
(0, import_react29.useEffect)(() => {
|
|
4489
4742
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
4490
4743
|
const apply = () => {
|
|
4491
4744
|
const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
|
|
@@ -4506,7 +4759,7 @@ function AccountDashboard(props) {
|
|
|
4506
4759
|
};
|
|
4507
4760
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
4508
4761
|
const sidebar = (props.layout ?? "sidebar") === "sidebar";
|
|
4509
|
-
const nav = /* @__PURE__ */ (0,
|
|
4762
|
+
const nav = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4510
4763
|
Tabs,
|
|
4511
4764
|
{
|
|
4512
4765
|
idBase,
|
|
@@ -4522,7 +4775,7 @@ function AccountDashboard(props) {
|
|
|
4522
4775
|
}))
|
|
4523
4776
|
}
|
|
4524
4777
|
);
|
|
4525
|
-
const panel = /* @__PURE__ */ (0,
|
|
4778
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
4526
4779
|
"div",
|
|
4527
4780
|
{
|
|
4528
4781
|
...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
|
|
@@ -4531,46 +4784,58 @@ function AccountDashboard(props) {
|
|
|
4531
4784
|
"aria-labelledby": `${idBase}-tab-${active}`,
|
|
4532
4785
|
tabIndex: 0,
|
|
4533
4786
|
children: [
|
|
4534
|
-
active === "profile" ? /* @__PURE__ */ (0,
|
|
4535
|
-
active === "addresses" ? /* @__PURE__ */ (0,
|
|
4536
|
-
active === "paymentMethods" ? /* @__PURE__ */ (0,
|
|
4537
|
-
active === "orders" ? /* @__PURE__ */ (0,
|
|
4787
|
+
active === "profile" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ProfilePanel, { ...shared }) : null,
|
|
4788
|
+
active === "addresses" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4789
|
+
active === "paymentMethods" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4790
|
+
active === "orders" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4538
4791
|
OrdersPanel,
|
|
4539
4792
|
{
|
|
4540
4793
|
...shared,
|
|
4541
4794
|
variant: props.panelVariant,
|
|
4795
|
+
initialOpenId: openOrderId,
|
|
4542
4796
|
onViewSubscription: () => go("subscriptions"),
|
|
4543
4797
|
onPayNow: props.onPayNow,
|
|
4544
4798
|
onReorder: props.onReorder,
|
|
4545
4799
|
onTrackShipment: props.onTrackShipment
|
|
4546
4800
|
}
|
|
4547
4801
|
) : null,
|
|
4548
|
-
active === "invoices" ? /* @__PURE__ */ (0,
|
|
4549
|
-
|
|
4550
|
-
|
|
4802
|
+
active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4803
|
+
InvoicesPanel,
|
|
4804
|
+
{
|
|
4805
|
+
...shared,
|
|
4806
|
+
variant: props.panelVariant,
|
|
4807
|
+
onViewOrder: (orderId) => {
|
|
4808
|
+
setOpenOrderId(orderId);
|
|
4809
|
+
go("orders");
|
|
4810
|
+
},
|
|
4811
|
+
onViewSubscription: () => go("subscriptions")
|
|
4812
|
+
}
|
|
4813
|
+
) : null,
|
|
4814
|
+
active === "subscriptions" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4815
|
+
active === "security" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
|
|
4551
4816
|
]
|
|
4552
4817
|
}
|
|
4553
4818
|
);
|
|
4554
|
-
return /* @__PURE__ */ (0,
|
|
4555
|
-
/* @__PURE__ */ (0,
|
|
4556
|
-
sidebar ? /* @__PURE__ */ (0,
|
|
4557
|
-
/* @__PURE__ */ (0,
|
|
4819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
|
|
4820
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(VerifyEmailBanner, { ...shared }),
|
|
4821
|
+
sidebar ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "throttle-account", children: [
|
|
4822
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
|
|
4558
4823
|
panel
|
|
4559
|
-
] }) : /* @__PURE__ */ (0,
|
|
4560
|
-
/* @__PURE__ */ (0,
|
|
4824
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
4825
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.el("accountDashboard.tabs"), children: nav }),
|
|
4561
4826
|
panel
|
|
4562
4827
|
] })
|
|
4563
4828
|
] }) }) });
|
|
4564
4829
|
}
|
|
4565
4830
|
|
|
4566
4831
|
// src/react/components/account/AccountModal.tsx
|
|
4567
|
-
var
|
|
4832
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4568
4833
|
function AccountModal(props) {
|
|
4569
4834
|
const a = useAppearance(props.appearance);
|
|
4570
4835
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4571
4836
|
const { t } = useCopy(props.localization);
|
|
4572
|
-
const titleId = (0,
|
|
4573
|
-
return /* @__PURE__ */ (0,
|
|
4837
|
+
const titleId = (0, import_react30.useId)();
|
|
4838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
4574
4839
|
Modal,
|
|
4575
4840
|
{
|
|
4576
4841
|
open: props.open,
|
|
@@ -4580,15 +4845,15 @@ function AccountModal(props) {
|
|
|
4580
4845
|
overlayKey: "accountModal.overlay",
|
|
4581
4846
|
containerKey: "accountModal.container",
|
|
4582
4847
|
children: [
|
|
4583
|
-
/* @__PURE__ */ (0,
|
|
4584
|
-
/* @__PURE__ */ (0,
|
|
4848
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
|
|
4849
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
|
|
4585
4850
|
]
|
|
4586
4851
|
}
|
|
4587
4852
|
) });
|
|
4588
4853
|
}
|
|
4589
4854
|
|
|
4590
4855
|
// src/react/components/provider.tsx
|
|
4591
|
-
var
|
|
4856
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4592
4857
|
var warned = /* @__PURE__ */ new Set();
|
|
4593
4858
|
function warnOnce(key, message) {
|
|
4594
4859
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -4596,9 +4861,9 @@ function warnOnce(key, message) {
|
|
|
4596
4861
|
warned.add(key);
|
|
4597
4862
|
console.warn(`[@usethrottle/auth] ${message}`);
|
|
4598
4863
|
}
|
|
4599
|
-
var ThrottleUIContext = (0,
|
|
4864
|
+
var ThrottleUIContext = (0, import_react31.createContext)(null);
|
|
4600
4865
|
function useThrottle() {
|
|
4601
|
-
const ctx = (0,
|
|
4866
|
+
const ctx = (0, import_react31.useContext)(ThrottleUIContext);
|
|
4602
4867
|
if (!ctx) {
|
|
4603
4868
|
warnOnce(
|
|
4604
4869
|
"use-throttle-no-provider",
|
|
@@ -4633,51 +4898,51 @@ function ThrottleProvider(props) {
|
|
|
4633
4898
|
__captureStepUp
|
|
4634
4899
|
} = props;
|
|
4635
4900
|
useInjectStyles(injectStyles);
|
|
4636
|
-
const [stepUpOpen, setStepUpOpen] = (0,
|
|
4637
|
-
const resolveStepUp = (0,
|
|
4638
|
-
const claimRef = (0,
|
|
4901
|
+
const [stepUpOpen, setStepUpOpen] = (0, import_react31.useState)(false);
|
|
4902
|
+
const resolveStepUp = (0, import_react31.useRef)(null);
|
|
4903
|
+
const claimRef = (0, import_react31.useRef)(claimCartOnSignIn);
|
|
4639
4904
|
claimRef.current = claimCartOnSignIn;
|
|
4640
|
-
const [overlay, setOverlay] = (0,
|
|
4641
|
-
const overlayRestoreFocus = (0,
|
|
4642
|
-
const [accountTabs, setAccountTabs] = (0,
|
|
4643
|
-
const onOverlaySuccess = (0,
|
|
4644
|
-
const openSignIn = (0,
|
|
4905
|
+
const [overlay, setOverlay] = (0, import_react31.useState)(null);
|
|
4906
|
+
const overlayRestoreFocus = (0, import_react31.useRef)(null);
|
|
4907
|
+
const [accountTabs, setAccountTabs] = (0, import_react31.useState)(void 0);
|
|
4908
|
+
const onOverlaySuccess = (0, import_react31.useRef)(null);
|
|
4909
|
+
const openSignIn = (0, import_react31.useCallback)((onSuccess) => {
|
|
4645
4910
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
4646
4911
|
setOverlay("signIn");
|
|
4647
4912
|
}, []);
|
|
4648
|
-
const openSignUp = (0,
|
|
4913
|
+
const openSignUp = (0, import_react31.useCallback)((onSuccess) => {
|
|
4649
4914
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
4650
4915
|
setOverlay("signUp");
|
|
4651
4916
|
}, []);
|
|
4652
|
-
const openAccount = (0,
|
|
4917
|
+
const openAccount = (0, import_react31.useCallback)((opts) => {
|
|
4653
4918
|
onOverlaySuccess.current = null;
|
|
4654
4919
|
overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
|
|
4655
4920
|
setAccountTabs(opts?.tabs);
|
|
4656
4921
|
setOverlay("account");
|
|
4657
4922
|
}, []);
|
|
4658
|
-
const closeOverlay = (0,
|
|
4923
|
+
const closeOverlay = (0, import_react31.useCallback)(() => {
|
|
4659
4924
|
onOverlaySuccess.current = null;
|
|
4660
4925
|
overlayRestoreFocus.current = null;
|
|
4661
4926
|
setOverlay(null);
|
|
4662
4927
|
}, []);
|
|
4663
|
-
const handleOverlaySuccess = (0,
|
|
4928
|
+
const handleOverlaySuccess = (0, import_react31.useCallback)(() => {
|
|
4664
4929
|
const fn = onOverlaySuccess.current;
|
|
4665
4930
|
onOverlaySuccess.current = null;
|
|
4666
4931
|
setOverlay(null);
|
|
4667
4932
|
fn?.();
|
|
4668
4933
|
}, []);
|
|
4669
|
-
const ui = (0,
|
|
4934
|
+
const ui = (0, import_react31.useMemo)(
|
|
4670
4935
|
() => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
|
|
4671
4936
|
[overlay, openSignIn, openSignUp, openAccount, closeOverlay]
|
|
4672
4937
|
);
|
|
4673
|
-
const askForStepUp = (0,
|
|
4938
|
+
const askForStepUp = (0, import_react31.useCallback)(
|
|
4674
4939
|
() => new Promise((resolve) => {
|
|
4675
4940
|
resolveStepUp.current = resolve;
|
|
4676
4941
|
setStepUpOpen(true);
|
|
4677
4942
|
}),
|
|
4678
4943
|
[]
|
|
4679
4944
|
);
|
|
4680
|
-
const auth = (0,
|
|
4945
|
+
const auth = (0, import_react31.useMemo)(() => {
|
|
4681
4946
|
__captureStepUp?.(askForStepUp);
|
|
4682
4947
|
const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
|
|
4683
4948
|
const account = createAccount(client);
|
|
@@ -4710,10 +4975,9 @@ function ThrottleProvider(props) {
|
|
|
4710
4975
|
resolve?.(password);
|
|
4711
4976
|
};
|
|
4712
4977
|
const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
|
|
4713
|
-
return /* @__PURE__ */ (0,
|
|
4978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ConfirmProvider, { stepUpOpen, onStepUpResolve: finishStepUp, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
|
|
4714
4979
|
children,
|
|
4715
|
-
/* @__PURE__ */ (0,
|
|
4716
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4980
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4717
4981
|
AuthModal,
|
|
4718
4982
|
{
|
|
4719
4983
|
open: authOverlayOpen,
|
|
@@ -4724,10 +4988,14 @@ function ThrottleProvider(props) {
|
|
|
4724
4988
|
},
|
|
4725
4989
|
overlay === "signUp" ? "signUp" : "signIn"
|
|
4726
4990
|
),
|
|
4727
|
-
/* @__PURE__ */ (0,
|
|
4991
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
|
|
4728
4992
|
] }) }) }) }) }) });
|
|
4729
4993
|
}
|
|
4730
4994
|
|
|
4995
|
+
// src/react/components/auth/StepUpDialog.tsx
|
|
4996
|
+
var import_react32 = require("react");
|
|
4997
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
4998
|
+
|
|
4731
4999
|
// src/react/components/auth/SignInButton.tsx
|
|
4732
5000
|
var import_react33 = require("react");
|
|
4733
5001
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|