@openrails/billing-ui 0.273.0 → 0.275.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/admin/components/customer-search.d.ts +5 -0
- package/dist/admin/components/missing-record.d.ts +6 -0
- package/dist/admin/components/status-badge.d.ts +1 -0
- package/dist/admin/context.d.ts +34 -2
- package/dist/admin/lib/api/endpoints.d.ts +4 -1
- package/dist/admin/lib/api/index.d.ts +3 -0
- package/dist/admin/lib/api/order-endpoints.d.ts +1 -0
- package/dist/admin/lib/api/types.d.ts +4 -12
- package/dist/admin/lib/capabilities.d.ts +4 -0
- package/dist/admin/lib/dialog-width.d.ts +4 -3
- package/dist/admin/lib/error-text.d.ts +4 -0
- package/dist/admin/lib/format.d.ts +5 -1
- package/dist/admin/lib/mutations.d.ts +6 -1
- package/dist/admin/lib/order-queries.d.ts +3 -0
- package/dist/admin/lib/queries.d.ts +6 -0
- package/dist/admin/lib/tile-grids.d.ts +6 -0
- package/dist/admin/messages.d.ts +102 -8
- package/dist/admin/pages/dashboard/lib.d.ts +1 -0
- package/dist/admin/pages/imports/shared.d.ts +1 -0
- package/dist/admin/pages/payments/index.d.ts +1 -2
- package/dist/admin/pages/subscriptions/change-subscription-dialog.d.ts +4 -7
- package/dist/admin/pages/subscriptions/index.d.ts +1 -2
- package/dist/admin/pages/subscriptions/subscription-change-options.d.ts +6 -15
- package/dist/admin-attempts-CP5CWyNR.js +419 -0
- package/dist/admin-attempts-CP5CWyNR.js.map +1 -0
- package/dist/{admin-auth-1aZIgXiS.js → admin-auth-DlIOmwPo.js} +2 -2
- package/dist/{admin-auth-1aZIgXiS.js.map → admin-auth-DlIOmwPo.js.map} +1 -1
- package/dist/{admin-badge-pgG6D9-a.js → admin-badge-DR_8AhdC.js} +2 -2
- package/dist/{admin-badge-pgG6D9-a.js.map → admin-badge-DR_8AhdC.js.map} +1 -1
- package/dist/{admin-button-CrcYk5r0.js → admin-button-DBzTD6By.js} +2 -2
- package/dist/{admin-button-CrcYk5r0.js.map → admin-button-DBzTD6By.js.map} +1 -1
- package/dist/{admin-capabilities-BDcZeHL_.js → admin-capabilities-CZdT1Pxe.js} +35 -14
- package/dist/admin-capabilities-CZdT1Pxe.js.map +1 -0
- package/dist/{admin-card-DvTMc5Se.js → admin-card-mZl4-s5d.js} +2 -2
- package/dist/{admin-card-DvTMc5Se.js.map → admin-card-mZl4-s5d.js.map} +1 -1
- package/dist/{admin-catalog-BlF5mnu4.js → admin-catalog-DpTjS0Yo.js} +298 -298
- package/dist/{admin-catalog-BlF5mnu4.js.map → admin-catalog-DpTjS0Yo.js.map} +1 -1
- package/dist/{admin-cursor-pager-CIb3Jw2F.js → admin-cursor-pager-C-KjCIy9.js} +6 -6
- package/dist/{admin-cursor-pager-CIb3Jw2F.js.map → admin-cursor-pager-C-KjCIy9.js.map} +1 -1
- package/dist/{admin-customers-EpfoWDh-.js → admin-customers-BE3N839X.js} +22 -21
- package/dist/{admin-customers-EpfoWDh-.js.map → admin-customers-BE3N839X.js.map} +1 -1
- package/dist/admin-dashboard-BxjkV15J.js +464 -0
- package/dist/admin-dashboard-BxjkV15J.js.map +1 -0
- package/dist/admin-data-table-D89AwWz_.js +107 -0
- package/dist/admin-data-table-D89AwWz_.js.map +1 -0
- package/dist/admin-detail-BKe9xqPd.js +338 -0
- package/dist/admin-detail-BKe9xqPd.js.map +1 -0
- package/dist/admin-detail-C8lD7U2t.js +699 -0
- package/dist/admin-detail-C8lD7U2t.js.map +1 -0
- package/dist/admin-detail-D6zD085K.js +354 -0
- package/dist/admin-detail-D6zD085K.js.map +1 -0
- package/dist/{admin-detail-3wFIDPNB.js → admin-detail-Ln56otK0.js} +83 -83
- package/dist/{admin-detail-3wFIDPNB.js.map → admin-detail-Ln56otK0.js.map} +1 -1
- package/dist/admin-detail-P-UnNvXJ.js +1357 -0
- package/dist/admin-detail-P-UnNvXJ.js.map +1 -0
- package/dist/{admin-dialog-BSRf9Zre.js → admin-dialog-Dn2FRJu4.js} +3 -3
- package/dist/{admin-dialog-BSRf9Zre.js.map → admin-dialog-Dn2FRJu4.js.map} +1 -1
- package/dist/admin-dialog-width-CC7QHT1p.js +6 -0
- package/dist/admin-dialog-width-CC7QHT1p.js.map +1 -0
- package/dist/{admin-dropdown-menu-D0E5rwmn.js → admin-dropdown-menu-DLUn6Uj3.js} +2 -2
- package/dist/{admin-dropdown-menu-D0E5rwmn.js.map → admin-dropdown-menu-DLUn6Uj3.js.map} +1 -1
- package/dist/{admin-dunning-B2zgtrOo.js → admin-dunning-COaHzrmN.js} +2 -2
- package/dist/{admin-dunning-B2zgtrOo.js.map → admin-dunning-COaHzrmN.js.map} +1 -1
- package/dist/{admin-fact-card-BPSVhS15.js → admin-fact-card-DKvBnUXB.js} +2 -2
- package/dist/{admin-fact-card-BPSVhS15.js.map → admin-fact-card-DKvBnUXB.js.map} +1 -1
- package/dist/admin-format-BbiTCqUG.js +171 -0
- package/dist/admin-format-BbiTCqUG.js.map +1 -0
- package/dist/{admin-health-D0L5Kig7.js → admin-health-DmnI4e8K.js} +249 -248
- package/dist/admin-health-DmnI4e8K.js.map +1 -0
- package/dist/{admin-imports-CgZB5JAV.js → admin-imports-C0aMP6sj.js} +65 -65
- package/dist/{admin-imports-CgZB5JAV.js.map → admin-imports-C0aMP6sj.js.map} +1 -1
- package/dist/{admin-input-DJAK9nmk.js → admin-input-JKrQIGfD.js} +2 -2
- package/dist/{admin-input-DJAK9nmk.js.map → admin-input-JKrQIGfD.js.map} +1 -1
- package/dist/{admin-label-aviN9Gng.js → admin-label-CHWsVIZC.js} +2 -2
- package/dist/{admin-label-aviN9Gng.js.map → admin-label-CHWsVIZC.js.map} +1 -1
- package/dist/{admin-linked-table-row-BGr7JXeM.js → admin-linked-table-row-BMZYYsuk.js} +4 -4
- package/dist/{admin-linked-table-row-BGr7JXeM.js.map → admin-linked-table-row-BMZYYsuk.js.map} +1 -1
- package/dist/{admin-map-dialog-DS2Wz6G3.js → admin-map-dialog-BHUGdCcv.js} +24 -24
- package/dist/{admin-map-dialog-DS2Wz6G3.js.map → admin-map-dialog-BHUGdCcv.js.map} +1 -1
- package/dist/{admin-metering-D-e-37Jn.js → admin-metering-CDqueHUh.js} +307 -307
- package/dist/{admin-metering-D-e-37Jn.js.map → admin-metering-CDqueHUh.js.map} +1 -1
- package/dist/admin-missing-record-BPFs3MmO.js +42 -0
- package/dist/admin-missing-record-BPFs3MmO.js.map +1 -0
- package/dist/admin-ops-CL2kjDwi.js +359 -0
- package/dist/admin-ops-CL2kjDwi.js.map +1 -0
- package/dist/admin-orders-C1Sf2qhc.js +192 -0
- package/dist/admin-orders-C1Sf2qhc.js.map +1 -0
- package/dist/admin-parked-a0tB5bhG.js +193 -0
- package/dist/admin-parked-a0tB5bhG.js.map +1 -0
- package/dist/admin-payments-DJcjwRA4.js +221 -0
- package/dist/admin-payments-DJcjwRA4.js.map +1 -0
- package/dist/{admin-price-detail-CSI5oKdb.js → admin-price-detail-BOmeWw15.js} +103 -103
- package/dist/{admin-price-detail-CSI5oKdb.js.map → admin-price-detail-BOmeWw15.js.map} +1 -1
- package/dist/{admin-price-format-BVUpDoSC.js → admin-price-format-CqOmHrIn.js} +2 -2
- package/dist/{admin-price-format-BVUpDoSC.js.map → admin-price-format-CqOmHrIn.js.map} +1 -1
- package/dist/{admin-price-wizard-CBEcNGvP.js → admin-price-wizard-B6s5OJeO.js} +63 -63
- package/dist/{admin-price-wizard-CBEcNGvP.js.map → admin-price-wizard-B6s5OJeO.js.map} +1 -1
- package/dist/{admin-proposals-Cuj7tvaM.js → admin-proposals-DVrl-ym4.js} +70 -70
- package/dist/{admin-proposals-Cuj7tvaM.js.map → admin-proposals-DVrl-ym4.js.map} +1 -1
- package/dist/admin-provider-prices-BVVogH7Q.js +241 -0
- package/dist/admin-provider-prices-BVVogH7Q.js.map +1 -0
- package/dist/{admin-range-picker-De36L-AP.js → admin-range-picker-C6BtSm2B.js} +9 -9
- package/dist/{admin-range-picker-De36L-AP.js.map → admin-range-picker-C6BtSm2B.js.map} +1 -1
- package/dist/{admin-records-H0MlhEVY.js → admin-records-DKtcgN11.js} +50 -50
- package/dist/{admin-records-H0MlhEVY.js.map → admin-records-DKtcgN11.js.map} +1 -1
- package/dist/{admin-reports-BFGS_PWf.js → admin-reports-CtPoiceH.js} +50 -50
- package/dist/{admin-reports-BFGS_PWf.js.map → admin-reports-CtPoiceH.js.map} +1 -1
- package/dist/{admin-select-BUcEU5Rg.js → admin-select-6Yuh5M1Q.js} +2 -2
- package/dist/{admin-select-BUcEU5Rg.js.map → admin-select-6Yuh5M1Q.js.map} +1 -1
- package/dist/admin-settings-DscHu4ww.js +1823 -0
- package/dist/admin-settings-DscHu4ww.js.map +1 -0
- package/dist/{admin-shared-lfIUEbPY.js → admin-shared-BywM-MMp.js} +28 -24
- package/dist/{admin-shared-lfIUEbPY.js.map → admin-shared-BywM-MMp.js.map} +1 -1
- package/dist/{admin-skeleton-B0yzYY_X.js → admin-skeleton-lndmw89u.js} +2 -2
- package/dist/{admin-skeleton-B0yzYY_X.js.map → admin-skeleton-lndmw89u.js.map} +1 -1
- package/dist/admin-status-badge-IL8ofZ_6.js +51 -0
- package/dist/admin-status-badge-IL8ofZ_6.js.map +1 -0
- package/dist/admin-subscriptions-Cd5CGrue.js +271 -0
- package/dist/admin-subscriptions-Cd5CGrue.js.map +1 -0
- package/dist/{admin-switch-DDorugaw.js → admin-switch-DpwQSzEm.js} +2 -2
- package/dist/{admin-switch-DDorugaw.js.map → admin-switch-DpwQSzEm.js.map} +1 -1
- package/dist/{admin-table-BU6Tie69.js → admin-table-D-GdGM1m.js} +2 -2
- package/dist/{admin-table-BU6Tie69.js.map → admin-table-D-GdGM1m.js.map} +1 -1
- package/dist/admin-tabs-B--1flzO.js +158 -0
- package/dist/admin-tabs-B--1flzO.js.map +1 -0
- package/dist/{admin-textarea-Dc6lnEub.js → admin-textarea-xsp5V9xM.js} +2 -2
- package/dist/{admin-textarea-Dc6lnEub.js.map → admin-textarea-xsp5V9xM.js.map} +1 -1
- package/dist/admin-tile-grids-CzGpidd9.js +6 -0
- package/dist/admin-tile-grids-CzGpidd9.js.map +1 -0
- package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js → admin-typed-confirm-dialog-NiEDwX_0.js} +11 -11
- package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js.map → admin-typed-confirm-dialog-NiEDwX_0.js.map} +1 -1
- package/dist/{admin-utils-B9eEBNsR.js → admin-utils-wuPUD0uh.js} +341 -283
- package/dist/admin-utils-wuPUD0uh.js.map +1 -0
- package/dist/admin-widget-viz-kHHVmDEx.js +646 -0
- package/dist/admin-widget-viz-kHHVmDEx.js.map +1 -0
- package/dist/admin.css +1 -1
- package/dist/admin.js +544 -413
- package/dist/admin.js.map +1 -1
- package/dist/client/generated/routes.d.ts +17 -0
- package/dist/client/generated/wire.d.ts +4 -0
- package/dist/client/types.d.ts +6 -0
- package/dist/{client-BYgnI6_h.js → client-ctrbivyN.js} +3 -2
- package/dist/client-ctrbivyN.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/{hooks-t2tSrCpa.js → hooks-KpTetx6F.js} +2 -2
- package/dist/{hooks-t2tSrCpa.js.map → hooks-KpTetx6F.js.map} +1 -1
- package/dist/index.js +750 -711
- package/dist/index.js.map +1 -1
- package/dist/lib/card-brands.d.ts +1 -0
- package/dist/locales/de.js +3 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +3 -0
- package/dist/locales/en.js +3 -0
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +3 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/ja.js +3 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.js +3 -0
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/zh.js +3 -0
- package/dist/locales/zh.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/admin-attempts-DyDDt-qw.js +0 -418
- package/dist/admin-attempts-DyDDt-qw.js.map +0 -1
- package/dist/admin-capabilities-BDcZeHL_.js.map +0 -1
- package/dist/admin-dashboard-CJE63yz4.js +0 -420
- package/dist/admin-dashboard-CJE63yz4.js.map +0 -1
- package/dist/admin-data-table-hvFcJepL.js +0 -96
- package/dist/admin-data-table-hvFcJepL.js.map +0 -1
- package/dist/admin-detail-BRP6pL7t.js +0 -328
- package/dist/admin-detail-BRP6pL7t.js.map +0 -1
- package/dist/admin-detail-CRzFb_pa.js +0 -1331
- package/dist/admin-detail-CRzFb_pa.js.map +0 -1
- package/dist/admin-detail-QLxU8r-5.js +0 -344
- package/dist/admin-detail-QLxU8r-5.js.map +0 -1
- package/dist/admin-detail-pPC8Q9l-.js +0 -710
- package/dist/admin-detail-pPC8Q9l-.js.map +0 -1
- package/dist/admin-dialog-width-BPrgdYlj.js +0 -6
- package/dist/admin-dialog-width-BPrgdYlj.js.map +0 -1
- package/dist/admin-format-DoohJ7Fg.js +0 -136
- package/dist/admin-format-DoohJ7Fg.js.map +0 -1
- package/dist/admin-health-D0L5Kig7.js.map +0 -1
- package/dist/admin-ops-CQP4TzWM.js +0 -235
- package/dist/admin-ops-CQP4TzWM.js.map +0 -1
- package/dist/admin-orders-BJ7W5S8P.js +0 -192
- package/dist/admin-orders-BJ7W5S8P.js.map +0 -1
- package/dist/admin-parked-B8xHkV2e.js +0 -193
- package/dist/admin-parked-B8xHkV2e.js.map +0 -1
- package/dist/admin-payments-CzkzqYA1.js +0 -246
- package/dist/admin-payments-CzkzqYA1.js.map +0 -1
- package/dist/admin-provider-prices-B6vwnVPi.js +0 -246
- package/dist/admin-provider-prices-B6vwnVPi.js.map +0 -1
- package/dist/admin-settings-DYC-c7mJ.js +0 -1813
- package/dist/admin-settings-DYC-c7mJ.js.map +0 -1
- package/dist/admin-status-badge-0-K37EfN.js +0 -43
- package/dist/admin-status-badge-0-K37EfN.js.map +0 -1
- package/dist/admin-subscriptions-CvW-YFs0.js +0 -301
- package/dist/admin-subscriptions-CvW-YFs0.js.map +0 -1
- package/dist/admin-tabs-D5lqdVcC.js +0 -46
- package/dist/admin-tabs-D5lqdVcC.js.map +0 -1
- package/dist/admin-utils-B9eEBNsR.js.map +0 -1
- package/dist/admin-widget-viz-8aukE3v_.js +0 -581
- package/dist/admin-widget-viz-8aukE3v_.js.map +0 -1
- package/dist/client-BYgnI6_h.js.map +0 -1
|
@@ -0,0 +1,1823 @@
|
|
|
1
|
+
import { E as e, O as t, f as n, l as r, p as i, w as a } from "./admin-utils-wuPUD0uh.js";
|
|
2
|
+
import { t as o } from "./admin-button-DBzTD6By.js";
|
|
3
|
+
import { t as s } from "./admin-input-JKrQIGfD.js";
|
|
4
|
+
import { a as c, d as l, i as u, n as d, u as f } from "./admin-capabilities-CZdT1Pxe.js";
|
|
5
|
+
import { h as p, n as m, o as h, r as g, s as _, t as v } from "./admin-format-BbiTCqUG.js";
|
|
6
|
+
import { n as ee } from "./admin-confirm-katGq0Qo.js";
|
|
7
|
+
import { t as y } from "./admin-badge-DR_8AhdC.js";
|
|
8
|
+
import { t as b } from "./admin-form-field-errors-hbUMIriS.js";
|
|
9
|
+
import { a as x, i as S, n as C, r as w, t as T } from "./admin-select-6Yuh5M1Q.js";
|
|
10
|
+
import { a as E, n as D, o as O, r as k, s as A, t as j } from "./admin-table-D-GdGM1m.js";
|
|
11
|
+
import { a as M, i as N, n as P, o as F, r as te, s as ne, t as re } from "./admin-dialog-Dn2FRJu4.js";
|
|
12
|
+
import { t as I } from "./admin-label-CHWsVIZC.js";
|
|
13
|
+
import { t as ie } from "./admin-switch-DpwQSzEm.js";
|
|
14
|
+
import { r as L } from "./admin-dialog-width-CC7QHT1p.js";
|
|
15
|
+
import { t as ae } from "./admin-typed-confirm-dialog-NiEDwX_0.js";
|
|
16
|
+
import { a as oe, i as R, n as z, r as se, t as ce } from "./admin-tabs-B--1flzO.js";
|
|
17
|
+
import * as B from "react";
|
|
18
|
+
import { useMutation as V, useQuery as H, useQueryClient as U } from "@tanstack/react-query";
|
|
19
|
+
import { Fragment as W, jsx as G, jsxs as K } from "react/jsx-runtime";
|
|
20
|
+
import { HugeiconsIcon as q } from "@hugeicons/react";
|
|
21
|
+
import { Add01Icon as le, Cancel01Icon as ue, Delete02Icon as de } from "@hugeicons/core-free-icons";
|
|
22
|
+
import { useForm as J } from "@tanstack/react-form";
|
|
23
|
+
//#region src/admin/pages/settings/configuration-edit.ts
|
|
24
|
+
function Y(e) {
|
|
25
|
+
let { toast: t, toastApiError: n, toastStaleEdit: r, adminMutations: o } = i(), [s, c] = B.useState(null), l = U(), u = V(o.updateMerchantConfiguration(l));
|
|
26
|
+
return {
|
|
27
|
+
editing: s !== null,
|
|
28
|
+
open: () => {
|
|
29
|
+
e && c(e.revision);
|
|
30
|
+
},
|
|
31
|
+
close: () => c(null),
|
|
32
|
+
save: async (e, i, o) => {
|
|
33
|
+
if (s !== null) try {
|
|
34
|
+
await u.mutateAsync({
|
|
35
|
+
...e,
|
|
36
|
+
expected_revision: s
|
|
37
|
+
}), t.success(i), c(null);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
if (e instanceof a && e.revisionMismatch) {
|
|
40
|
+
r("The configuration"), c(null);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
n(e, o), e instanceof a && e.merchantConfigReadOnly && c(null);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/admin/pages/settings/setting-fields.tsx
|
|
50
|
+
function fe() {
|
|
51
|
+
let { adminQueries: t } = i(), { data: n } = H(t.config());
|
|
52
|
+
return !n || n.capabilities.features?.merchant_config_edits ? null : /* @__PURE__ */ G("p", {
|
|
53
|
+
className: "rounded-md border px-3 py-2 text-sm text-muted-foreground",
|
|
54
|
+
children: /* @__PURE__ */ G(e, { id: "Read-only: this merchant's configuration comes from a file. Change it there." })
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function pe({ edits: t, editing: n, form: r, saving: i, canSave: a = !0, onEdit: s, onCancel: c }) {
|
|
58
|
+
return t ? n ? /* @__PURE__ */ K("div", {
|
|
59
|
+
className: "flex items-center gap-2",
|
|
60
|
+
children: [/* @__PURE__ */ G(o, {
|
|
61
|
+
type: "button",
|
|
62
|
+
variant: "outline",
|
|
63
|
+
size: "sm",
|
|
64
|
+
disabled: i,
|
|
65
|
+
onClick: c,
|
|
66
|
+
children: /* @__PURE__ */ G(e, { id: "Cancel" })
|
|
67
|
+
}), /* @__PURE__ */ G(o, {
|
|
68
|
+
type: "submit",
|
|
69
|
+
size: "sm",
|
|
70
|
+
form: r,
|
|
71
|
+
disabled: !a || i,
|
|
72
|
+
children: i ? "Saving…" : "Save"
|
|
73
|
+
})]
|
|
74
|
+
}) : /* @__PURE__ */ G(o, {
|
|
75
|
+
type: "button",
|
|
76
|
+
variant: "outline",
|
|
77
|
+
size: "sm",
|
|
78
|
+
onClick: s,
|
|
79
|
+
children: /* @__PURE__ */ G(e, { id: "Edit" })
|
|
80
|
+
}) : null;
|
|
81
|
+
}
|
|
82
|
+
function X({ label: e, value: t }) {
|
|
83
|
+
return /* @__PURE__ */ K("div", {
|
|
84
|
+
className: "grid gap-1.5 md:grid-cols-[11rem_minmax(0,1fr)] md:gap-6",
|
|
85
|
+
children: [/* @__PURE__ */ G("dt", {
|
|
86
|
+
className: "text-sm text-muted-foreground",
|
|
87
|
+
children: e
|
|
88
|
+
}), /* @__PURE__ */ G("dd", {
|
|
89
|
+
className: t ? "min-w-0 text-sm break-words" : "text-sm text-muted-foreground",
|
|
90
|
+
children: t || "Not set"
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function Z({ label: e, id: n, children: r }) {
|
|
95
|
+
let { id: i } = t();
|
|
96
|
+
return /* @__PURE__ */ K("div", {
|
|
97
|
+
className: "grid gap-2 md:grid-cols-[11rem_minmax(0,1fr)] md:items-center md:gap-6",
|
|
98
|
+
children: [/* @__PURE__ */ G(I, {
|
|
99
|
+
htmlFor: i(n),
|
|
100
|
+
children: e
|
|
101
|
+
}), /* @__PURE__ */ G("div", {
|
|
102
|
+
className: "min-w-0",
|
|
103
|
+
children: r
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/admin/pages/settings/notifications.tsx
|
|
109
|
+
function me() {
|
|
110
|
+
let { adminQueries: t } = i(), n = H(t.merchantConfiguration("Load settings")), r = H(t.webhooks()), a = l(), o = r.data?.data ?? [];
|
|
111
|
+
return /* @__PURE__ */ K("div", {
|
|
112
|
+
className: "flex flex-col gap-10",
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ G(fe, {}),
|
|
115
|
+
n.data ? /* @__PURE__ */ G(he, {
|
|
116
|
+
configuration: n.data,
|
|
117
|
+
edits: a
|
|
118
|
+
}) : /* @__PURE__ */ G("p", {
|
|
119
|
+
className: "text-sm text-muted-foreground",
|
|
120
|
+
children: /* @__PURE__ */ G(e, { id: "Loading…" })
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ G(_e, {
|
|
123
|
+
webhooks: o,
|
|
124
|
+
loading: r.isPending,
|
|
125
|
+
edits: a
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function he({ configuration: n, edits: r }) {
|
|
131
|
+
let { id: i, text: a } = t(), o = n.alert_email ?? "", c = Y(n), l = J({
|
|
132
|
+
defaultValues: { email: o },
|
|
133
|
+
onSubmit: ({ value: e }) => c.save({ alert_email: e.email.trim() }, e.email.trim() ? "Alert email saved" : "Alert email cleared", "Save alert email")
|
|
134
|
+
});
|
|
135
|
+
return /* @__PURE__ */ K("section", {
|
|
136
|
+
className: "grid gap-5",
|
|
137
|
+
children: [/* @__PURE__ */ K("div", {
|
|
138
|
+
className: "flex flex-wrap items-start justify-between gap-4",
|
|
139
|
+
children: [/* @__PURE__ */ K("div", {
|
|
140
|
+
className: "grid gap-1",
|
|
141
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
142
|
+
className: "text-base font-semibold",
|
|
143
|
+
children: /* @__PURE__ */ G(e, { id: "Email delivery" })
|
|
144
|
+
}), /* @__PURE__ */ G("p", {
|
|
145
|
+
className: "text-sm text-muted-foreground",
|
|
146
|
+
children: /* @__PURE__ */ G(e, { id: "Send email alerts to this address." })
|
|
147
|
+
})]
|
|
148
|
+
}), /* @__PURE__ */ G(l.Subscribe, {
|
|
149
|
+
selector: (e) => e.isSubmitting,
|
|
150
|
+
children: (e) => /* @__PURE__ */ G(pe, {
|
|
151
|
+
edits: r,
|
|
152
|
+
editing: c.editing,
|
|
153
|
+
form: "alert-email-form",
|
|
154
|
+
saving: e,
|
|
155
|
+
onEdit: () => {
|
|
156
|
+
l.reset({ email: o }), c.open();
|
|
157
|
+
},
|
|
158
|
+
onCancel: c.close
|
|
159
|
+
})
|
|
160
|
+
})]
|
|
161
|
+
}), c.editing ? /* @__PURE__ */ G("form", {
|
|
162
|
+
id: i("alert-email-form"),
|
|
163
|
+
onSubmit: (e) => {
|
|
164
|
+
e.preventDefault(), e.stopPropagation(), l.handleSubmit();
|
|
165
|
+
},
|
|
166
|
+
children: /* @__PURE__ */ G(l.Field, {
|
|
167
|
+
name: "email",
|
|
168
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
169
|
+
label: a("Alert email"),
|
|
170
|
+
id: "alert-email",
|
|
171
|
+
children: /* @__PURE__ */ G(s, {
|
|
172
|
+
id: i("alert-email"),
|
|
173
|
+
type: "email",
|
|
174
|
+
placeholder: a("alerts@example.com"),
|
|
175
|
+
value: e.state.value,
|
|
176
|
+
onBlur: e.handleBlur,
|
|
177
|
+
onChange: (t) => e.handleChange(t.target.value)
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
}) : /* @__PURE__ */ G("dl", { children: /* @__PURE__ */ G(X, {
|
|
182
|
+
label: a("Alert email"),
|
|
183
|
+
value: o
|
|
184
|
+
}) })]
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
var ge = [
|
|
188
|
+
{
|
|
189
|
+
value: "generic",
|
|
190
|
+
label: "Generic (your own receiver)"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
value: "discord",
|
|
194
|
+
label: "Discord"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: "slack",
|
|
198
|
+
label: "Slack"
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
function _e({ webhooks: t, loading: n, edits: r }) {
|
|
202
|
+
return /* @__PURE__ */ K("section", {
|
|
203
|
+
className: "grid gap-5",
|
|
204
|
+
children: [/* @__PURE__ */ K("div", {
|
|
205
|
+
className: "flex flex-wrap items-start justify-between gap-4",
|
|
206
|
+
children: [/* @__PURE__ */ K("div", {
|
|
207
|
+
className: "grid max-w-2xl gap-1",
|
|
208
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
209
|
+
className: "text-base font-semibold",
|
|
210
|
+
children: /* @__PURE__ */ G(e, { id: "Webhooks" })
|
|
211
|
+
}), /* @__PURE__ */ G("p", {
|
|
212
|
+
className: "text-sm text-pretty text-muted-foreground",
|
|
213
|
+
children: /* @__PURE__ */ G(e, { id: "Send alerts to Discord, Slack, or your own endpoint." })
|
|
214
|
+
})]
|
|
215
|
+
}), r && /* @__PURE__ */ G(ye, {})]
|
|
216
|
+
}), n ? /* @__PURE__ */ G("p", {
|
|
217
|
+
className: "text-sm text-muted-foreground",
|
|
218
|
+
children: /* @__PURE__ */ G(e, { id: "Loading…" })
|
|
219
|
+
}) : t.length === 0 ? /* @__PURE__ */ G("p", {
|
|
220
|
+
className: "py-2 text-sm text-muted-foreground",
|
|
221
|
+
children: /* @__PURE__ */ G(e, { id: "No webhooks configured." })
|
|
222
|
+
}) : /* @__PURE__ */ K(j, {
|
|
223
|
+
className: "min-w-[36rem]",
|
|
224
|
+
children: [/* @__PURE__ */ G(O, { children: /* @__PURE__ */ K(A, {
|
|
225
|
+
className: "hover:bg-transparent",
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ G(E, {
|
|
228
|
+
className: "text-muted-foreground",
|
|
229
|
+
children: /* @__PURE__ */ G(e, { id: "Name" })
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ G(E, {
|
|
232
|
+
className: "text-muted-foreground",
|
|
233
|
+
children: /* @__PURE__ */ G(e, { id: "Format" })
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ G(E, {
|
|
236
|
+
className: "text-muted-foreground",
|
|
237
|
+
children: "URL"
|
|
238
|
+
}),
|
|
239
|
+
r && /* @__PURE__ */ G(E, {
|
|
240
|
+
className: "text-right text-muted-foreground",
|
|
241
|
+
children: /* @__PURE__ */ G(e, { id: "Action" })
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
}) }), /* @__PURE__ */ G(D, { children: t.map((e) => /* @__PURE__ */ G(ve, {
|
|
245
|
+
webhook: e,
|
|
246
|
+
edits: r
|
|
247
|
+
}, e.id)) })]
|
|
248
|
+
})]
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function ve({ webhook: n, edits: r }) {
|
|
252
|
+
let { toast: a, toastApiError: s, adminMutations: c } = i(), { text: l } = t(), [u, d] = B.useState(!1), f = U(), p = V(c.deleteWebhook(f)), m = n.name ?? n.destination_host;
|
|
253
|
+
return /* @__PURE__ */ K(A, {
|
|
254
|
+
className: n.enabled ? void 0 : "opacity-60",
|
|
255
|
+
children: [
|
|
256
|
+
/* @__PURE__ */ G(k, {
|
|
257
|
+
className: "py-3 font-medium",
|
|
258
|
+
children: m
|
|
259
|
+
}),
|
|
260
|
+
/* @__PURE__ */ G(k, {
|
|
261
|
+
className: "py-3",
|
|
262
|
+
children: /* @__PURE__ */ K("span", {
|
|
263
|
+
className: "flex flex-wrap gap-1",
|
|
264
|
+
children: [/* @__PURE__ */ G(y, {
|
|
265
|
+
variant: "secondary",
|
|
266
|
+
children: n.format
|
|
267
|
+
}), !n.enabled && /* @__PURE__ */ G(y, {
|
|
268
|
+
variant: "outline",
|
|
269
|
+
children: /* @__PURE__ */ G(e, { id: "disabled" })
|
|
270
|
+
})]
|
|
271
|
+
})
|
|
272
|
+
}),
|
|
273
|
+
/* @__PURE__ */ G(k, {
|
|
274
|
+
className: "max-w-[22rem] truncate py-3 text-xs text-muted-foreground",
|
|
275
|
+
title: n.destination_host,
|
|
276
|
+
children: n.destination_host
|
|
277
|
+
}),
|
|
278
|
+
r && /* @__PURE__ */ G(k, {
|
|
279
|
+
className: "py-3 text-right",
|
|
280
|
+
children: /* @__PURE__ */ K("div", {
|
|
281
|
+
className: "flex justify-end gap-1",
|
|
282
|
+
children: [
|
|
283
|
+
/* @__PURE__ */ G(ye, { webhook: n }),
|
|
284
|
+
/* @__PURE__ */ G(o, {
|
|
285
|
+
variant: "ghost",
|
|
286
|
+
size: "icon",
|
|
287
|
+
"aria-label": l("Delete webhook"),
|
|
288
|
+
onClick: () => d(!0),
|
|
289
|
+
children: /* @__PURE__ */ G(q, {
|
|
290
|
+
icon: de,
|
|
291
|
+
className: "size-4 text-muted-foreground"
|
|
292
|
+
})
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ G(ae, {
|
|
295
|
+
open: u,
|
|
296
|
+
onOpenChange: d,
|
|
297
|
+
title: `Delete "${m}"?`,
|
|
298
|
+
description: l("Operational notifications will stop delivering to this webhook. This cannot be undone."),
|
|
299
|
+
confirmationWord: "DELETE",
|
|
300
|
+
actionLabel: "Delete webhook",
|
|
301
|
+
onConfirm: async () => {
|
|
302
|
+
try {
|
|
303
|
+
await p.mutateAsync(n.id), a.success("Webhook deleted");
|
|
304
|
+
} catch (e) {
|
|
305
|
+
s(e, "Delete webhook");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
]
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
]
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function ye({ webhook: n }) {
|
|
316
|
+
let { toast: r, toastApiError: a, adminMutations: c } = i(), { id: l, text: u } = t(), [d, f] = B.useState(!1), p = U(), m = V(c.createWebhook(p)), h = V(c.updateWebhook(p)), g = () => ({
|
|
317
|
+
name: n?.name ?? "",
|
|
318
|
+
url: "",
|
|
319
|
+
format: n?.format ?? "generic",
|
|
320
|
+
enabled: n?.enabled ?? !0
|
|
321
|
+
}), _ = J({
|
|
322
|
+
defaultValues: g(),
|
|
323
|
+
onSubmit: async ({ value: e }) => {
|
|
324
|
+
let t = e.url.trim();
|
|
325
|
+
try {
|
|
326
|
+
n ? await h.mutateAsync({
|
|
327
|
+
id: n.id,
|
|
328
|
+
webhook: {
|
|
329
|
+
name: e.name.trim() || null,
|
|
330
|
+
format: e.format,
|
|
331
|
+
enabled: e.enabled,
|
|
332
|
+
...t ? { url: t } : {}
|
|
333
|
+
}
|
|
334
|
+
}) : await m.mutateAsync({
|
|
335
|
+
name: e.name.trim(),
|
|
336
|
+
url: t,
|
|
337
|
+
format: e.format
|
|
338
|
+
}), r.success(n ? "Webhook saved" : "Webhook added"), v(!1);
|
|
339
|
+
} catch (e) {
|
|
340
|
+
a(e, n ? "Save webhook" : "Add webhook");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}), v = (e) => {
|
|
344
|
+
e ? _.reset(g()) : _.reset(), f(e);
|
|
345
|
+
};
|
|
346
|
+
return /* @__PURE__ */ K(re, {
|
|
347
|
+
open: d,
|
|
348
|
+
onOpenChange: v,
|
|
349
|
+
children: [/* @__PURE__ */ G(ne, { render: /* @__PURE__ */ K(o, {
|
|
350
|
+
size: "sm",
|
|
351
|
+
variant: "outline",
|
|
352
|
+
children: [
|
|
353
|
+
!n && /* @__PURE__ */ G(q, {
|
|
354
|
+
icon: le,
|
|
355
|
+
className: "size-4"
|
|
356
|
+
}),
|
|
357
|
+
" ",
|
|
358
|
+
n ? "Edit" : "Add webhook"
|
|
359
|
+
]
|
|
360
|
+
}) }), /* @__PURE__ */ K(P, {
|
|
361
|
+
className: L,
|
|
362
|
+
children: [/* @__PURE__ */ K(M, { children: [/* @__PURE__ */ G(F, { children: n ? `Edit ${n.name ?? n.destination_host}` : "Add webhook" }), /* @__PURE__ */ G(te, { children: n ? "The current URL is never shown. Paste a new one to replace it, or leave it blank to keep it." : "Paste a webhook address from Discord, Slack, or your own alert receiver." })] }), /* @__PURE__ */ K("form", {
|
|
363
|
+
onSubmit: (e) => {
|
|
364
|
+
e.preventDefault(), e.stopPropagation(), _.handleSubmit();
|
|
365
|
+
},
|
|
366
|
+
className: "grid gap-4",
|
|
367
|
+
children: [/* @__PURE__ */ K("div", {
|
|
368
|
+
className: "grid gap-3",
|
|
369
|
+
children: [
|
|
370
|
+
/* @__PURE__ */ G(_.Field, {
|
|
371
|
+
name: "name",
|
|
372
|
+
validators: { onChange: ({ value: e }) => n || e.trim() ? void 0 : "Enter a webhook name" },
|
|
373
|
+
children: (t) => /* @__PURE__ */ K("div", {
|
|
374
|
+
className: "grid gap-1.5",
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ G(I, {
|
|
377
|
+
htmlFor: l("wh-name"),
|
|
378
|
+
children: /* @__PURE__ */ G(e, { id: "Name" })
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ G(s, {
|
|
381
|
+
id: l("wh-name"),
|
|
382
|
+
placeholder: u("e.g. #billing-alerts"),
|
|
383
|
+
value: t.state.value,
|
|
384
|
+
onBlur: t.handleBlur,
|
|
385
|
+
onChange: (e) => t.handleChange(e.target.value),
|
|
386
|
+
"aria-invalid": t.state.meta.errors.length > 0
|
|
387
|
+
}),
|
|
388
|
+
/* @__PURE__ */ G(b, { errors: t.state.meta.errors })
|
|
389
|
+
]
|
|
390
|
+
})
|
|
391
|
+
}),
|
|
392
|
+
/* @__PURE__ */ G(_.Field, {
|
|
393
|
+
name: "format",
|
|
394
|
+
children: (t) => /* @__PURE__ */ K("div", {
|
|
395
|
+
className: "grid gap-1.5",
|
|
396
|
+
children: [/* @__PURE__ */ G(I, {
|
|
397
|
+
htmlFor: l("wh-format"),
|
|
398
|
+
children: /* @__PURE__ */ G(e, { id: "Format" })
|
|
399
|
+
}), /* @__PURE__ */ K(T, {
|
|
400
|
+
value: t.state.value,
|
|
401
|
+
onValueChange: (e) => t.handleChange(e),
|
|
402
|
+
children: [/* @__PURE__ */ G(S, {
|
|
403
|
+
id: l("wh-format"),
|
|
404
|
+
className: "w-full",
|
|
405
|
+
children: /* @__PURE__ */ G(x, {})
|
|
406
|
+
}), /* @__PURE__ */ G(C, { children: ge.map((e) => /* @__PURE__ */ G(w, {
|
|
407
|
+
value: e.value,
|
|
408
|
+
children: e.label
|
|
409
|
+
}, e.value)) })]
|
|
410
|
+
})]
|
|
411
|
+
})
|
|
412
|
+
}),
|
|
413
|
+
/* @__PURE__ */ G(_.Field, {
|
|
414
|
+
name: "url",
|
|
415
|
+
validators: { onChange: ({ value: e }) => {
|
|
416
|
+
if (!e.trim()) return n ? void 0 : "Enter a webhook URL";
|
|
417
|
+
try {
|
|
418
|
+
new URL(e);
|
|
419
|
+
return;
|
|
420
|
+
} catch {
|
|
421
|
+
return "Enter a valid webhook URL";
|
|
422
|
+
}
|
|
423
|
+
} },
|
|
424
|
+
children: (t) => /* @__PURE__ */ K("div", {
|
|
425
|
+
className: "grid gap-1.5",
|
|
426
|
+
children: [
|
|
427
|
+
/* @__PURE__ */ G(I, {
|
|
428
|
+
htmlFor: l("wh-url"),
|
|
429
|
+
children: /* @__PURE__ */ G(e, { id: "Webhook URL" })
|
|
430
|
+
}),
|
|
431
|
+
/* @__PURE__ */ G(s, {
|
|
432
|
+
id: l("wh-url"),
|
|
433
|
+
type: "url",
|
|
434
|
+
autoComplete: "off",
|
|
435
|
+
className: "text-xs",
|
|
436
|
+
placeholder: n ? "unchanged" : "https://discord.com/api/webhooks/…",
|
|
437
|
+
value: t.state.value,
|
|
438
|
+
onBlur: t.handleBlur,
|
|
439
|
+
onChange: (e) => t.handleChange(e.target.value),
|
|
440
|
+
"aria-invalid": t.state.meta.errors.length > 0
|
|
441
|
+
}),
|
|
442
|
+
/* @__PURE__ */ G(b, { errors: t.state.meta.errors })
|
|
443
|
+
]
|
|
444
|
+
})
|
|
445
|
+
}),
|
|
446
|
+
n && /* @__PURE__ */ G(_.Field, {
|
|
447
|
+
name: "enabled",
|
|
448
|
+
children: (t) => /* @__PURE__ */ K("div", {
|
|
449
|
+
className: "flex items-center gap-2",
|
|
450
|
+
children: [/* @__PURE__ */ G(ie, {
|
|
451
|
+
id: l("wh-enabled"),
|
|
452
|
+
checked: t.state.value,
|
|
453
|
+
onCheckedChange: t.handleChange
|
|
454
|
+
}), /* @__PURE__ */ G(I, {
|
|
455
|
+
htmlFor: l("wh-enabled"),
|
|
456
|
+
children: /* @__PURE__ */ G(e, { id: "Enabled" })
|
|
457
|
+
})]
|
|
458
|
+
})
|
|
459
|
+
})
|
|
460
|
+
]
|
|
461
|
+
}), /* @__PURE__ */ G(N, { children: /* @__PURE__ */ G(_.Subscribe, {
|
|
462
|
+
selector: (e) => [
|
|
463
|
+
e.values.name,
|
|
464
|
+
e.values.url,
|
|
465
|
+
e.isDirty,
|
|
466
|
+
e.canSubmit,
|
|
467
|
+
e.isSubmitting
|
|
468
|
+
],
|
|
469
|
+
children: ([e, t, r, i, a]) => /* @__PURE__ */ G(o, {
|
|
470
|
+
type: "submit",
|
|
471
|
+
disabled: (n ? !r : !e.trim() || !t.trim()) || !i || a,
|
|
472
|
+
children: a ? "Saving…" : n ? "Save" : "Add webhook"
|
|
473
|
+
})
|
|
474
|
+
}) })]
|
|
475
|
+
})]
|
|
476
|
+
})]
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/admin/pages/settings/custody.tsx
|
|
481
|
+
function be() {
|
|
482
|
+
let e = i(), t = U(), n = l(), r = H(e.adminQueries.merchantConfiguration()), a = H(e.adminQueries.psps()), s = [...e.queryKeys.settings(), "custodians"], c = H({
|
|
483
|
+
queryKey: s,
|
|
484
|
+
queryFn: ({ signal: t }) => e.listCustodians(t)
|
|
485
|
+
}), [u, d] = B.useState(null), [f] = B.useState(() => e.selectedMerchant()), p = () => t.invalidateQueries({ queryKey: e.queryKeys.settings() }), m = V({
|
|
486
|
+
mutationFn: async ({ psp: t, custody: n }) => {
|
|
487
|
+
if (f !== e.selectedMerchant()) throw Error("Merchant changed; reopen settings");
|
|
488
|
+
let r = a.data?.data.find((e) => e.id === t);
|
|
489
|
+
if (!r) throw Error("PSP is no longer available");
|
|
490
|
+
return e.updatePSP(t, {
|
|
491
|
+
expected_revision: r.revision,
|
|
492
|
+
custodian: n
|
|
493
|
+
});
|
|
494
|
+
},
|
|
495
|
+
onSuccess: p,
|
|
496
|
+
onError: (t) => e.toastApiError(t, "Change card custody")
|
|
497
|
+
}), h = V({
|
|
498
|
+
mutationFn: async (t) => {
|
|
499
|
+
if (!r.data || f !== e.selectedMerchant()) throw Error("Merchant changed; reopen settings");
|
|
500
|
+
return e.updateMerchantConfiguration({
|
|
501
|
+
expected_revision: r.data.revision,
|
|
502
|
+
card_vault: String(t.get("card_vault") ?? ""),
|
|
503
|
+
charge_psps: t.getAll("charge_psps").map(String)
|
|
504
|
+
});
|
|
505
|
+
},
|
|
506
|
+
onSuccess: p,
|
|
507
|
+
onError: (t) => e.toastApiError(t, "Save card routing")
|
|
508
|
+
});
|
|
509
|
+
if (!r.data || !a.data || !c.data) return null;
|
|
510
|
+
let g = a.data.data.filter((e) => !e.archived && (e.rail === "nmi" || e.rail === "stripe"));
|
|
511
|
+
return /* @__PURE__ */ K("section", {
|
|
512
|
+
className: "grid gap-5",
|
|
513
|
+
"aria-label": "Card vaults",
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("h2", {
|
|
516
|
+
className: "text-base font-semibold",
|
|
517
|
+
children: "Card vaults"
|
|
518
|
+
}), /* @__PURE__ */ G("p", {
|
|
519
|
+
className: "text-sm text-muted-foreground",
|
|
520
|
+
children: "Choose where new cards are stored and which accounts charge them. Existing cards and subscriptions keep their accepted custody."
|
|
521
|
+
})] }),
|
|
522
|
+
/* @__PURE__ */ G("ul", {
|
|
523
|
+
className: "grid gap-2",
|
|
524
|
+
children: c.data.data.map((e) => /* @__PURE__ */ K("li", {
|
|
525
|
+
className: "flex flex-wrap items-center justify-between gap-3 rounded border p-3",
|
|
526
|
+
children: [/* @__PURE__ */ K("div", { children: [
|
|
527
|
+
/* @__PURE__ */ G("strong", { children: e.key }),
|
|
528
|
+
" · Basis Theory · ",
|
|
529
|
+
e.environment,
|
|
530
|
+
/* @__PURE__ */ G("br", {}),
|
|
531
|
+
/* @__PURE__ */ K("span", {
|
|
532
|
+
className: "text-sm text-muted-foreground",
|
|
533
|
+
children: [
|
|
534
|
+
e.account_id,
|
|
535
|
+
" ·",
|
|
536
|
+
" ",
|
|
537
|
+
e.credentials?.api_key?.configured ? "Credential configured" : "Credential missing"
|
|
538
|
+
]
|
|
539
|
+
})
|
|
540
|
+
] }), n && !e.archived && /* @__PURE__ */ G(o, {
|
|
541
|
+
size: "sm",
|
|
542
|
+
variant: "outline",
|
|
543
|
+
onClick: () => d(e),
|
|
544
|
+
children: "Edit vault"
|
|
545
|
+
})]
|
|
546
|
+
}, e.key))
|
|
547
|
+
}),
|
|
548
|
+
n && /* @__PURE__ */ G(o, {
|
|
549
|
+
className: "justify-self-start",
|
|
550
|
+
variant: "outline",
|
|
551
|
+
onClick: () => d("new"),
|
|
552
|
+
children: "Add Basis Theory vault"
|
|
553
|
+
}),
|
|
554
|
+
u && /* @__PURE__ */ G(xe, {
|
|
555
|
+
current: u === "new" ? void 0 : u,
|
|
556
|
+
close: () => d(null),
|
|
557
|
+
saved: p
|
|
558
|
+
}, u === "new" ? "new" : `${u.key}:${u.revision}`),
|
|
559
|
+
g.filter((e) => e.rail === "nmi").map((e) => /* @__PURE__ */ K(I, {
|
|
560
|
+
className: "grid gap-2",
|
|
561
|
+
children: [
|
|
562
|
+
e.key,
|
|
563
|
+
": card storage",
|
|
564
|
+
/* @__PURE__ */ K("select", {
|
|
565
|
+
className: "rounded border bg-background p-2",
|
|
566
|
+
"aria-label": `${e.key} card storage`,
|
|
567
|
+
disabled: !n || m.isPending,
|
|
568
|
+
value: e.custodian ?? "",
|
|
569
|
+
onChange: (t) => m.mutate({
|
|
570
|
+
psp: e.id,
|
|
571
|
+
custody: t.target.value
|
|
572
|
+
}),
|
|
573
|
+
children: [/* @__PURE__ */ G("option", {
|
|
574
|
+
value: "",
|
|
575
|
+
children: "NMI customer vault"
|
|
576
|
+
}), c.data.data.filter((t) => !t.archived && t.environment === e.environment).map((e) => /* @__PURE__ */ K("option", {
|
|
577
|
+
value: e.key,
|
|
578
|
+
children: [e.key, " · Basis Theory"]
|
|
579
|
+
}, e.key))]
|
|
580
|
+
})
|
|
581
|
+
]
|
|
582
|
+
}, e.id)),
|
|
583
|
+
/* @__PURE__ */ K("form", {
|
|
584
|
+
className: "grid gap-3",
|
|
585
|
+
onSubmit: (e) => {
|
|
586
|
+
e.preventDefault(), h.mutate(new FormData(e.currentTarget));
|
|
587
|
+
},
|
|
588
|
+
children: [
|
|
589
|
+
/* @__PURE__ */ K(I, {
|
|
590
|
+
className: "grid gap-2",
|
|
591
|
+
children: ["Vault for new cards", /* @__PURE__ */ K("select", {
|
|
592
|
+
name: "card_vault",
|
|
593
|
+
className: "rounded border bg-background p-2",
|
|
594
|
+
defaultValue: r.data.card_vault ?? "",
|
|
595
|
+
disabled: !n,
|
|
596
|
+
children: [
|
|
597
|
+
/* @__PURE__ */ G("option", {
|
|
598
|
+
value: "",
|
|
599
|
+
children: "No card vault selected"
|
|
600
|
+
}),
|
|
601
|
+
r.data.platform_vault.available && /* @__PURE__ */ G("option", {
|
|
602
|
+
value: "platform",
|
|
603
|
+
children: "Hosted vault · isolated to this merchant"
|
|
604
|
+
}),
|
|
605
|
+
g.map((e) => /* @__PURE__ */ K("option", {
|
|
606
|
+
value: e.key,
|
|
607
|
+
children: [
|
|
608
|
+
e.key,
|
|
609
|
+
" ·",
|
|
610
|
+
" ",
|
|
611
|
+
e.custodian ? "Basis Theory" : e.rail === "stripe" ? "Stripe" : "NMI customer vault"
|
|
612
|
+
]
|
|
613
|
+
}, e.id))
|
|
614
|
+
]
|
|
615
|
+
})]
|
|
616
|
+
}),
|
|
617
|
+
/* @__PURE__ */ K("fieldset", {
|
|
618
|
+
className: "grid gap-2",
|
|
619
|
+
disabled: !n,
|
|
620
|
+
children: [
|
|
621
|
+
/* @__PURE__ */ G("legend", {
|
|
622
|
+
className: "mb-2 font-medium",
|
|
623
|
+
children: "Charge PSPs"
|
|
624
|
+
}),
|
|
625
|
+
/* @__PURE__ */ G("p", {
|
|
626
|
+
className: "text-sm text-muted-foreground",
|
|
627
|
+
children: "Select the accounts allowed for new charges. With none selected, routing considers all eligible accounts."
|
|
628
|
+
}),
|
|
629
|
+
g.map((e) => /* @__PURE__ */ K(I, {
|
|
630
|
+
className: "flex gap-2",
|
|
631
|
+
children: [/* @__PURE__ */ G("input", {
|
|
632
|
+
type: "checkbox",
|
|
633
|
+
name: "charge_psps",
|
|
634
|
+
value: e.key,
|
|
635
|
+
defaultChecked: r.data?.charge_psps?.includes(e.key) ?? !1
|
|
636
|
+
}), e.key]
|
|
637
|
+
}, e.id))
|
|
638
|
+
]
|
|
639
|
+
}),
|
|
640
|
+
n && /* @__PURE__ */ G(o, {
|
|
641
|
+
className: "justify-self-start",
|
|
642
|
+
disabled: h.isPending,
|
|
643
|
+
type: "submit",
|
|
644
|
+
children: "Save card routing"
|
|
645
|
+
})
|
|
646
|
+
]
|
|
647
|
+
}, `routing:${r.data.revision}`)
|
|
648
|
+
]
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
function xe({ current: e, close: t, saved: n }) {
|
|
652
|
+
let r = i(), [a] = B.useState(() => r.selectedMerchant()), c = V({
|
|
653
|
+
mutationFn: async (t) => {
|
|
654
|
+
if (a !== r.selectedMerchant()) throw Error("Merchant changed; reopen this form");
|
|
655
|
+
let n = String(t.get("private_key") ?? "").trim();
|
|
656
|
+
return r.putCustodian(e?.key ?? String(t.get("key") ?? "").trim(), {
|
|
657
|
+
expected_revision: e?.revision ?? 0,
|
|
658
|
+
kind: "basis_theory",
|
|
659
|
+
environment: e?.environment ?? String(t.get("environment") ?? "test"),
|
|
660
|
+
account_id: e?.account_id ?? String(t.get("account_id") ?? "").trim(),
|
|
661
|
+
settings: {
|
|
662
|
+
...e?.settings ?? {},
|
|
663
|
+
public_api_key: String(t.get("public_key") ?? "").trim()
|
|
664
|
+
},
|
|
665
|
+
...n ? { credentials: { api_key: n } } : {}
|
|
666
|
+
});
|
|
667
|
+
},
|
|
668
|
+
onSuccess: async () => {
|
|
669
|
+
await n(), t();
|
|
670
|
+
},
|
|
671
|
+
onError: (e) => r.toastApiError(e, "Configure vault")
|
|
672
|
+
});
|
|
673
|
+
return /* @__PURE__ */ K("form", {
|
|
674
|
+
className: "grid gap-3 rounded border p-4",
|
|
675
|
+
onSubmit: (e) => {
|
|
676
|
+
e.preventDefault(), c.mutate(new FormData(e.currentTarget));
|
|
677
|
+
},
|
|
678
|
+
children: [
|
|
679
|
+
/* @__PURE__ */ G("h3", {
|
|
680
|
+
className: "font-medium",
|
|
681
|
+
children: e ? `Edit ${e.key}` : "Add Basis Theory vault"
|
|
682
|
+
}),
|
|
683
|
+
!e && /* @__PURE__ */ K(W, { children: [
|
|
684
|
+
/* @__PURE__ */ K(I, {
|
|
685
|
+
className: "grid gap-1",
|
|
686
|
+
children: ["Vault key", /* @__PURE__ */ G(s, {
|
|
687
|
+
name: "key",
|
|
688
|
+
required: !0,
|
|
689
|
+
pattern: "[a-z0-9_-]{1,63}"
|
|
690
|
+
})]
|
|
691
|
+
}),
|
|
692
|
+
/* @__PURE__ */ K(I, {
|
|
693
|
+
className: "grid gap-1",
|
|
694
|
+
children: ["Environment", /* @__PURE__ */ K("select", {
|
|
695
|
+
name: "environment",
|
|
696
|
+
className: "rounded border bg-background p-2",
|
|
697
|
+
children: [/* @__PURE__ */ G("option", {
|
|
698
|
+
value: "test",
|
|
699
|
+
children: "Test"
|
|
700
|
+
}), /* @__PURE__ */ G("option", {
|
|
701
|
+
value: "live",
|
|
702
|
+
children: "Live"
|
|
703
|
+
})]
|
|
704
|
+
})]
|
|
705
|
+
}),
|
|
706
|
+
/* @__PURE__ */ K(I, {
|
|
707
|
+
className: "grid gap-1",
|
|
708
|
+
children: ["Basis Theory tenant ID", /* @__PURE__ */ G(s, {
|
|
709
|
+
name: "account_id",
|
|
710
|
+
required: !0
|
|
711
|
+
})]
|
|
712
|
+
})
|
|
713
|
+
] }),
|
|
714
|
+
/* @__PURE__ */ K(I, {
|
|
715
|
+
className: "grid gap-1",
|
|
716
|
+
children: ["Public collection key", /* @__PURE__ */ G(s, {
|
|
717
|
+
name: "public_key",
|
|
718
|
+
required: !0,
|
|
719
|
+
defaultValue: String(e?.settings?.public_api_key ?? "")
|
|
720
|
+
})]
|
|
721
|
+
}),
|
|
722
|
+
/* @__PURE__ */ K(I, {
|
|
723
|
+
className: "grid gap-1",
|
|
724
|
+
children: ["Private API key", /* @__PURE__ */ G(s, {
|
|
725
|
+
type: "password",
|
|
726
|
+
name: "private_key",
|
|
727
|
+
autoComplete: "new-password",
|
|
728
|
+
required: !e
|
|
729
|
+
})]
|
|
730
|
+
}),
|
|
731
|
+
/* @__PURE__ */ G("p", {
|
|
732
|
+
className: "text-sm text-muted-foreground",
|
|
733
|
+
children: "Use a key that can read its application, manage the merchant’s card tokens and invoke the proxy. Existing credentials stay unchanged when left blank."
|
|
734
|
+
}),
|
|
735
|
+
/* @__PURE__ */ K("div", {
|
|
736
|
+
className: "flex gap-2",
|
|
737
|
+
children: [/* @__PURE__ */ G(o, {
|
|
738
|
+
type: "submit",
|
|
739
|
+
disabled: c.isPending,
|
|
740
|
+
children: "Validate and save vault"
|
|
741
|
+
}), /* @__PURE__ */ G(o, {
|
|
742
|
+
type: "button",
|
|
743
|
+
variant: "outline",
|
|
744
|
+
onClick: t,
|
|
745
|
+
children: "Cancel"
|
|
746
|
+
})]
|
|
747
|
+
})
|
|
748
|
+
]
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
//#endregion
|
|
752
|
+
//#region src/admin/pages/settings/index.tsx
|
|
753
|
+
var Q = "h-8 flex-none px-0 after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary pointer-coarse:h-10";
|
|
754
|
+
function Se() {
|
|
755
|
+
let [t, i] = r(), a = f(), o = u(), s = n().props.settingsTabs ?? [], c = s.map((e) => e.value), l = d(null, a, o, c), p = d(t.get("tab"), a, o, c);
|
|
756
|
+
return /* @__PURE__ */ K(ce, {
|
|
757
|
+
value: p,
|
|
758
|
+
onValueChange: (e) => {
|
|
759
|
+
let n = new URLSearchParams(t);
|
|
760
|
+
!e || e === l ? n.delete("tab") : n.set("tab", e), i(n);
|
|
761
|
+
},
|
|
762
|
+
className: "flex flex-col gap-4",
|
|
763
|
+
children: [
|
|
764
|
+
/* @__PURE__ */ G("div", {
|
|
765
|
+
className: "overflow-x-auto",
|
|
766
|
+
children: /* @__PURE__ */ K(se, {
|
|
767
|
+
variant: "line",
|
|
768
|
+
className: "w-max min-w-full justify-start gap-6 rounded-none p-0",
|
|
769
|
+
children: [
|
|
770
|
+
a && /* @__PURE__ */ G(R, {
|
|
771
|
+
value: "merchant",
|
|
772
|
+
className: Q,
|
|
773
|
+
children: /* @__PURE__ */ G(e, { id: "Merchant" })
|
|
774
|
+
}),
|
|
775
|
+
a && /* @__PURE__ */ G(R, {
|
|
776
|
+
value: "notifications",
|
|
777
|
+
className: Q,
|
|
778
|
+
children: /* @__PURE__ */ G(e, { id: "Notifications" })
|
|
779
|
+
}),
|
|
780
|
+
a && /* @__PURE__ */ G(R, {
|
|
781
|
+
value: "psps",
|
|
782
|
+
className: Q,
|
|
783
|
+
children: /* @__PURE__ */ G(e, { id: "PSPs" })
|
|
784
|
+
}),
|
|
785
|
+
o && /* @__PURE__ */ G(R, {
|
|
786
|
+
value: "customer-controls",
|
|
787
|
+
className: Q,
|
|
788
|
+
children: /* @__PURE__ */ G(e, { id: "Customer controls" })
|
|
789
|
+
}),
|
|
790
|
+
s.map((e) => /* @__PURE__ */ G(R, {
|
|
791
|
+
value: e.value,
|
|
792
|
+
className: Q,
|
|
793
|
+
children: e.title
|
|
794
|
+
}, e.value))
|
|
795
|
+
]
|
|
796
|
+
})
|
|
797
|
+
}),
|
|
798
|
+
a && /* @__PURE__ */ G(z, {
|
|
799
|
+
value: "merchant",
|
|
800
|
+
children: /* @__PURE__ */ G(Ce, {})
|
|
801
|
+
}),
|
|
802
|
+
a && /* @__PURE__ */ G(z, {
|
|
803
|
+
value: "notifications",
|
|
804
|
+
children: /* @__PURE__ */ G(me, {})
|
|
805
|
+
}),
|
|
806
|
+
a && /* @__PURE__ */ G(z, {
|
|
807
|
+
value: "psps",
|
|
808
|
+
children: /* @__PURE__ */ G(Ee, {})
|
|
809
|
+
}),
|
|
810
|
+
o && /* @__PURE__ */ G(z, {
|
|
811
|
+
value: "customer-controls",
|
|
812
|
+
children: /* @__PURE__ */ G(Re, {})
|
|
813
|
+
}),
|
|
814
|
+
s.map((e) => /* @__PURE__ */ G(z, {
|
|
815
|
+
value: e.value,
|
|
816
|
+
children: e.element
|
|
817
|
+
}, e.value))
|
|
818
|
+
]
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
function Ce() {
|
|
822
|
+
let { adminQueries: t } = i(), { data: n } = H(t.merchantConfiguration("Load settings")), r = l();
|
|
823
|
+
return n ? /* @__PURE__ */ K("div", {
|
|
824
|
+
className: "grid gap-10",
|
|
825
|
+
children: [
|
|
826
|
+
/* @__PURE__ */ G(fe, {}),
|
|
827
|
+
/* @__PURE__ */ G(we, {
|
|
828
|
+
configuration: n,
|
|
829
|
+
edits: r
|
|
830
|
+
}),
|
|
831
|
+
/* @__PURE__ */ G(Te, {
|
|
832
|
+
configuration: n,
|
|
833
|
+
edits: r
|
|
834
|
+
})
|
|
835
|
+
]
|
|
836
|
+
}) : /* @__PURE__ */ G("p", {
|
|
837
|
+
className: "text-sm text-muted-foreground",
|
|
838
|
+
children: /* @__PURE__ */ G(e, { id: "Loading…" })
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
function we({ configuration: n, edits: r }) {
|
|
842
|
+
let { id: i, text: a } = t(), o = n.profile, c = () => ({
|
|
843
|
+
displayName: n.display_name,
|
|
844
|
+
fromEmail: o?.from_email ?? "",
|
|
845
|
+
supportURL: o?.support_url ?? "",
|
|
846
|
+
subscribeURL: o?.subscribe_url ?? "",
|
|
847
|
+
billingURL: o?.billing_url ?? "",
|
|
848
|
+
logoURL: o?.logo_url ?? ""
|
|
849
|
+
}), l = Y(n), u = J({
|
|
850
|
+
defaultValues: c(),
|
|
851
|
+
onSubmit: ({ value: e }) => l.save({
|
|
852
|
+
display_name: e.displayName.trim(),
|
|
853
|
+
profile: {
|
|
854
|
+
from_email: e.fromEmail || void 0,
|
|
855
|
+
support_url: e.supportURL || void 0,
|
|
856
|
+
subscribe_url: e.subscribeURL || void 0,
|
|
857
|
+
billing_url: e.billingURL || void 0,
|
|
858
|
+
logo_url: e.logoURL || void 0
|
|
859
|
+
}
|
|
860
|
+
}, "Profile saved", "Save profile")
|
|
861
|
+
});
|
|
862
|
+
return /* @__PURE__ */ K("section", {
|
|
863
|
+
className: "grid gap-5",
|
|
864
|
+
children: [/* @__PURE__ */ K("div", {
|
|
865
|
+
className: "flex flex-wrap items-start justify-between gap-4",
|
|
866
|
+
children: [/* @__PURE__ */ K("div", {
|
|
867
|
+
className: "grid gap-1",
|
|
868
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
869
|
+
className: "text-base font-semibold",
|
|
870
|
+
children: /* @__PURE__ */ G(e, { id: "Merchant profile" })
|
|
871
|
+
}), /* @__PURE__ */ G("p", {
|
|
872
|
+
className: "text-sm text-pretty text-muted-foreground",
|
|
873
|
+
children: /* @__PURE__ */ G(e, { id: "Customer-facing merchant details used on invoices and emails." })
|
|
874
|
+
})]
|
|
875
|
+
}), /* @__PURE__ */ G(u.Subscribe, {
|
|
876
|
+
selector: (e) => [e.canSubmit, e.isSubmitting],
|
|
877
|
+
children: ([e, t]) => /* @__PURE__ */ G(pe, {
|
|
878
|
+
edits: r,
|
|
879
|
+
editing: l.editing,
|
|
880
|
+
form: "merchant-profile-form",
|
|
881
|
+
saving: t,
|
|
882
|
+
canSave: e,
|
|
883
|
+
onEdit: () => {
|
|
884
|
+
u.reset(c()), l.open();
|
|
885
|
+
},
|
|
886
|
+
onCancel: l.close
|
|
887
|
+
})
|
|
888
|
+
})]
|
|
889
|
+
}), l.editing ? /* @__PURE__ */ K("form", {
|
|
890
|
+
id: i("merchant-profile-form"),
|
|
891
|
+
onSubmit: (e) => {
|
|
892
|
+
e.preventDefault(), e.stopPropagation(), u.handleSubmit();
|
|
893
|
+
},
|
|
894
|
+
className: "grid gap-4",
|
|
895
|
+
children: [
|
|
896
|
+
/* @__PURE__ */ G(u.Field, {
|
|
897
|
+
name: "displayName",
|
|
898
|
+
validators: { onChange: ({ value: e }) => e.trim() ? void 0 : "Enter the merchant's name" },
|
|
899
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
900
|
+
label: a("Display name"),
|
|
901
|
+
id: "s-name",
|
|
902
|
+
children: /* @__PURE__ */ K("div", {
|
|
903
|
+
className: "grid gap-1.5",
|
|
904
|
+
children: [/* @__PURE__ */ G(s, {
|
|
905
|
+
id: i("s-name"),
|
|
906
|
+
value: e.state.value,
|
|
907
|
+
onBlur: e.handleBlur,
|
|
908
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
909
|
+
autoComplete: "organization",
|
|
910
|
+
"aria-invalid": e.state.meta.errors.length > 0
|
|
911
|
+
}), /* @__PURE__ */ G(b, { errors: e.state.meta.errors })]
|
|
912
|
+
})
|
|
913
|
+
})
|
|
914
|
+
}),
|
|
915
|
+
/* @__PURE__ */ G(u.Field, {
|
|
916
|
+
name: "fromEmail",
|
|
917
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
918
|
+
label: a("From email"),
|
|
919
|
+
id: "s-email",
|
|
920
|
+
children: /* @__PURE__ */ G(s, {
|
|
921
|
+
id: i("s-email"),
|
|
922
|
+
type: "email",
|
|
923
|
+
value: e.state.value,
|
|
924
|
+
onBlur: e.handleBlur,
|
|
925
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
926
|
+
autoComplete: "email"
|
|
927
|
+
})
|
|
928
|
+
})
|
|
929
|
+
}),
|
|
930
|
+
/* @__PURE__ */ G(u.Field, {
|
|
931
|
+
name: "supportURL",
|
|
932
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
933
|
+
label: a("Support URL"),
|
|
934
|
+
id: "s-support",
|
|
935
|
+
children: /* @__PURE__ */ G(s, {
|
|
936
|
+
id: i("s-support"),
|
|
937
|
+
type: "url",
|
|
938
|
+
value: e.state.value,
|
|
939
|
+
onBlur: e.handleBlur,
|
|
940
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
941
|
+
placeholder: a("https://example.com/support")
|
|
942
|
+
})
|
|
943
|
+
})
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ G(u.Field, {
|
|
946
|
+
name: "subscribeURL",
|
|
947
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
948
|
+
label: a("Subscribe URL"),
|
|
949
|
+
id: "s-subscribe",
|
|
950
|
+
children: /* @__PURE__ */ G(s, {
|
|
951
|
+
id: i("s-subscribe"),
|
|
952
|
+
type: "url",
|
|
953
|
+
value: e.state.value,
|
|
954
|
+
onBlur: e.handleBlur,
|
|
955
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
956
|
+
placeholder: a("https://example.com/subscribe")
|
|
957
|
+
})
|
|
958
|
+
})
|
|
959
|
+
}),
|
|
960
|
+
/* @__PURE__ */ G(u.Field, {
|
|
961
|
+
name: "billingURL",
|
|
962
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
963
|
+
label: a("Billing URL"),
|
|
964
|
+
id: "s-billing",
|
|
965
|
+
children: /* @__PURE__ */ G(s, {
|
|
966
|
+
id: i("s-billing"),
|
|
967
|
+
type: "url",
|
|
968
|
+
value: e.state.value,
|
|
969
|
+
onBlur: e.handleBlur,
|
|
970
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
971
|
+
placeholder: a("https://example.com/account")
|
|
972
|
+
})
|
|
973
|
+
})
|
|
974
|
+
}),
|
|
975
|
+
/* @__PURE__ */ G(u.Field, {
|
|
976
|
+
name: "logoURL",
|
|
977
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
978
|
+
label: a("Logo URL"),
|
|
979
|
+
id: "s-logo",
|
|
980
|
+
children: /* @__PURE__ */ G(s, {
|
|
981
|
+
id: i("s-logo"),
|
|
982
|
+
type: "url",
|
|
983
|
+
value: e.state.value,
|
|
984
|
+
onBlur: e.handleBlur,
|
|
985
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
986
|
+
placeholder: a("https://example.com/logo.png")
|
|
987
|
+
})
|
|
988
|
+
})
|
|
989
|
+
})
|
|
990
|
+
]
|
|
991
|
+
}) : /* @__PURE__ */ K("dl", {
|
|
992
|
+
className: "grid gap-4",
|
|
993
|
+
children: [
|
|
994
|
+
/* @__PURE__ */ G(X, {
|
|
995
|
+
label: a("Display name"),
|
|
996
|
+
value: n.display_name
|
|
997
|
+
}),
|
|
998
|
+
/* @__PURE__ */ G(X, {
|
|
999
|
+
label: a("From email"),
|
|
1000
|
+
value: o?.from_email
|
|
1001
|
+
}),
|
|
1002
|
+
/* @__PURE__ */ G(X, {
|
|
1003
|
+
label: a("Support URL"),
|
|
1004
|
+
value: o?.support_url
|
|
1005
|
+
}),
|
|
1006
|
+
/* @__PURE__ */ G(X, {
|
|
1007
|
+
label: a("Subscribe URL"),
|
|
1008
|
+
value: o?.subscribe_url
|
|
1009
|
+
}),
|
|
1010
|
+
/* @__PURE__ */ G(X, {
|
|
1011
|
+
label: a("Billing URL"),
|
|
1012
|
+
value: o?.billing_url
|
|
1013
|
+
}),
|
|
1014
|
+
/* @__PURE__ */ G(X, {
|
|
1015
|
+
label: a("Logo URL"),
|
|
1016
|
+
value: o?.logo_url
|
|
1017
|
+
})
|
|
1018
|
+
]
|
|
1019
|
+
})]
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
function Te({ configuration: n, edits: r }) {
|
|
1023
|
+
let { id: i, text: a } = t(), o = n.reprice_notice_window_days ?? 30, c = Y(n), l = J({
|
|
1024
|
+
defaultValues: { days: String(o) },
|
|
1025
|
+
onSubmit: ({ value: e }) => c.save({ reprice_notice_window_days: Number(e.days) }, "Notice window saved", "Save notice window")
|
|
1026
|
+
});
|
|
1027
|
+
return /* @__PURE__ */ K("section", {
|
|
1028
|
+
className: "grid gap-5",
|
|
1029
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1030
|
+
className: "flex flex-wrap items-start justify-between gap-4",
|
|
1031
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1032
|
+
className: "grid max-w-2xl gap-1",
|
|
1033
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
1034
|
+
className: "text-base font-semibold",
|
|
1035
|
+
children: /* @__PURE__ */ G(e, { id: "Pricing policies" })
|
|
1036
|
+
}), /* @__PURE__ */ G("p", {
|
|
1037
|
+
className: "text-sm text-pretty text-muted-foreground",
|
|
1038
|
+
children: /* @__PURE__ */ G(e, { id: "Set how much notice customers receive before a price increase." })
|
|
1039
|
+
})]
|
|
1040
|
+
}), /* @__PURE__ */ G(l.Subscribe, {
|
|
1041
|
+
selector: (e) => [e.canSubmit, e.isSubmitting],
|
|
1042
|
+
children: ([e, t]) => /* @__PURE__ */ G(pe, {
|
|
1043
|
+
edits: r,
|
|
1044
|
+
editing: c.editing,
|
|
1045
|
+
form: "notice-window-form",
|
|
1046
|
+
saving: t,
|
|
1047
|
+
canSave: e,
|
|
1048
|
+
onEdit: () => {
|
|
1049
|
+
l.reset({ days: String(o) }), c.open();
|
|
1050
|
+
},
|
|
1051
|
+
onCancel: c.close
|
|
1052
|
+
})
|
|
1053
|
+
})]
|
|
1054
|
+
}), c.editing ? /* @__PURE__ */ G("form", {
|
|
1055
|
+
id: i("notice-window-form"),
|
|
1056
|
+
onSubmit: (e) => {
|
|
1057
|
+
e.preventDefault(), e.stopPropagation(), l.handleSubmit();
|
|
1058
|
+
},
|
|
1059
|
+
children: /* @__PURE__ */ G(l.Field, {
|
|
1060
|
+
name: "days",
|
|
1061
|
+
validators: { onChange: ({ value: e }) => {
|
|
1062
|
+
let t = Number(e);
|
|
1063
|
+
return e.trim() && Number.isInteger(t) && t >= 0 ? void 0 : "Enter a whole number of days";
|
|
1064
|
+
} },
|
|
1065
|
+
children: (e) => /* @__PURE__ */ G(Z, {
|
|
1066
|
+
label: a("Notice period (days)"),
|
|
1067
|
+
id: "s-notice-window",
|
|
1068
|
+
children: /* @__PURE__ */ K("div", {
|
|
1069
|
+
className: "grid gap-1.5",
|
|
1070
|
+
children: [/* @__PURE__ */ G(s, {
|
|
1071
|
+
id: i("s-notice-window"),
|
|
1072
|
+
type: "number",
|
|
1073
|
+
step: "1",
|
|
1074
|
+
min: "0",
|
|
1075
|
+
value: e.state.value,
|
|
1076
|
+
onBlur: e.handleBlur,
|
|
1077
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
1078
|
+
"aria-invalid": e.state.meta.errors.length > 0
|
|
1079
|
+
}), /* @__PURE__ */ G(b, { errors: e.state.meta.errors })]
|
|
1080
|
+
})
|
|
1081
|
+
})
|
|
1082
|
+
})
|
|
1083
|
+
}) : /* @__PURE__ */ G("dl", { children: /* @__PURE__ */ G(X, {
|
|
1084
|
+
label: a("Notice period"),
|
|
1085
|
+
value: `${o} ${o === 1 ? "day" : "days"}`
|
|
1086
|
+
}) })]
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
function Ee() {
|
|
1090
|
+
let { selectedMerchant: t, adminQueries: n } = i(), r = H(n.psps()), a = H(n.rails()), o = l();
|
|
1091
|
+
if (r.isPending || a.isPending) return /* @__PURE__ */ G("p", {
|
|
1092
|
+
className: "text-sm text-muted-foreground",
|
|
1093
|
+
children: /* @__PURE__ */ G(e, { id: "Loading…" })
|
|
1094
|
+
});
|
|
1095
|
+
let s = a.data ?? [];
|
|
1096
|
+
return /* @__PURE__ */ K("div", {
|
|
1097
|
+
className: "grid gap-6",
|
|
1098
|
+
children: [
|
|
1099
|
+
/* @__PURE__ */ G(fe, {}),
|
|
1100
|
+
/* @__PURE__ */ K("section", {
|
|
1101
|
+
className: "grid gap-5",
|
|
1102
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1103
|
+
className: "flex flex-wrap items-start justify-between gap-4",
|
|
1104
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1105
|
+
className: "grid gap-1",
|
|
1106
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
1107
|
+
className: "text-base font-semibold",
|
|
1108
|
+
children: /* @__PURE__ */ G(e, { id: "PSPs" })
|
|
1109
|
+
}), /* @__PURE__ */ G("p", {
|
|
1110
|
+
className: "text-sm text-muted-foreground",
|
|
1111
|
+
children: /* @__PURE__ */ G(e, { id: "The accounts this merchant takes payments through, one or more per rail." })
|
|
1112
|
+
})]
|
|
1113
|
+
}), o && /* @__PURE__ */ G(Le, { railDefinitions: s }, t() ?? "")]
|
|
1114
|
+
}), r.data?.data?.length ? /* @__PURE__ */ K(j, {
|
|
1115
|
+
className: "min-w-[44rem]",
|
|
1116
|
+
children: [/* @__PURE__ */ G(O, { children: /* @__PURE__ */ K(A, {
|
|
1117
|
+
className: "hover:bg-transparent",
|
|
1118
|
+
children: [
|
|
1119
|
+
/* @__PURE__ */ G(E, {
|
|
1120
|
+
className: "text-muted-foreground",
|
|
1121
|
+
children: "PSP"
|
|
1122
|
+
}),
|
|
1123
|
+
/* @__PURE__ */ G(E, {
|
|
1124
|
+
className: "text-muted-foreground",
|
|
1125
|
+
children: /* @__PURE__ */ G(e, { id: "Environment" })
|
|
1126
|
+
}),
|
|
1127
|
+
/* @__PURE__ */ G(E, {
|
|
1128
|
+
className: "text-muted-foreground",
|
|
1129
|
+
children: /* @__PURE__ */ G(e, { id: "Credentials" })
|
|
1130
|
+
}),
|
|
1131
|
+
/* @__PURE__ */ G(E, {
|
|
1132
|
+
className: "text-muted-foreground",
|
|
1133
|
+
children: /* @__PURE__ */ G(e, { id: "State" })
|
|
1134
|
+
}),
|
|
1135
|
+
o && /* @__PURE__ */ G(E, {
|
|
1136
|
+
className: "text-right text-muted-foreground",
|
|
1137
|
+
children: /* @__PURE__ */ G(e, { id: "Action" })
|
|
1138
|
+
})
|
|
1139
|
+
]
|
|
1140
|
+
}) }), /* @__PURE__ */ G(D, { children: r.data.data.map((e) => /* @__PURE__ */ G(Oe, {
|
|
1141
|
+
psp: e,
|
|
1142
|
+
railDefinitions: s,
|
|
1143
|
+
edits: o
|
|
1144
|
+
}, e.id)) })]
|
|
1145
|
+
}) : /* @__PURE__ */ G("p", {
|
|
1146
|
+
className: "py-2 text-sm text-muted-foreground",
|
|
1147
|
+
children: /* @__PURE__ */ G(e, { id: "No PSPs configured." })
|
|
1148
|
+
})]
|
|
1149
|
+
}),
|
|
1150
|
+
/* @__PURE__ */ G(be, {})
|
|
1151
|
+
]
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
function De(e) {
|
|
1155
|
+
return e.validated_at ? `Validated ${h(e.validated_at)}` : e.configured ? "Configured" : "Not configured";
|
|
1156
|
+
}
|
|
1157
|
+
function Oe({ psp: n, railDefinitions: r, edits: s }) {
|
|
1158
|
+
let { toast: c, toastApiError: l, toastStaleEdit: u, adminMutations: d, selectedMerchant: f } = i(), { text: p } = t(), m = U(), h = V(d.updatePSP(m)), [g, _] = B.useState(!1), v = ee(), b = r.find((e) => e.rail === n.rail), x = b?.display_name ?? n.rail, S = n.credentials ?? {}, C = async (e) => {
|
|
1159
|
+
if (!(!e && !await v({
|
|
1160
|
+
title: `Archive ${n.key}?`,
|
|
1161
|
+
description: "New purchase stops routing to it. Existing subscriptions, refunds and webhooks keep using it.",
|
|
1162
|
+
confirmLabel: "Archive PSP"
|
|
1163
|
+
}))) try {
|
|
1164
|
+
await h.mutateAsync({
|
|
1165
|
+
id: n.id,
|
|
1166
|
+
psp: {
|
|
1167
|
+
archived: !0,
|
|
1168
|
+
expected_revision: n.revision,
|
|
1169
|
+
...e ? { allow_last: !0 } : {}
|
|
1170
|
+
}
|
|
1171
|
+
}), c.success("PSP archived");
|
|
1172
|
+
} catch (t) {
|
|
1173
|
+
if (t instanceof a && t.code === "psp_last_active") {
|
|
1174
|
+
e ? l(t, "Archive PSP") : _(!0);
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (t instanceof a && t.revisionMismatch) {
|
|
1178
|
+
u(`PSP ${n.key}`);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
l(t, "Archive PSP");
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
return /* @__PURE__ */ K(A, {
|
|
1185
|
+
className: n.archived ? "opacity-60" : void 0,
|
|
1186
|
+
children: [
|
|
1187
|
+
/* @__PURE__ */ G(k, {
|
|
1188
|
+
className: "py-3",
|
|
1189
|
+
children: /* @__PURE__ */ K("div", {
|
|
1190
|
+
className: "grid min-w-0 leading-tight",
|
|
1191
|
+
children: [/* @__PURE__ */ G("span", {
|
|
1192
|
+
className: "font-medium",
|
|
1193
|
+
children: n.key
|
|
1194
|
+
}), /* @__PURE__ */ K("span", {
|
|
1195
|
+
className: "truncate text-xs text-muted-foreground",
|
|
1196
|
+
children: [
|
|
1197
|
+
x,
|
|
1198
|
+
" · ",
|
|
1199
|
+
je(n)
|
|
1200
|
+
]
|
|
1201
|
+
})]
|
|
1202
|
+
})
|
|
1203
|
+
}),
|
|
1204
|
+
/* @__PURE__ */ G(k, {
|
|
1205
|
+
className: "py-3 capitalize",
|
|
1206
|
+
children: n.environment
|
|
1207
|
+
}),
|
|
1208
|
+
/* @__PURE__ */ G(k, {
|
|
1209
|
+
className: "py-3",
|
|
1210
|
+
children: Object.keys(S).length > 0 ? /* @__PURE__ */ G("span", {
|
|
1211
|
+
className: "flex flex-wrap gap-1",
|
|
1212
|
+
children: Object.entries(S).map(([e, t]) => /* @__PURE__ */ G(y, {
|
|
1213
|
+
variant: "secondary",
|
|
1214
|
+
className: t.configured ? "" : "bg-held-surface text-held",
|
|
1215
|
+
title: De(t),
|
|
1216
|
+
children: e
|
|
1217
|
+
}, e))
|
|
1218
|
+
}) : /* @__PURE__ */ G("span", {
|
|
1219
|
+
className: "text-sm text-muted-foreground",
|
|
1220
|
+
children: /* @__PURE__ */ G(e, { id: "None required" })
|
|
1221
|
+
})
|
|
1222
|
+
}),
|
|
1223
|
+
/* @__PURE__ */ G(k, {
|
|
1224
|
+
className: "py-3",
|
|
1225
|
+
children: n.archived && n.open_obligations === 0 ? /* @__PURE__ */ G(y, {
|
|
1226
|
+
variant: "secondary",
|
|
1227
|
+
children: /* @__PURE__ */ G(e, { id: "archived" })
|
|
1228
|
+
}) : n.archived ? /* @__PURE__ */ K(y, {
|
|
1229
|
+
variant: "secondary",
|
|
1230
|
+
className: "bg-held-surface text-held",
|
|
1231
|
+
children: [
|
|
1232
|
+
/* @__PURE__ */ G(e, { id: "draining (" }),
|
|
1233
|
+
n.open_obligations,
|
|
1234
|
+
")"
|
|
1235
|
+
]
|
|
1236
|
+
}) : /* @__PURE__ */ G(y, {
|
|
1237
|
+
variant: "secondary",
|
|
1238
|
+
className: "bg-settled-surface text-settled",
|
|
1239
|
+
children: /* @__PURE__ */ G(e, { id: "active" })
|
|
1240
|
+
})
|
|
1241
|
+
}),
|
|
1242
|
+
s && /* @__PURE__ */ G(k, {
|
|
1243
|
+
className: "py-3 text-right",
|
|
1244
|
+
children: !n.archived && /* @__PURE__ */ K("div", {
|
|
1245
|
+
className: "flex justify-end gap-2",
|
|
1246
|
+
children: [
|
|
1247
|
+
/* @__PURE__ */ G(ke, {
|
|
1248
|
+
psp: n,
|
|
1249
|
+
credentialKeys: b?.credential_keys ?? Object.keys(S)
|
|
1250
|
+
}, `${f() ?? ""}:${n.id}`),
|
|
1251
|
+
/* @__PURE__ */ G(o, {
|
|
1252
|
+
variant: "outline",
|
|
1253
|
+
size: "sm",
|
|
1254
|
+
disabled: h.isPending,
|
|
1255
|
+
onClick: () => C(!1),
|
|
1256
|
+
children: /* @__PURE__ */ G(e, { id: "Archive" })
|
|
1257
|
+
}),
|
|
1258
|
+
/* @__PURE__ */ G(ae, {
|
|
1259
|
+
open: g,
|
|
1260
|
+
onOpenChange: _,
|
|
1261
|
+
title: `Archive the last active ${x} PSP?`,
|
|
1262
|
+
description: p("New purchase on this rail is refused until another PSP is armed. Existing subscriptions, refunds and webhooks keep using this one."),
|
|
1263
|
+
confirmationWord: "ARCHIVE",
|
|
1264
|
+
actionLabel: "Archive PSP",
|
|
1265
|
+
onConfirm: () => C(!0)
|
|
1266
|
+
})
|
|
1267
|
+
]
|
|
1268
|
+
})
|
|
1269
|
+
})
|
|
1270
|
+
]
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
function ke({ psp: n, credentialKeys: r }) {
|
|
1274
|
+
let { toast: c, toastApiError: l, toastStaleEdit: u, adminMutations: d, selectedMerchant: f } = i(), { id: p } = t(), [m, g] = B.useState(!1), [_] = B.useState(() => f() ?? ""), v = B.useRef(n.revision), ee = U(), y = V(d.updatePSP(ee)), b = n.credentials ?? {}, x = J({
|
|
1275
|
+
defaultValues: { credentials: {} },
|
|
1276
|
+
onSubmit: async ({ value: e }) => {
|
|
1277
|
+
let t = Object.fromEntries(Object.entries(e.credentials).filter(([, e]) => e.trim()));
|
|
1278
|
+
try {
|
|
1279
|
+
if ((f() ?? "") !== _) throw Error("Merchant changed; reopen this form");
|
|
1280
|
+
await y.mutateAsync({
|
|
1281
|
+
id: n.id,
|
|
1282
|
+
psp: {
|
|
1283
|
+
expected_revision: v.current,
|
|
1284
|
+
credentials: t
|
|
1285
|
+
}
|
|
1286
|
+
}), c.success(`${n.key} credentials validated and rotated`), S(!1);
|
|
1287
|
+
} catch (e) {
|
|
1288
|
+
if (e instanceof a && e.revisionMismatch) {
|
|
1289
|
+
u(`PSP ${n.key}`), S(!1);
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
l(e, "Rotate credentials");
|
|
1293
|
+
} finally {
|
|
1294
|
+
y.reset();
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}), S = (e) => {
|
|
1298
|
+
e || x.reset(), e && (v.current = n.revision), g(e);
|
|
1299
|
+
};
|
|
1300
|
+
return /* @__PURE__ */ K(re, {
|
|
1301
|
+
open: m,
|
|
1302
|
+
onOpenChange: S,
|
|
1303
|
+
children: [/* @__PURE__ */ G(ne, { render: /* @__PURE__ */ G(o, {
|
|
1304
|
+
variant: "outline",
|
|
1305
|
+
size: "sm",
|
|
1306
|
+
children: /* @__PURE__ */ G(e, { id: "Rotate" })
|
|
1307
|
+
}) }), /* @__PURE__ */ K(P, {
|
|
1308
|
+
className: L,
|
|
1309
|
+
children: [/* @__PURE__ */ K(M, { children: [/* @__PURE__ */ K(F, { children: [
|
|
1310
|
+
/* @__PURE__ */ G(e, { id: "Rotate " }),
|
|
1311
|
+
n.key,
|
|
1312
|
+
/* @__PURE__ */ G(e, { id: " credentials · " }),
|
|
1313
|
+
je(n)
|
|
1314
|
+
] }), /* @__PURE__ */ G(te, { children: /* @__PURE__ */ G(e, { id: "Current credentials are never shown. A new one is validated against the live provider before it is stored; if that check fails, nothing is written. Leave a field blank to keep the credential it holds now." }) })] }), /* @__PURE__ */ K("form", {
|
|
1315
|
+
onSubmit: (e) => {
|
|
1316
|
+
e.preventDefault(), e.stopPropagation(), x.handleSubmit();
|
|
1317
|
+
},
|
|
1318
|
+
className: "grid gap-4",
|
|
1319
|
+
children: [/* @__PURE__ */ G(x.Field, {
|
|
1320
|
+
name: "credentials",
|
|
1321
|
+
children: (t) => /* @__PURE__ */ K("div", {
|
|
1322
|
+
className: "grid gap-3",
|
|
1323
|
+
children: [r.map((r) => {
|
|
1324
|
+
let i = b[r];
|
|
1325
|
+
return /* @__PURE__ */ K($, {
|
|
1326
|
+
label: r,
|
|
1327
|
+
id: `rot-${n.id}-${r}`,
|
|
1328
|
+
children: [/* @__PURE__ */ G(s, {
|
|
1329
|
+
id: p(`rot-${n.id}-${r}`),
|
|
1330
|
+
type: "password",
|
|
1331
|
+
autoComplete: "new-password",
|
|
1332
|
+
placeholder: i?.configured ? "unchanged" : "not configured",
|
|
1333
|
+
value: t.state.value[r] ?? "",
|
|
1334
|
+
onChange: (e) => t.handleChange({
|
|
1335
|
+
...t.state.value,
|
|
1336
|
+
[r]: e.target.value
|
|
1337
|
+
})
|
|
1338
|
+
}), i?.validated_at && /* @__PURE__ */ K("p", {
|
|
1339
|
+
className: "text-xs text-muted-foreground",
|
|
1340
|
+
children: [/* @__PURE__ */ G(e, { id: "Last validated " }), h(i.validated_at)]
|
|
1341
|
+
})]
|
|
1342
|
+
}, r);
|
|
1343
|
+
}), /* @__PURE__ */ G("p", {
|
|
1344
|
+
className: "text-xs text-muted-foreground",
|
|
1345
|
+
children: /* @__PURE__ */ G(e, { id: "Once this succeeds, the new credential is used for the next charge and every one after it. Previous webhook signing secrets remain accepted while their required overlap is active." })
|
|
1346
|
+
})]
|
|
1347
|
+
})
|
|
1348
|
+
}), /* @__PURE__ */ G(N, { children: /* @__PURE__ */ G(x.Subscribe, {
|
|
1349
|
+
selector: (e) => [e.values.credentials, e.isSubmitting],
|
|
1350
|
+
children: ([e, t]) => /* @__PURE__ */ G(o, {
|
|
1351
|
+
type: "submit",
|
|
1352
|
+
disabled: t || !Object.values(e).some((e) => e.trim()),
|
|
1353
|
+
children: t ? "Validating…" : "Validate & rotate"
|
|
1354
|
+
})
|
|
1355
|
+
}) })]
|
|
1356
|
+
})]
|
|
1357
|
+
})]
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
var Ae = {
|
|
1361
|
+
gateway_id: {
|
|
1362
|
+
label: "Gateway ID",
|
|
1363
|
+
hint: "The Gateway ID shown in your NMI dashboard."
|
|
1364
|
+
},
|
|
1365
|
+
account_id: {
|
|
1366
|
+
label: "Account ID",
|
|
1367
|
+
hint: "Your Stripe account ID. It starts with acct_."
|
|
1368
|
+
},
|
|
1369
|
+
client_accnum: {
|
|
1370
|
+
label: "Client account number",
|
|
1371
|
+
hint: "Your CCBill account number, such as 945280."
|
|
1372
|
+
},
|
|
1373
|
+
client_subacc: {
|
|
1374
|
+
label: "Client subaccount",
|
|
1375
|
+
hint: "Your CCBill subaccount number, such as 0000."
|
|
1376
|
+
},
|
|
1377
|
+
treasury: {
|
|
1378
|
+
label: "Treasury",
|
|
1379
|
+
hint: "The Solana address your payments land in."
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
function je(e) {
|
|
1383
|
+
return e.client_accnum ? `${e.client_accnum}-${e.client_subacc ?? ""}` : e.gateway_id ?? e.account_id ?? e.treasury ?? "";
|
|
1384
|
+
}
|
|
1385
|
+
var Me = {
|
|
1386
|
+
live: "Live: real money",
|
|
1387
|
+
test: "Test: the provider's own system, no money moves",
|
|
1388
|
+
sandbox: "Sandbox: the provider's separate sandbox",
|
|
1389
|
+
mainnet: "Mainnet: real money",
|
|
1390
|
+
devnet: "Devnet: Solana's development network",
|
|
1391
|
+
testnet: "Testnet: Solana's test network"
|
|
1392
|
+
}, Ne = {
|
|
1393
|
+
nmi: "NMI",
|
|
1394
|
+
ccbill: "CCBill",
|
|
1395
|
+
stripe: "Stripe",
|
|
1396
|
+
solana: "Solana"
|
|
1397
|
+
};
|
|
1398
|
+
function Pe(e, t) {
|
|
1399
|
+
let n = Ne[e] ?? e;
|
|
1400
|
+
return !t || t.toLowerCase() === n.toLowerCase() ? n : `${t} (${n})`;
|
|
1401
|
+
}
|
|
1402
|
+
var Fe = {
|
|
1403
|
+
api: "API",
|
|
1404
|
+
id: "ID",
|
|
1405
|
+
url: "URL"
|
|
1406
|
+
};
|
|
1407
|
+
function Ie(e) {
|
|
1408
|
+
return e.split(/[_-]+/).filter(Boolean).map((e, t) => Fe[e.toLowerCase()] || (t > 0 ? e.toLowerCase() : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase())).join(" ");
|
|
1409
|
+
}
|
|
1410
|
+
function Le({ railDefinitions: n }) {
|
|
1411
|
+
let { toast: r, toastApiError: a, adminMutations: c, selectedMerchant: l } = i(), { text: u, id: d } = t(), [f, p] = B.useState(!1), [m] = B.useState(() => l() ?? ""), h = U(), g = V(c.createPSP(h)), _ = J({
|
|
1412
|
+
defaultValues: {
|
|
1413
|
+
rail: "",
|
|
1414
|
+
environment: "",
|
|
1415
|
+
key: "",
|
|
1416
|
+
account: {},
|
|
1417
|
+
credentials: {}
|
|
1418
|
+
},
|
|
1419
|
+
onSubmit: async ({ value: e }) => {
|
|
1420
|
+
let t = Object.fromEntries(Object.entries(e.credentials).filter(([, e]) => e !== ""));
|
|
1421
|
+
try {
|
|
1422
|
+
if ((l() ?? "") !== m) throw Error("Merchant changed; reopen this form");
|
|
1423
|
+
let i = n.find((t) => t.rail === e.rail);
|
|
1424
|
+
await g.mutateAsync({
|
|
1425
|
+
key: e.key.trim().toLowerCase(),
|
|
1426
|
+
rail: e.rail,
|
|
1427
|
+
environment: e.environment,
|
|
1428
|
+
...Object.fromEntries((i?.account_fields ?? []).map((t) => [t, (e.account[t] ?? "").trim()])),
|
|
1429
|
+
...Object.keys(t).length ? { credentials: t } : {}
|
|
1430
|
+
}), _.reset(), r.success("PSP added"), p(!1);
|
|
1431
|
+
} catch (e) {
|
|
1432
|
+
a(e, "Add PSP");
|
|
1433
|
+
} finally {
|
|
1434
|
+
g.reset();
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
}), v = (e) => {
|
|
1438
|
+
e || _.reset(), p(e);
|
|
1439
|
+
};
|
|
1440
|
+
return /* @__PURE__ */ K(re, {
|
|
1441
|
+
open: f,
|
|
1442
|
+
onOpenChange: v,
|
|
1443
|
+
children: [/* @__PURE__ */ G(ne, { render: /* @__PURE__ */ G(o, {
|
|
1444
|
+
size: "sm",
|
|
1445
|
+
children: /* @__PURE__ */ G(e, { id: "Add PSP" })
|
|
1446
|
+
}) }), /* @__PURE__ */ K(P, {
|
|
1447
|
+
className: L,
|
|
1448
|
+
children: [/* @__PURE__ */ K(M, { children: [/* @__PURE__ */ G(F, { children: /* @__PURE__ */ G(e, { id: "Add a PSP" }) }), /* @__PURE__ */ G(te, { children: /* @__PURE__ */ G(e, { id: "Connect the account that will take money for you. Credentials go straight into the secret store and are never shown again." }) })] }), /* @__PURE__ */ K("form", {
|
|
1449
|
+
onSubmit: (e) => {
|
|
1450
|
+
e.preventDefault(), e.stopPropagation(), _.handleSubmit();
|
|
1451
|
+
},
|
|
1452
|
+
className: "grid gap-4",
|
|
1453
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1454
|
+
className: "grid gap-3",
|
|
1455
|
+
children: [
|
|
1456
|
+
/* @__PURE__ */ G(_.Field, {
|
|
1457
|
+
name: "rail",
|
|
1458
|
+
validators: { onChange: ({ value: e }) => e ? void 0 : "Choose a payment rail" },
|
|
1459
|
+
children: (e) => /* @__PURE__ */ K($, {
|
|
1460
|
+
label: u("Payment rail"),
|
|
1461
|
+
id: "pv-rail",
|
|
1462
|
+
children: [/* @__PURE__ */ K(T, {
|
|
1463
|
+
items: n.map((e) => ({
|
|
1464
|
+
value: e.rail,
|
|
1465
|
+
label: Pe(e.rail, e.display_name)
|
|
1466
|
+
})),
|
|
1467
|
+
value: e.state.value || null,
|
|
1468
|
+
onValueChange: (t) => {
|
|
1469
|
+
e.handleChange(t ?? ""), _.setFieldValue("account", {}), _.setFieldValue("credentials", {}), _.setFieldValue("environment", n.find((e) => e.rail === t)?.environments[0] ?? "");
|
|
1470
|
+
},
|
|
1471
|
+
children: [/* @__PURE__ */ G(S, {
|
|
1472
|
+
id: d("pv-rail"),
|
|
1473
|
+
className: "w-full",
|
|
1474
|
+
"aria-invalid": e.state.meta.errors.length > 0,
|
|
1475
|
+
children: /* @__PURE__ */ G(x, { placeholder: u("Pick a rail…") })
|
|
1476
|
+
}), /* @__PURE__ */ G(C, { children: n.map((e) => /* @__PURE__ */ G(w, {
|
|
1477
|
+
value: e.rail,
|
|
1478
|
+
children: Pe(e.rail, e.display_name)
|
|
1479
|
+
}, e.rail)) })]
|
|
1480
|
+
}), /* @__PURE__ */ G(b, { errors: e.state.meta.errors })]
|
|
1481
|
+
})
|
|
1482
|
+
}),
|
|
1483
|
+
/* @__PURE__ */ G(_.Subscribe, {
|
|
1484
|
+
selector: (e) => e.values.rail,
|
|
1485
|
+
children: (e) => {
|
|
1486
|
+
let t = n.find((t) => t.rail === e)?.environments ?? [];
|
|
1487
|
+
return /* @__PURE__ */ G(_.Field, {
|
|
1488
|
+
name: "environment",
|
|
1489
|
+
validators: { onChange: ({ value: e }) => e ? void 0 : "Choose whether it moves real money" },
|
|
1490
|
+
children: (n) => /* @__PURE__ */ K($, {
|
|
1491
|
+
label: u("Environment"),
|
|
1492
|
+
id: "pv-environment",
|
|
1493
|
+
hint: "Whether this PSP moves real money. It is checked with the provider before the PSP is used.",
|
|
1494
|
+
children: [/* @__PURE__ */ K(T, {
|
|
1495
|
+
items: t.map((e) => ({
|
|
1496
|
+
value: e,
|
|
1497
|
+
label: u(Me[e] ?? e)
|
|
1498
|
+
})),
|
|
1499
|
+
value: n.state.value || null,
|
|
1500
|
+
onValueChange: (e) => n.handleChange(e ?? ""),
|
|
1501
|
+
children: [/* @__PURE__ */ G(S, {
|
|
1502
|
+
id: d("pv-environment"),
|
|
1503
|
+
className: "w-full",
|
|
1504
|
+
disabled: !e,
|
|
1505
|
+
"aria-invalid": n.state.meta.errors.length > 0,
|
|
1506
|
+
children: /* @__PURE__ */ G(x, { placeholder: u("Pick an environment…") })
|
|
1507
|
+
}), /* @__PURE__ */ G(C, { children: t.map((e) => /* @__PURE__ */ G(w, {
|
|
1508
|
+
value: e,
|
|
1509
|
+
children: u(Me[e] ?? e)
|
|
1510
|
+
}, e)) })]
|
|
1511
|
+
}), /* @__PURE__ */ G(b, { errors: n.state.meta.errors })]
|
|
1512
|
+
})
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
}),
|
|
1516
|
+
/* @__PURE__ */ G(_.Field, {
|
|
1517
|
+
name: "key",
|
|
1518
|
+
validators: { onChange: ({ value: e }) => /^[a-z0-9][a-z0-9_-]{0,62}$/.test(e.trim().toLowerCase()) ? void 0 : "Lowercase letters, digits, - or _" },
|
|
1519
|
+
children: (e) => /* @__PURE__ */ K($, {
|
|
1520
|
+
label: u("Key"),
|
|
1521
|
+
id: "pv-key",
|
|
1522
|
+
hint: "Your name for this PSP, such as mobius. Prices and purchase name it by this key.",
|
|
1523
|
+
children: [/* @__PURE__ */ G(s, {
|
|
1524
|
+
id: d("pv-key"),
|
|
1525
|
+
value: e.state.value,
|
|
1526
|
+
onBlur: e.handleBlur,
|
|
1527
|
+
onChange: (t) => e.handleChange(t.target.value),
|
|
1528
|
+
"aria-invalid": e.state.meta.errors.length > 0
|
|
1529
|
+
}), /* @__PURE__ */ G(b, { errors: e.state.meta.errors })]
|
|
1530
|
+
})
|
|
1531
|
+
}),
|
|
1532
|
+
/* @__PURE__ */ G(_.Subscribe, {
|
|
1533
|
+
selector: (e) => e.values.rail,
|
|
1534
|
+
children: (e) => /* @__PURE__ */ G(_.Field, {
|
|
1535
|
+
name: "account",
|
|
1536
|
+
children: (t) => /* @__PURE__ */ G(W, { children: n.find((t) => t.rail === e)?.account_fields.map((e) => /* @__PURE__ */ G($, {
|
|
1537
|
+
label: u(Ae[e]?.label ?? Ie(e)),
|
|
1538
|
+
id: `pv-account-${e}`,
|
|
1539
|
+
hint: Ae[e]?.hint,
|
|
1540
|
+
children: /* @__PURE__ */ G(s, {
|
|
1541
|
+
id: d(`pv-account-${e}`),
|
|
1542
|
+
value: t.state.value[e] ?? "",
|
|
1543
|
+
onBlur: t.handleBlur,
|
|
1544
|
+
onChange: (n) => t.handleChange({
|
|
1545
|
+
...t.state.value,
|
|
1546
|
+
[e]: n.target.value
|
|
1547
|
+
})
|
|
1548
|
+
})
|
|
1549
|
+
}, e)) })
|
|
1550
|
+
})
|
|
1551
|
+
}),
|
|
1552
|
+
/* @__PURE__ */ G(_.Subscribe, {
|
|
1553
|
+
selector: (e) => e.values.rail,
|
|
1554
|
+
children: (e) => {
|
|
1555
|
+
let t = n.find((t) => t.rail === e);
|
|
1556
|
+
return /* @__PURE__ */ G(_.Field, {
|
|
1557
|
+
name: "credentials",
|
|
1558
|
+
children: (e) => /* @__PURE__ */ G(W, { children: t?.credential_keys.map((t) => /* @__PURE__ */ G($, {
|
|
1559
|
+
label: Ie(t),
|
|
1560
|
+
id: `pv-credential-${t}`,
|
|
1561
|
+
children: /* @__PURE__ */ G(s, {
|
|
1562
|
+
id: d(`pv-credential-${t}`),
|
|
1563
|
+
type: "password",
|
|
1564
|
+
autoComplete: "new-password",
|
|
1565
|
+
value: e.state.value[t] ?? "",
|
|
1566
|
+
onChange: (n) => e.handleChange({
|
|
1567
|
+
...e.state.value,
|
|
1568
|
+
[t]: n.target.value
|
|
1569
|
+
})
|
|
1570
|
+
})
|
|
1571
|
+
}, t)) })
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
})
|
|
1575
|
+
]
|
|
1576
|
+
}), /* @__PURE__ */ G(N, { children: /* @__PURE__ */ G(_.Subscribe, {
|
|
1577
|
+
selector: (e) => [
|
|
1578
|
+
e.values.rail,
|
|
1579
|
+
e.values.environment,
|
|
1580
|
+
e.values.key,
|
|
1581
|
+
e.values.account,
|
|
1582
|
+
e.canSubmit,
|
|
1583
|
+
e.isSubmitting
|
|
1584
|
+
],
|
|
1585
|
+
children: ([t, r, i, a, s, c]) => /* @__PURE__ */ K(W, { children: [/* @__PURE__ */ G(o, {
|
|
1586
|
+
type: "button",
|
|
1587
|
+
variant: "outline",
|
|
1588
|
+
onClick: () => v(!1),
|
|
1589
|
+
children: /* @__PURE__ */ G(e, { id: "Cancel" })
|
|
1590
|
+
}), /* @__PURE__ */ G(o, {
|
|
1591
|
+
type: "submit",
|
|
1592
|
+
disabled: !t || !r || !i.trim() || !n.find((e) => e.rail === t)?.account_fields.every((e) => (a[e] ?? "").trim()) || !s || c,
|
|
1593
|
+
children: c ? "Saving…" : "Add PSP"
|
|
1594
|
+
})] })
|
|
1595
|
+
}) })]
|
|
1596
|
+
})]
|
|
1597
|
+
})]
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
function Re() {
|
|
1601
|
+
let { toast: n, toastApiError: r, adminMutations: a, adminQueries: l } = i(), { text: u, id: d } = t(), [f, h] = B.useState(), ee = V(a.lookupCustomerControls()), y = V(a.setCreditLimit()), E = c(), D = J({
|
|
1602
|
+
defaultValues: { newLimit: "" },
|
|
1603
|
+
onSubmit: async ({ value: e }) => {
|
|
1604
|
+
if (!f) return;
|
|
1605
|
+
let t = m(f.currency), i = t === void 0 ? null : v(e.newLimit, t);
|
|
1606
|
+
if (!(i === null || i.startsWith("-"))) try {
|
|
1607
|
+
await y.mutateAsync({
|
|
1608
|
+
customerId: f.customerID,
|
|
1609
|
+
currency: f.currency,
|
|
1610
|
+
amount: i
|
|
1611
|
+
}), h((e) => e && {
|
|
1612
|
+
...e,
|
|
1613
|
+
creditLimit: i
|
|
1614
|
+
}), D.reset(), n.success("Credit limit updated");
|
|
1615
|
+
} catch (e) {
|
|
1616
|
+
r(e, "Set credit limit");
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}), [O, k] = B.useState(), { data: A } = H(l.merchantConfiguration()), j = [...new Set([
|
|
1620
|
+
...A?.usage_billing?.currencies ?? [],
|
|
1621
|
+
...O?.balances ?? [],
|
|
1622
|
+
...O?.settings.credit_limits ?? [],
|
|
1623
|
+
...O?.settings.trust_levels ?? []
|
|
1624
|
+
].map((e) => e.currency.toUpperCase()))].sort(), M = j.length ? j : Object.keys(p).sort(), N = J({
|
|
1625
|
+
defaultValues: { currency: "" },
|
|
1626
|
+
onSubmit: async ({ value: e }) => {
|
|
1627
|
+
let t = e.currency || M[0];
|
|
1628
|
+
if (!(!O || !t)) try {
|
|
1629
|
+
let e = await ee.mutateAsync({
|
|
1630
|
+
customerId: O.id,
|
|
1631
|
+
currency: t
|
|
1632
|
+
});
|
|
1633
|
+
h({
|
|
1634
|
+
customerID: O.id,
|
|
1635
|
+
...e
|
|
1636
|
+
}), D.reset();
|
|
1637
|
+
} catch (e) {
|
|
1638
|
+
r(e, "Lookup customer controls"), h(void 0);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}), P = (e) => {
|
|
1642
|
+
k(e), h(void 0), N.reset();
|
|
1643
|
+
};
|
|
1644
|
+
return /* @__PURE__ */ K("div", {
|
|
1645
|
+
className: "grid gap-10",
|
|
1646
|
+
children: [/* @__PURE__ */ K("section", {
|
|
1647
|
+
className: "grid gap-5",
|
|
1648
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1649
|
+
className: "grid gap-1",
|
|
1650
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
1651
|
+
className: "text-base font-semibold",
|
|
1652
|
+
children: /* @__PURE__ */ G(e, { id: "Customer lookup" })
|
|
1653
|
+
}), /* @__PURE__ */ G("p", {
|
|
1654
|
+
className: "text-sm text-muted-foreground",
|
|
1655
|
+
children: /* @__PURE__ */ G(e, { id: "Find a customer by name or email, then pick a currency." })
|
|
1656
|
+
})]
|
|
1657
|
+
}), /* @__PURE__ */ K("div", {
|
|
1658
|
+
className: "grid gap-4 md:grid-cols-[minmax(0,1fr)_10rem_auto] md:items-end",
|
|
1659
|
+
children: [/* @__PURE__ */ K("div", {
|
|
1660
|
+
className: "grid gap-1.5",
|
|
1661
|
+
children: [/* @__PURE__ */ G(I, { children: /* @__PURE__ */ G(e, { id: "Customer" }) }), O ? /* @__PURE__ */ K("span", {
|
|
1662
|
+
className: "inline-flex h-8 w-fit max-w-full items-center gap-1 rounded-md bg-muted pr-1 pl-2 text-sm font-medium",
|
|
1663
|
+
children: [/* @__PURE__ */ G("span", {
|
|
1664
|
+
className: "truncate",
|
|
1665
|
+
children: g(O)
|
|
1666
|
+
}), /* @__PURE__ */ G(o, {
|
|
1667
|
+
variant: "ghost",
|
|
1668
|
+
size: "icon",
|
|
1669
|
+
className: "size-5",
|
|
1670
|
+
"aria-label": u("Clear customer"),
|
|
1671
|
+
onClick: () => P(void 0),
|
|
1672
|
+
children: /* @__PURE__ */ G(q, {
|
|
1673
|
+
icon: ue,
|
|
1674
|
+
className: "size-3"
|
|
1675
|
+
})
|
|
1676
|
+
})]
|
|
1677
|
+
}) : /* @__PURE__ */ G(oe, { onPick: P })]
|
|
1678
|
+
}), /* @__PURE__ */ K("form", {
|
|
1679
|
+
onSubmit: (e) => {
|
|
1680
|
+
e.preventDefault(), e.stopPropagation(), N.handleSubmit();
|
|
1681
|
+
},
|
|
1682
|
+
className: "contents",
|
|
1683
|
+
children: [/* @__PURE__ */ G(N.Field, {
|
|
1684
|
+
name: "currency",
|
|
1685
|
+
children: (e) => /* @__PURE__ */ G($, {
|
|
1686
|
+
label: u("Currency"),
|
|
1687
|
+
id: "customer-controls-currency",
|
|
1688
|
+
children: /* @__PURE__ */ K(T, {
|
|
1689
|
+
items: M.map((e) => ({
|
|
1690
|
+
value: e,
|
|
1691
|
+
label: e
|
|
1692
|
+
})),
|
|
1693
|
+
value: e.state.value || M[0] || null,
|
|
1694
|
+
onValueChange: (t) => e.handleChange(t ?? ""),
|
|
1695
|
+
children: [/* @__PURE__ */ G(S, {
|
|
1696
|
+
id: d("customer-controls-currency"),
|
|
1697
|
+
className: "w-full",
|
|
1698
|
+
disabled: M.length === 0,
|
|
1699
|
+
children: /* @__PURE__ */ G(x, { placeholder: u(O ? "No currency yet" : "Pick a customer first") })
|
|
1700
|
+
}), /* @__PURE__ */ G(C, { children: M.map((e) => /* @__PURE__ */ G(w, {
|
|
1701
|
+
value: e,
|
|
1702
|
+
children: e
|
|
1703
|
+
}, e)) })]
|
|
1704
|
+
})
|
|
1705
|
+
})
|
|
1706
|
+
}), /* @__PURE__ */ G(N.Subscribe, {
|
|
1707
|
+
selector: (e) => e.isSubmitting,
|
|
1708
|
+
children: (e) => /* @__PURE__ */ G(o, {
|
|
1709
|
+
type: "submit",
|
|
1710
|
+
variant: "outline",
|
|
1711
|
+
disabled: !O || !M.length || e,
|
|
1712
|
+
children: e ? "Looking up…" : "Look up"
|
|
1713
|
+
})
|
|
1714
|
+
})]
|
|
1715
|
+
})]
|
|
1716
|
+
})]
|
|
1717
|
+
}), f && /* @__PURE__ */ K("section", {
|
|
1718
|
+
className: "grid gap-5",
|
|
1719
|
+
children: [
|
|
1720
|
+
/* @__PURE__ */ K("div", {
|
|
1721
|
+
className: "grid gap-1",
|
|
1722
|
+
children: [/* @__PURE__ */ G("h2", {
|
|
1723
|
+
className: "text-base font-semibold",
|
|
1724
|
+
children: /* @__PURE__ */ G(e, { id: "Credit and trust" })
|
|
1725
|
+
}), /* @__PURE__ */ K("p", {
|
|
1726
|
+
className: "text-sm text-muted-foreground",
|
|
1727
|
+
children: [
|
|
1728
|
+
/* @__PURE__ */ G("span", {
|
|
1729
|
+
className: "font-mono text-xs break-all text-foreground",
|
|
1730
|
+
children: f.customerID
|
|
1731
|
+
}),
|
|
1732
|
+
" ",
|
|
1733
|
+
"· ",
|
|
1734
|
+
f.currency.toUpperCase()
|
|
1735
|
+
]
|
|
1736
|
+
})]
|
|
1737
|
+
}),
|
|
1738
|
+
/* @__PURE__ */ K("dl", {
|
|
1739
|
+
className: "grid gap-4",
|
|
1740
|
+
children: [/* @__PURE__ */ G(X, {
|
|
1741
|
+
label: u("Trust level"),
|
|
1742
|
+
value: f.trustLevel || "Default"
|
|
1743
|
+
}), /* @__PURE__ */ G(X, {
|
|
1744
|
+
label: u("Credit limit"),
|
|
1745
|
+
value: f.creditLimit === "0" ? "Off" : _(f.creditLimit, f.currency)
|
|
1746
|
+
})]
|
|
1747
|
+
}),
|
|
1748
|
+
E && /* @__PURE__ */ G("form", {
|
|
1749
|
+
onSubmit: (e) => {
|
|
1750
|
+
e.preventDefault(), e.stopPropagation(), D.handleSubmit();
|
|
1751
|
+
},
|
|
1752
|
+
children: /* @__PURE__ */ G(Z, {
|
|
1753
|
+
label: `New limit (${f.currency.toUpperCase()})`,
|
|
1754
|
+
id: "customer-controls-limit",
|
|
1755
|
+
children: /* @__PURE__ */ G(D.Field, {
|
|
1756
|
+
name: "newLimit",
|
|
1757
|
+
validators: { onChange: ({ value: e }) => {
|
|
1758
|
+
let t = m(f.currency), n = t === void 0 ? null : v(e, t);
|
|
1759
|
+
return e !== "" && n !== null && !n.startsWith("-") ? void 0 : "Enter a valid amount";
|
|
1760
|
+
} },
|
|
1761
|
+
children: (t) => /* @__PURE__ */ K("div", {
|
|
1762
|
+
className: "grid gap-1.5",
|
|
1763
|
+
children: [
|
|
1764
|
+
/* @__PURE__ */ K("div", {
|
|
1765
|
+
className: "flex gap-2",
|
|
1766
|
+
children: [/* @__PURE__ */ G(s, {
|
|
1767
|
+
id: d("customer-controls-limit"),
|
|
1768
|
+
placeholder: "0.00",
|
|
1769
|
+
type: "number",
|
|
1770
|
+
step: "any",
|
|
1771
|
+
min: "0",
|
|
1772
|
+
value: t.state.value,
|
|
1773
|
+
onBlur: t.handleBlur,
|
|
1774
|
+
onChange: (e) => t.handleChange(e.target.value),
|
|
1775
|
+
"aria-invalid": t.state.meta.errors.length > 0
|
|
1776
|
+
}), /* @__PURE__ */ G(D.Subscribe, {
|
|
1777
|
+
selector: (e) => [
|
|
1778
|
+
e.values.newLimit,
|
|
1779
|
+
e.canSubmit,
|
|
1780
|
+
e.isSubmitting
|
|
1781
|
+
],
|
|
1782
|
+
children: ([e, t, n]) => /* @__PURE__ */ G(o, {
|
|
1783
|
+
type: "submit",
|
|
1784
|
+
disabled: !e || !t || n,
|
|
1785
|
+
children: n ? "Updating…" : "Update"
|
|
1786
|
+
})
|
|
1787
|
+
})]
|
|
1788
|
+
}),
|
|
1789
|
+
/* @__PURE__ */ G(b, { errors: t.state.meta.errors }),
|
|
1790
|
+
/* @__PURE__ */ G("p", {
|
|
1791
|
+
className: "text-xs text-muted-foreground",
|
|
1792
|
+
children: /* @__PURE__ */ G(e, { id: "Enter 0 to turn credit off." })
|
|
1793
|
+
})
|
|
1794
|
+
]
|
|
1795
|
+
})
|
|
1796
|
+
})
|
|
1797
|
+
})
|
|
1798
|
+
})
|
|
1799
|
+
]
|
|
1800
|
+
})]
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
function $({ label: e, id: n, hint: r, children: i }) {
|
|
1804
|
+
let { id: a } = t();
|
|
1805
|
+
return /* @__PURE__ */ K("div", {
|
|
1806
|
+
className: "grid gap-1.5",
|
|
1807
|
+
children: [
|
|
1808
|
+
/* @__PURE__ */ G(I, {
|
|
1809
|
+
htmlFor: a(n),
|
|
1810
|
+
children: e
|
|
1811
|
+
}),
|
|
1812
|
+
r ? /* @__PURE__ */ G("p", {
|
|
1813
|
+
className: "text-[13px] text-muted-foreground",
|
|
1814
|
+
children: r
|
|
1815
|
+
}) : null,
|
|
1816
|
+
i
|
|
1817
|
+
]
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
//#endregion
|
|
1821
|
+
export { Se as SettingsPage };
|
|
1822
|
+
|
|
1823
|
+
//# sourceMappingURL=admin-settings-DscHu4ww.js.map
|