@openrails/billing-ui 0.268.2 → 0.269.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/context.d.ts +164 -62
- package/dist/admin/lib/api/endpoints.d.ts +3 -7
- package/dist/admin/lib/api/import-endpoints.d.ts +44 -0
- package/dist/admin/lib/api/index.d.ts +17 -7
- package/dist/admin/lib/api/types.d.ts +0 -29
- package/dist/admin/lib/import-queries.d.ts +66 -0
- package/dist/admin/lib/mutations.d.ts +1 -5
- package/dist/admin/lib/queries.d.ts +6 -20
- package/dist/admin/messages.d.ts +176 -6
- package/dist/admin/pages/catalog/index.d.ts +0 -1
- package/dist/admin/pages/imports/detail.d.ts +2 -0
- package/dist/admin/pages/imports/index.d.ts +2 -0
- package/dist/admin/pages/imports/mapping-csv.d.ts +10 -0
- package/dist/admin/pages/imports/progress.d.ts +21 -0
- package/dist/admin/pages/imports/records.d.ts +2 -0
- package/dist/admin/pages/imports/shared.d.ts +22 -0
- package/dist/admin/pages/parked/index.d.ts +2 -0
- package/dist/admin/pages/proposals/grouping.d.ts +13 -0
- package/dist/admin/pages/proposals/index.d.ts +2 -0
- package/dist/admin/pages/provider-prices/index.d.ts +2 -0
- package/dist/admin/pages/provider-prices/map-dialog.d.ts +11 -0
- package/dist/admin/routes.d.ts +1 -1
- package/dist/{admin-attempts-BLeeKABa.js → admin-attempts-DQTg0UzZ.js} +82 -82
- package/dist/{admin-attempts-BLeeKABa.js.map → admin-attempts-DQTg0UzZ.js.map} +1 -1
- package/dist/{admin-auth-DWVWxDup.js → admin-auth-1aZIgXiS.js} +2 -2
- package/dist/{admin-auth-DWVWxDup.js.map → admin-auth-1aZIgXiS.js.map} +1 -1
- package/dist/{admin-badge-CrEqD9Ew.js → admin-badge-pgG6D9-a.js} +2 -2
- package/dist/{admin-badge-CrEqD9Ew.js.map → admin-badge-pgG6D9-a.js.map} +1 -1
- package/dist/{admin-button-a7bDFgp0.js → admin-button-CrcYk5r0.js} +2 -2
- package/dist/{admin-button-a7bDFgp0.js.map → admin-button-CrcYk5r0.js.map} +1 -1
- package/dist/{admin-capabilities-QYUuJXvG.js → admin-capabilities-BDcZeHL_.js} +2 -2
- package/dist/{admin-capabilities-QYUuJXvG.js.map → admin-capabilities-BDcZeHL_.js.map} +1 -1
- package/dist/{admin-card-D1tz8Lbh.js → admin-card-DvTMc5Se.js} +2 -2
- package/dist/{admin-card-D1tz8Lbh.js.map → admin-card-DvTMc5Se.js.map} +1 -1
- package/dist/{admin-catalog-ggiDgWsR.js → admin-catalog-BlF5mnu4.js} +285 -382
- package/dist/admin-catalog-BlF5mnu4.js.map +1 -0
- package/dist/{admin-dom-VkcwevWr.js → admin-cursor-pager-CIb3Jw2F.js} +20 -25
- package/dist/admin-cursor-pager-CIb3Jw2F.js.map +1 -0
- package/dist/{admin-customers-BVMg-gUv.js → admin-customers-EpfoWDh-.js} +13 -13
- package/dist/{admin-customers-BVMg-gUv.js.map → admin-customers-EpfoWDh-.js.map} +1 -1
- package/dist/{admin-dashboard-Cc13i8i9.js → admin-dashboard-CJE63yz4.js} +46 -46
- package/dist/{admin-dashboard-Cc13i8i9.js.map → admin-dashboard-CJE63yz4.js.map} +1 -1
- package/dist/{admin-data-table-BL84xKKF.js → admin-data-table-hvFcJepL.js} +16 -16
- package/dist/{admin-data-table-BL84xKKF.js.map → admin-data-table-hvFcJepL.js.map} +1 -1
- package/dist/{admin-detail-CaEwBdX9.js → admin-detail-BRP6pL7t.js} +51 -51
- package/dist/{admin-detail-CaEwBdX9.js.map → admin-detail-BRP6pL7t.js.map} +1 -1
- package/dist/{admin-detail-9YAep3ts.js → admin-detail-CRzFb_pa.js} +232 -232
- package/dist/{admin-detail-9YAep3ts.js.map → admin-detail-CRzFb_pa.js.map} +1 -1
- package/dist/admin-detail-Ceod8AXy.js +299 -0
- package/dist/admin-detail-Ceod8AXy.js.map +1 -0
- package/dist/{admin-detail-C8t5jBps.js → admin-detail-QLxU8r-5.js} +62 -62
- package/dist/{admin-detail-C8t5jBps.js.map → admin-detail-QLxU8r-5.js.map} +1 -1
- package/dist/admin-detail-pPC8Q9l-.js +710 -0
- package/dist/{admin-detail-D2zcz_Xm.js.map → admin-detail-pPC8Q9l-.js.map} +1 -1
- package/dist/{admin-dialog-CiAw5vx-.js → admin-dialog-BSRf9Zre.js} +24 -24
- package/dist/{admin-dialog-CiAw5vx-.js.map → admin-dialog-BSRf9Zre.js.map} +1 -1
- package/dist/admin-dom-C7Y7A6Wa.js +8 -0
- package/dist/admin-dom-C7Y7A6Wa.js.map +1 -0
- package/dist/{admin-dropdown-menu-CYJbmqK2.js → admin-dropdown-menu-D0E5rwmn.js} +2 -2
- package/dist/{admin-dropdown-menu-CYJbmqK2.js.map → admin-dropdown-menu-D0E5rwmn.js.map} +1 -1
- package/dist/{admin-fact-card-BHTpDlaX.js → admin-fact-card-BPSVhS15.js} +2 -2
- package/dist/{admin-fact-card-BHTpDlaX.js.map → admin-fact-card-BPSVhS15.js.map} +1 -1
- package/dist/{admin-health-BUnjbvYR.js → admin-health-D0L5Kig7.js} +84 -84
- package/dist/{admin-health-BUnjbvYR.js.map → admin-health-D0L5Kig7.js.map} +1 -1
- package/dist/admin-imports-TCOljTgw.js +269 -0
- package/dist/admin-imports-TCOljTgw.js.map +1 -0
- package/dist/{admin-input-C-S_RGGo.js → admin-input-DJAK9nmk.js} +2 -2
- package/dist/{admin-input-C-S_RGGo.js.map → admin-input-DJAK9nmk.js.map} +1 -1
- package/dist/{admin-label-DPVYDdSO.js → admin-label-aviN9Gng.js} +2 -2
- package/dist/{admin-label-DPVYDdSO.js.map → admin-label-aviN9Gng.js.map} +1 -1
- package/dist/{admin-linked-table-row-D-gbTT7a.js → admin-linked-table-row-BGr7JXeM.js} +6 -6
- package/dist/{admin-linked-table-row-D-gbTT7a.js.map → admin-linked-table-row-BGr7JXeM.js.map} +1 -1
- package/dist/admin-map-dialog-DpGaIq52.js +135 -0
- package/dist/admin-map-dialog-DpGaIq52.js.map +1 -0
- package/dist/admin-mapping-csv-FtkyTBmk.js +56 -0
- package/dist/admin-mapping-csv-FtkyTBmk.js.map +1 -0
- package/dist/{admin-metering-BjbL0jjT.js → admin-metering-D-e-37Jn.js} +285 -285
- package/dist/{admin-metering-BjbL0jjT.js.map → admin-metering-D-e-37Jn.js.map} +1 -1
- package/dist/admin-ops-CQP4TzWM.js +235 -0
- package/dist/admin-ops-CQP4TzWM.js.map +1 -0
- package/dist/{admin-orders-BVW9-Fs9.js → admin-orders-BJ7W5S8P.js} +32 -32
- package/dist/{admin-orders-BVW9-Fs9.js.map → admin-orders-BJ7W5S8P.js.map} +1 -1
- package/dist/admin-parked-7HL8mOjw.js +193 -0
- package/dist/admin-parked-7HL8mOjw.js.map +1 -0
- package/dist/{admin-payments-C5MsFFmm.js → admin-payments-CzkzqYA1.js} +17 -17
- package/dist/{admin-payments-C5MsFFmm.js.map → admin-payments-CzkzqYA1.js.map} +1 -1
- package/dist/{admin-price-detail-D517JYHB.js → admin-price-detail-CSI5oKdb.js} +74 -74
- package/dist/{admin-price-detail-D517JYHB.js.map → admin-price-detail-CSI5oKdb.js.map} +1 -1
- package/dist/{admin-price-wizard-bj36o3ux.js → admin-price-wizard-CBEcNGvP.js} +38 -38
- package/dist/{admin-price-wizard-bj36o3ux.js.map → admin-price-wizard-CBEcNGvP.js.map} +1 -1
- package/dist/admin-proposals-dtgijWKz.js +375 -0
- package/dist/admin-proposals-dtgijWKz.js.map +1 -0
- package/dist/admin-provider-prices-ChuponcZ.js +246 -0
- package/dist/admin-provider-prices-ChuponcZ.js.map +1 -0
- package/dist/{admin-range-picker-D2aFF8IV.js → admin-range-picker-De36L-AP.js} +12 -12
- package/dist/{admin-range-picker-D2aFF8IV.js.map → admin-range-picker-De36L-AP.js.map} +1 -1
- package/dist/admin-records-CUHUOXAU.js +391 -0
- package/dist/admin-records-CUHUOXAU.js.map +1 -0
- package/dist/{admin-reports-D-ob04d4.js → admin-reports-BFGS_PWf.js} +45 -45
- package/dist/{admin-reports-D-ob04d4.js.map → admin-reports-BFGS_PWf.js.map} +1 -1
- package/dist/{admin-select-C8O7nx72.js → admin-select-BUcEU5Rg.js} +2 -2
- package/dist/{admin-select-C8O7nx72.js.map → admin-select-BUcEU5Rg.js.map} +1 -1
- package/dist/{admin-settings-Bs6cLcqi.js → admin-settings-DYC-c7mJ.js} +296 -296
- package/dist/{admin-settings-Bs6cLcqi.js.map → admin-settings-DYC-c7mJ.js.map} +1 -1
- package/dist/admin-shared-CzG8Pan3.js +222 -0
- package/dist/admin-shared-CzG8Pan3.js.map +1 -0
- package/dist/{admin-skeleton-wfocg2PJ.js → admin-skeleton-B0yzYY_X.js} +2 -2
- package/dist/{admin-skeleton-wfocg2PJ.js.map → admin-skeleton-B0yzYY_X.js.map} +1 -1
- package/dist/{admin-status-badge-D_gDMrht.js → admin-status-badge-0-K37EfN.js} +7 -2
- package/dist/admin-status-badge-0-K37EfN.js.map +1 -0
- package/dist/{admin-subscriptions-DYR1RGMO.js → admin-subscriptions-CvW-YFs0.js} +74 -74
- package/dist/{admin-subscriptions-DYR1RGMO.js.map → admin-subscriptions-CvW-YFs0.js.map} +1 -1
- package/dist/{admin-switch-F5D0AYjT.js → admin-switch-DDorugaw.js} +2 -2
- package/dist/{admin-switch-F5D0AYjT.js.map → admin-switch-DDorugaw.js.map} +1 -1
- package/dist/{admin-table-nUij5fLc.js → admin-table-BU6Tie69.js} +2 -2
- package/dist/{admin-table-nUij5fLc.js.map → admin-table-BU6Tie69.js.map} +1 -1
- package/dist/{admin-tabs-C3myjKdr.js → admin-tabs-D5lqdVcC.js} +2 -2
- package/dist/{admin-tabs-C3myjKdr.js.map → admin-tabs-D5lqdVcC.js.map} +1 -1
- package/dist/{admin-textarea-v-L-PXIc.js → admin-textarea-Dc6lnEub.js} +2 -2
- package/dist/{admin-textarea-v-L-PXIc.js.map → admin-textarea-Dc6lnEub.js.map} +1 -1
- package/dist/{admin-typed-confirm-dialog-BLgpuikW.js → admin-typed-confirm-dialog-Bk6XxmPb.js} +6 -6
- package/dist/{admin-typed-confirm-dialog-BLgpuikW.js.map → admin-typed-confirm-dialog-Bk6XxmPb.js.map} +1 -1
- package/dist/{admin-utils-6yE4YIVI.js → admin-utils-B9eEBNsR.js} +398 -146
- package/dist/admin-utils-B9eEBNsR.js.map +1 -0
- package/dist/{admin-widget-viz-BiEfckd4.js → admin-widget-viz-8aukE3v_.js} +34 -34
- package/dist/{admin-widget-viz-BiEfckd4.js.map → admin-widget-viz-8aukE3v_.js.map} +1 -1
- package/dist/admin.css +1 -1
- package/dist/admin.js +489 -264
- package/dist/admin.js.map +1 -1
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +94 -22
- package/dist/client/generated/wire.d.ts +89 -14
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/dist/admin-catalog-ggiDgWsR.js.map +0 -1
- package/dist/admin-detail-D2zcz_Xm.js +0 -710
- package/dist/admin-dom-VkcwevWr.js.map +0 -1
- package/dist/admin-ops-DT8epiXg.js +0 -217
- package/dist/admin-ops-DT8epiXg.js.map +0 -1
- package/dist/admin-status-badge-D_gDMrht.js.map +0 -1
- package/dist/admin-utils-6yE4YIVI.js.map +0 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as a } from "./admin-button-
|
|
3
|
-
import { t as o } from "./admin-input-
|
|
4
|
-
import { t as s } from "./admin-skeleton-
|
|
5
|
-
import {
|
|
6
|
-
import { c as
|
|
7
|
-
import { t as
|
|
8
|
-
import { a as
|
|
9
|
-
import { n as
|
|
10
|
-
import { a as
|
|
11
|
-
import { t as ee } from "./admin-linked-table-row-
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as te } from "./admin-status-badge-
|
|
14
|
-
import { a as
|
|
15
|
-
import { t as
|
|
16
|
-
import { t as ne } from "./admin-switch-
|
|
1
|
+
import { C as e, D as t, T as n, p as r, r as i } from "./admin-utils-B9eEBNsR.js";
|
|
2
|
+
import { t as a } from "./admin-button-CrcYk5r0.js";
|
|
3
|
+
import { t as o } from "./admin-input-DJAK9nmk.js";
|
|
4
|
+
import { t as s } from "./admin-skeleton-B0yzYY_X.js";
|
|
5
|
+
import { r as c, s as l } from "./admin-capabilities-BDcZeHL_.js";
|
|
6
|
+
import { c as u, d, n as f, o as p, s as m, u as h } from "./admin-format-DoohJ7Fg.js";
|
|
7
|
+
import { t as g } from "./admin-form-field-errors-hbUMIriS.js";
|
|
8
|
+
import { a as _, i as v, n as y, r as b, t as x } from "./admin-select-BUcEU5Rg.js";
|
|
9
|
+
import { n as S, t as C } from "./admin-cursor-pager-CIb3Jw2F.js";
|
|
10
|
+
import { a as w, n as T, o as E, r as D, s as O, t as k } from "./admin-table-BU6Tie69.js";
|
|
11
|
+
import { t as ee } from "./admin-linked-table-row-BGr7JXeM.js";
|
|
12
|
+
import { t as A } from "./admin-badge-pgG6D9-a.js";
|
|
13
|
+
import { t as te } from "./admin-status-badge-0-K37EfN.js";
|
|
14
|
+
import { a as j, i as M, n as N, o as P, r as F, s as I, t as L } from "./admin-dialog-BSRf9Zre.js";
|
|
15
|
+
import { t as R } from "./admin-label-aviN9Gng.js";
|
|
16
|
+
import { t as ne } from "./admin-switch-DDorugaw.js";
|
|
17
17
|
import { n as re, r as ie } from "./admin-dialog-width-BPrgdYlj.js";
|
|
18
|
-
import { i as
|
|
19
|
-
import { t as ce } from "./admin-textarea-
|
|
20
|
-
import { r as le, t as ue } from "./admin-card-
|
|
21
|
-
import { t as
|
|
22
|
-
import * as
|
|
23
|
-
import { useMutation as
|
|
24
|
-
import { Fragment as
|
|
18
|
+
import { i as z, n as ae, r as oe, t as se } from "./admin-price-format-BVUpDoSC.js";
|
|
19
|
+
import { t as ce } from "./admin-textarea-Dc6lnEub.js";
|
|
20
|
+
import { r as le, t as ue } from "./admin-card-DvTMc5Se.js";
|
|
21
|
+
import { t as B } from "./admin-price-wizard-CBEcNGvP.js";
|
|
22
|
+
import * as V from "react";
|
|
23
|
+
import { useMutation as H, useQuery as U, useQueryClient as W } from "@tanstack/react-query";
|
|
24
|
+
import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
|
|
25
25
|
import { HugeiconsIcon as J } from "@hugeicons/react";
|
|
26
|
-
import { Add01Icon as
|
|
26
|
+
import { Add01Icon as de, BubbleChatQuestionIcon as fe, Cancel01Icon as pe, Loading02Icon as me, SparklesIcon as he } from "@hugeicons/core-free-icons";
|
|
27
27
|
import { useForm as Y } from "@tanstack/react-form";
|
|
28
28
|
//#region src/admin/pages/catalog/application-dialog.tsx
|
|
29
|
-
function
|
|
30
|
-
let { toast:
|
|
29
|
+
function ge() {
|
|
30
|
+
let { toast: i, toastApiError: o, selectedMerchant: s, adminMutations: c } = r(), { id: l, text: u } = t(), [d, f] = V.useState(!1), [p, m] = V.useState(""), [h, g] = V.useState(!1), [_, v] = V.useState(), [y, b] = V.useState(), [x, S] = V.useState(""), [C, w] = V.useState(!1), [T, E] = V.useState(), D = H(c.applyCatalog(W())), O = () => {
|
|
31
31
|
E(s()), m(JSON.stringify({
|
|
32
32
|
schema_version: 1,
|
|
33
33
|
prune: !1,
|
|
34
34
|
products: {}
|
|
35
35
|
}, null, 2)), v(void 0), b(void 0), g(!1), w(!1), S("");
|
|
36
|
-
}, k = async (
|
|
36
|
+
}, k = async (t = !1) => {
|
|
37
37
|
if (s() !== T) {
|
|
38
38
|
S("This draft belongs to another selected merchant. Return to that merchant before applying it.");
|
|
39
39
|
return;
|
|
@@ -41,37 +41,37 @@ function ye() {
|
|
|
41
41
|
let n = _ ?? p;
|
|
42
42
|
v(n), w(!1), S("");
|
|
43
43
|
try {
|
|
44
|
-
let
|
|
44
|
+
let e = await D.mutateAsync({
|
|
45
45
|
document: n,
|
|
46
|
-
force:
|
|
46
|
+
force: t
|
|
47
47
|
});
|
|
48
|
-
b(
|
|
49
|
-
let
|
|
50
|
-
S(
|
|
51
|
-
} catch (
|
|
52
|
-
let n =
|
|
53
|
-
w(n), S(n ? "Batch refused. Review the error and edit the document before trying again." : "The outcome could not be confirmed. Retry this exact document to retrieve its receipt without repeating changes."), o(
|
|
48
|
+
b(e);
|
|
49
|
+
let r = e.conflicts?.length ?? 0;
|
|
50
|
+
S(e.replayed ? "This batch was already applied. No changes were repeated, and later catalog edits were preserved." : r > 0 ? `Applied everything no edit changed. ${r} ${r === 1 ? "object was" : "objects were"} skipped because an edit set ${r === 1 ? "its" : "their"} fields differently: change the batch to agree, remove those fields, or overwrite the edits.` : "Batch applied. Review the current catalog before preparing another batch."), r > 0 ? i.warning(`Catalog batch applied; ${r} skipped`) : i.success(e.replayed ? "Original batch receipt returned" : "Catalog batch applied");
|
|
51
|
+
} catch (t) {
|
|
52
|
+
let n = t instanceof e && t.status >= 400 && t.status < 500 && t.status !== 408;
|
|
53
|
+
w(n), S(n ? "Batch refused. Review the error and edit the document before trying again." : "The outcome could not be confirmed. Retry this exact document to retrieve its receipt without repeating changes."), o(t, "Apply catalog");
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ q(
|
|
56
|
+
return /* @__PURE__ */ q(L, {
|
|
57
57
|
open: d,
|
|
58
58
|
onOpenChange: (e) => {
|
|
59
59
|
D.isPending || (f(e), e && !p && O());
|
|
60
60
|
},
|
|
61
|
-
children: [/* @__PURE__ */ K(
|
|
61
|
+
children: [/* @__PURE__ */ K(I, { render: /* @__PURE__ */ K(a, {
|
|
62
62
|
variant: "outline",
|
|
63
63
|
size: "sm",
|
|
64
|
-
children: /* @__PURE__ */ K(
|
|
65
|
-
}) }), /* @__PURE__ */ q(
|
|
64
|
+
children: /* @__PURE__ */ K(n, { id: "Apply catalog" })
|
|
65
|
+
}) }), /* @__PURE__ */ q(N, {
|
|
66
66
|
className: ie,
|
|
67
67
|
children: [
|
|
68
|
-
/* @__PURE__ */ q(
|
|
68
|
+
/* @__PURE__ */ q(j, { children: [/* @__PURE__ */ K(P, { children: /* @__PURE__ */ K(n, { id: "Apply catalog changes" }) }), /* @__PURE__ */ K(F, { children: /* @__PURE__ */ K(n, { id: "Paste a JSON or YAML catalog batch; products, prices and meters are maps keyed by their key. Each product, price and meter applies whole, unless a field it names was set differently by an edit: it is skipped and listed, and the rest applies. A batch that applied whole is remembered; retries preserve later catalog edits. Omitted records stay unchanged unless prune is true, which archives the omitted ones only batches set." }) })] }),
|
|
69
69
|
/* @__PURE__ */ q("div", {
|
|
70
70
|
className: "grid gap-3",
|
|
71
71
|
children: [
|
|
72
|
-
/* @__PURE__ */ K(
|
|
72
|
+
/* @__PURE__ */ K(R, {
|
|
73
73
|
htmlFor: l("catalog-application"),
|
|
74
|
-
children: /* @__PURE__ */ K(
|
|
74
|
+
children: /* @__PURE__ */ K(n, { id: "Catalog document" })
|
|
75
75
|
}),
|
|
76
76
|
/* @__PURE__ */ K(ce, {
|
|
77
77
|
id: l("catalog-application"),
|
|
@@ -85,14 +85,14 @@ function ye() {
|
|
|
85
85
|
}),
|
|
86
86
|
h && !_ && /* @__PURE__ */ K("p", {
|
|
87
87
|
className: "text-sm",
|
|
88
|
-
children: /* @__PURE__ */ K(
|
|
88
|
+
children: /* @__PURE__ */ K(n, { id: "Review complete. Applying sends this exact document; this is not a database diff." })
|
|
89
89
|
}),
|
|
90
90
|
x && /* @__PURE__ */ K("p", {
|
|
91
91
|
role: "status",
|
|
92
92
|
className: "text-sm",
|
|
93
93
|
children: x
|
|
94
94
|
}),
|
|
95
|
-
y && y.conflicts.length > 0 && /* @__PURE__ */ K(
|
|
95
|
+
y && y.conflicts.length > 0 && /* @__PURE__ */ K(_e, { conflicts: y.conflicts }),
|
|
96
96
|
y && /* @__PURE__ */ K("pre", {
|
|
97
97
|
"aria-label": u("Batch receipt"),
|
|
98
98
|
className: "max-h-48 overflow-auto rounded-md border p-3 text-xs",
|
|
@@ -100,31 +100,31 @@ function ye() {
|
|
|
100
100
|
})
|
|
101
101
|
]
|
|
102
102
|
}),
|
|
103
|
-
/* @__PURE__ */ q(
|
|
103
|
+
/* @__PURE__ */ q(M, { children: [
|
|
104
104
|
C && /* @__PURE__ */ K(a, {
|
|
105
105
|
variant: "outline",
|
|
106
106
|
onClick: () => {
|
|
107
107
|
v(void 0), g(!1), w(!1), S("");
|
|
108
108
|
},
|
|
109
|
-
children: /* @__PURE__ */ K(
|
|
109
|
+
children: /* @__PURE__ */ K(n, { id: "Edit batch" })
|
|
110
110
|
}),
|
|
111
111
|
y && y.conflicts.length > 0 && /* @__PURE__ */ K(a, {
|
|
112
112
|
variant: "destructive",
|
|
113
113
|
disabled: D.isPending,
|
|
114
114
|
onClick: () => void k(!0),
|
|
115
|
-
children: /* @__PURE__ */ K(
|
|
115
|
+
children: /* @__PURE__ */ K(n, { id: "Overwrite edits" })
|
|
116
116
|
}),
|
|
117
117
|
y ? /* @__PURE__ */ K(a, {
|
|
118
118
|
onClick: () => O(),
|
|
119
|
-
children: /* @__PURE__ */ K(
|
|
119
|
+
children: /* @__PURE__ */ K(n, { id: "New batch" })
|
|
120
120
|
}) : _ === void 0 ? h ? /* @__PURE__ */ K(a, {
|
|
121
121
|
disabled: !p.trim(),
|
|
122
122
|
onClick: () => void k(),
|
|
123
|
-
children: /* @__PURE__ */ K(
|
|
123
|
+
children: /* @__PURE__ */ K(n, { id: "Apply reviewed batch" })
|
|
124
124
|
}) : /* @__PURE__ */ K(a, {
|
|
125
125
|
disabled: !p.trim(),
|
|
126
126
|
onClick: () => g(!0),
|
|
127
|
-
children: /* @__PURE__ */ K(
|
|
127
|
+
children: /* @__PURE__ */ K(n, { id: "Review batch" })
|
|
128
128
|
}) : /* @__PURE__ */ K(a, {
|
|
129
129
|
disabled: D.isPending || C,
|
|
130
130
|
onClick: () => void k(),
|
|
@@ -135,47 +135,47 @@ function ye() {
|
|
|
135
135
|
})]
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
let { text:
|
|
138
|
+
function _e({ conflicts: e }) {
|
|
139
|
+
let { text: r } = t();
|
|
140
140
|
return /* @__PURE__ */ K("ul", {
|
|
141
|
-
"aria-label":
|
|
141
|
+
"aria-label": r("Skipped objects"),
|
|
142
142
|
className: "grid gap-2 text-sm",
|
|
143
|
-
children:
|
|
143
|
+
children: e.map((e) => /* @__PURE__ */ q("li", {
|
|
144
144
|
className: "rounded-md border p-2",
|
|
145
145
|
children: [/* @__PURE__ */ q("p", {
|
|
146
146
|
className: "font-medium",
|
|
147
147
|
children: [
|
|
148
148
|
e.product_key ? `Price ${e.key} of product ${e.product_key}` : `${e.object === "meter" ? "Meter" : "Product"} ${e.key}`,
|
|
149
149
|
" ",
|
|
150
|
-
/* @__PURE__ */ K(
|
|
150
|
+
/* @__PURE__ */ K(n, { id: "skipped" })
|
|
151
151
|
]
|
|
152
152
|
}), /* @__PURE__ */ K("ul", {
|
|
153
153
|
className: "mt-1 grid gap-1 text-xs text-muted-foreground",
|
|
154
154
|
children: e.fields.map((t) => /* @__PURE__ */ q("li", { children: [
|
|
155
155
|
t.field,
|
|
156
|
-
/* @__PURE__ */ K(
|
|
156
|
+
/* @__PURE__ */ K(n, { id: ": the batch says" }),
|
|
157
157
|
" ",
|
|
158
|
-
|
|
159
|
-
/* @__PURE__ */ K(
|
|
158
|
+
ve(t, t.file_value, e.currency),
|
|
159
|
+
/* @__PURE__ */ K(n, { id: ", an edit set" }),
|
|
160
160
|
" ",
|
|
161
|
-
|
|
161
|
+
ve(t, t.live_value, e.currency),
|
|
162
162
|
" (",
|
|
163
163
|
t.set_by,
|
|
164
164
|
", ",
|
|
165
|
-
|
|
165
|
+
p(t.set_at),
|
|
166
166
|
")"
|
|
167
167
|
] }, t.field))
|
|
168
168
|
})]
|
|
169
169
|
}, `${e.object}:${e.product_key ?? ""}:${e.key}`))
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return t == null ? "none" : (e.field === "unit_amount" || e.field === "trial_unit_amount") && typeof t == "string" && n ?
|
|
172
|
+
function ve(e, t, n) {
|
|
173
|
+
return t == null ? "none" : (e.field === "unit_amount" || e.field === "trial_unit_amount") && typeof t == "string" && n ? m(t, n) : e.field.endsWith("_hours") && typeof t == "number" ? oe(t) : JSON.stringify(t);
|
|
174
174
|
}
|
|
175
175
|
//#endregion
|
|
176
176
|
//#region src/admin/pages/catalog/copilot-panel.tsx
|
|
177
|
-
function
|
|
178
|
-
let { text: c } =
|
|
177
|
+
function ye({ enabled: i, draftingEnabled: s }) {
|
|
178
|
+
let { text: c } = t(), { adminMutations: l } = r(), u = H(l.askCatalogCopilot()), d = Y({
|
|
179
179
|
defaultValues: { question: "" },
|
|
180
180
|
onSubmit: async ({ value: e }) => {
|
|
181
181
|
let t = e.question.trim();
|
|
@@ -186,8 +186,8 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
186
186
|
} catch {}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
}), f = u.data, p = u.error ? u.error instanceof
|
|
190
|
-
return
|
|
189
|
+
}), f = u.data, p = u.error ? u.error instanceof e ? u.error.message : "ask failed" : null;
|
|
190
|
+
return i ? /* @__PURE__ */ K(ue, { children: /* @__PURE__ */ q(le, {
|
|
191
191
|
className: "flex flex-col gap-3",
|
|
192
192
|
children: [
|
|
193
193
|
/* @__PURE__ */ q("form", {
|
|
@@ -197,7 +197,7 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
197
197
|
},
|
|
198
198
|
children: [
|
|
199
199
|
/* @__PURE__ */ K(J, {
|
|
200
|
-
icon:
|
|
200
|
+
icon: fe,
|
|
201
201
|
className: "size-4 shrink-0 text-muted-foreground"
|
|
202
202
|
}),
|
|
203
203
|
/* @__PURE__ */ K(d.Field, {
|
|
@@ -217,16 +217,16 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
217
217
|
size: "sm",
|
|
218
218
|
disabled: t || !e.trim(),
|
|
219
219
|
children: [t ? /* @__PURE__ */ K(J, {
|
|
220
|
-
icon:
|
|
220
|
+
icon: me,
|
|
221
221
|
className: "size-3.5 animate-spin"
|
|
222
|
-
}) : null, /* @__PURE__ */ K(
|
|
222
|
+
}) : null, /* @__PURE__ */ K(n, { id: "Ask" })]
|
|
223
223
|
})
|
|
224
224
|
})
|
|
225
225
|
]
|
|
226
226
|
}),
|
|
227
227
|
u.isPending ? /* @__PURE__ */ K("p", {
|
|
228
228
|
className: "text-xs text-muted-foreground",
|
|
229
|
-
children: /* @__PURE__ */ K(
|
|
229
|
+
children: /* @__PURE__ */ K(n, { id: "Checking your catalog…" })
|
|
230
230
|
}) : null,
|
|
231
231
|
p ? /* @__PURE__ */ K("p", {
|
|
232
232
|
className: "text-xs whitespace-pre-wrap text-destructive",
|
|
@@ -250,7 +250,7 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
250
250
|
u.reset();
|
|
251
251
|
},
|
|
252
252
|
children: /* @__PURE__ */ K(J, {
|
|
253
|
-
icon:
|
|
253
|
+
icon: pe,
|
|
254
254
|
className: "size-3.5"
|
|
255
255
|
})
|
|
256
256
|
})]
|
|
@@ -268,7 +268,7 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
268
268
|
})]
|
|
269
269
|
}, t))
|
|
270
270
|
}),
|
|
271
|
-
f.drafts?.map((e, t) => /* @__PURE__ */ K(
|
|
271
|
+
f.drafts?.map((e, t) => /* @__PURE__ */ K(be, {
|
|
272
272
|
draft: e,
|
|
273
273
|
draftingEnabled: s
|
|
274
274
|
}, t))
|
|
@@ -277,16 +277,16 @@ function Se({ enabled: r, draftingEnabled: s }) {
|
|
|
277
277
|
]
|
|
278
278
|
}) }) : null;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
let
|
|
280
|
+
function be({ draft: e, draftingEnabled: t }) {
|
|
281
|
+
let r = l() && t;
|
|
282
282
|
return e.kind === "refused" && e.refusal ? /* @__PURE__ */ q("div", {
|
|
283
283
|
className: "rounded-lg border border-dashed p-3 text-xs",
|
|
284
284
|
children: [
|
|
285
285
|
/* @__PURE__ */ K("p", {
|
|
286
286
|
className: "mb-1 flex items-center gap-2 font-medium",
|
|
287
|
-
children: /* @__PURE__ */ q(
|
|
287
|
+
children: /* @__PURE__ */ q(A, {
|
|
288
288
|
variant: "secondary",
|
|
289
|
-
children: [/* @__PURE__ */ K(
|
|
289
|
+
children: [/* @__PURE__ */ K(n, { id: "refused: " }), e.refusal.code]
|
|
290
290
|
})
|
|
291
291
|
}),
|
|
292
292
|
/* @__PURE__ */ K("p", {
|
|
@@ -298,16 +298,16 @@ function Ce({ draft: e, draftingEnabled: t }) {
|
|
|
298
298
|
children: e.refusal.workaround
|
|
299
299
|
})
|
|
300
300
|
]
|
|
301
|
-
}) : e.kind === "price_change" && e.price_change ? /* @__PURE__ */ K(
|
|
301
|
+
}) : e.kind === "price_change" && e.price_change ? /* @__PURE__ */ K(xe, {
|
|
302
302
|
draft: e.price_change,
|
|
303
|
-
canApply:
|
|
304
|
-
}) : e.kind === "new_price" && e.new_price ? /* @__PURE__ */ K(
|
|
303
|
+
canApply: r
|
|
304
|
+
}) : e.kind === "new_price" && e.new_price ? /* @__PURE__ */ K(Se, {
|
|
305
305
|
draft: e.new_price,
|
|
306
|
-
canApply:
|
|
306
|
+
canApply: r
|
|
307
307
|
}) : null;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
let { toastApiError:
|
|
309
|
+
function xe({ draft: e, canApply: t }) {
|
|
310
|
+
let { toastApiError: i, adminMutations: o } = r(), s = H(o.loadCatalogPriceDraft());
|
|
311
311
|
return /* @__PURE__ */ q("div", {
|
|
312
312
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
313
313
|
children: [
|
|
@@ -315,14 +315,14 @@ function we({ draft: e, canApply: t }) {
|
|
|
315
315
|
className: "mb-1 flex items-center gap-2",
|
|
316
316
|
children: [
|
|
317
317
|
/* @__PURE__ */ K(J, {
|
|
318
|
-
icon:
|
|
318
|
+
icon: he,
|
|
319
319
|
className: "size-3.5 text-muted-foreground"
|
|
320
320
|
}),
|
|
321
321
|
/* @__PURE__ */ K("span", {
|
|
322
322
|
className: "text-xs font-medium text-muted-foreground uppercase",
|
|
323
|
-
children: /* @__PURE__ */ K(
|
|
323
|
+
children: /* @__PURE__ */ K(n, { id: "Draft: price change" })
|
|
324
324
|
}),
|
|
325
|
-
/* @__PURE__ */ K(
|
|
325
|
+
/* @__PURE__ */ K(A, {
|
|
326
326
|
variant: "secondary",
|
|
327
327
|
children: BigInt(e.new_amount) > BigInt(e.current_amount) ? "increase" : "decrease"
|
|
328
328
|
})
|
|
@@ -332,17 +332,17 @@ function we({ draft: e, canApply: t }) {
|
|
|
332
332
|
/* @__PURE__ */ q("p", {
|
|
333
333
|
className: "mt-1 text-xs text-muted-foreground",
|
|
334
334
|
children: [
|
|
335
|
-
|
|
335
|
+
m(e.current_amount, e.currency),
|
|
336
336
|
" →",
|
|
337
337
|
" ",
|
|
338
|
-
|
|
338
|
+
m(e.new_amount, e.currency),
|
|
339
339
|
" ·",
|
|
340
340
|
" ",
|
|
341
341
|
e.affected_count.toLocaleString(),
|
|
342
|
-
/* @__PURE__ */ K(
|
|
342
|
+
/* @__PURE__ */ K(n, { id: " affected · requires human confirm" })
|
|
343
343
|
]
|
|
344
344
|
}),
|
|
345
|
-
t && (s.data ? /* @__PURE__ */ K(
|
|
345
|
+
t && (s.data ? /* @__PURE__ */ K(B, {
|
|
346
346
|
price: s.data.price,
|
|
347
347
|
productName: s.data.productName,
|
|
348
348
|
productKey: s.data.productKey,
|
|
@@ -359,7 +359,7 @@ function we({ draft: e, canApply: t }) {
|
|
|
359
359
|
priceKey: e.price_key
|
|
360
360
|
});
|
|
361
361
|
} catch (e) {
|
|
362
|
-
|
|
362
|
+
i(e, "Load draft for review");
|
|
363
363
|
}
|
|
364
364
|
},
|
|
365
365
|
children: s.isPending ? "Loading…" : "Review in wizard"
|
|
@@ -367,30 +367,30 @@ function we({ draft: e, canApply: t }) {
|
|
|
367
367
|
]
|
|
368
368
|
});
|
|
369
369
|
}
|
|
370
|
-
function
|
|
371
|
-
let { toastApiError:
|
|
370
|
+
function Se({ draft: e, canApply: t }) {
|
|
371
|
+
let { toastApiError: i, adminMutations: o } = r(), s = W(), c = H(o.createCatalogDraftPrice(s));
|
|
372
372
|
return /* @__PURE__ */ q("div", {
|
|
373
373
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
374
374
|
children: [
|
|
375
375
|
/* @__PURE__ */ q("div", {
|
|
376
376
|
className: "mb-1 flex items-center gap-2",
|
|
377
377
|
children: [/* @__PURE__ */ K(J, {
|
|
378
|
-
icon:
|
|
378
|
+
icon: he,
|
|
379
379
|
className: "size-3.5 text-muted-foreground"
|
|
380
380
|
}), /* @__PURE__ */ K("span", {
|
|
381
381
|
className: "text-xs font-medium text-muted-foreground uppercase",
|
|
382
|
-
children: /* @__PURE__ */ K(
|
|
382
|
+
children: /* @__PURE__ */ K(n, { id: "Draft: new price" })
|
|
383
383
|
})]
|
|
384
384
|
}),
|
|
385
385
|
/* @__PURE__ */ K("p", { children: e.review_text }),
|
|
386
386
|
/* @__PURE__ */ q("p", {
|
|
387
387
|
className: "mt-1 text-xs text-muted-foreground",
|
|
388
388
|
children: [
|
|
389
|
-
/* @__PURE__ */ K(
|
|
389
|
+
/* @__PURE__ */ K(n, { id: "key: " }),
|
|
390
390
|
e.create_price.key,
|
|
391
391
|
" ·",
|
|
392
392
|
" ",
|
|
393
|
-
|
|
393
|
+
m(e.create_price.unit_amount, e.create_price.currency)
|
|
394
394
|
]
|
|
395
395
|
}),
|
|
396
396
|
t && /* @__PURE__ */ K(a, {
|
|
@@ -401,7 +401,7 @@ function Te({ draft: e, canApply: t }) {
|
|
|
401
401
|
if (t) try {
|
|
402
402
|
await c.mutateAsync(e.create_price);
|
|
403
403
|
} catch (e) {
|
|
404
|
-
|
|
404
|
+
i(e, "Create drafted price");
|
|
405
405
|
}
|
|
406
406
|
},
|
|
407
407
|
children: c.isSuccess ? "Created" : c.isPending ? "Creating…" : "Create this price"
|
|
@@ -411,11 +411,11 @@ function Te({ draft: e, canApply: t }) {
|
|
|
411
411
|
}
|
|
412
412
|
//#endregion
|
|
413
413
|
//#region src/admin/pages/catalog/index.tsx
|
|
414
|
-
var X =
|
|
415
|
-
function
|
|
416
|
-
let
|
|
414
|
+
var X = V.createContext(!1);
|
|
415
|
+
function Ce({ title: e, children: t }) {
|
|
416
|
+
let r = c()?.assistants, i = l();
|
|
417
417
|
return /* @__PURE__ */ K(X.Provider, {
|
|
418
|
-
value:
|
|
418
|
+
value: i,
|
|
419
419
|
children: /* @__PURE__ */ q("div", {
|
|
420
420
|
className: "flex flex-col gap-4",
|
|
421
421
|
children: [
|
|
@@ -423,48 +423,38 @@ function Ee({ title: e, children: t }) {
|
|
|
423
423
|
className: "text-2xl font-semibold tracking-tight",
|
|
424
424
|
children: e
|
|
425
425
|
}),
|
|
426
|
-
/* @__PURE__ */ K(
|
|
427
|
-
enabled:
|
|
428
|
-
draftingEnabled:
|
|
426
|
+
/* @__PURE__ */ K(ye, {
|
|
427
|
+
enabled: r?.catalog_copilot ?? !1,
|
|
428
|
+
draftingEnabled: i && (r?.catalog_drafting ?? !1)
|
|
429
429
|
}),
|
|
430
|
-
!
|
|
430
|
+
!i && /* @__PURE__ */ K("p", {
|
|
431
431
|
className: "text-sm text-muted-foreground",
|
|
432
|
-
children: /* @__PURE__ */ K(
|
|
432
|
+
children: /* @__PURE__ */ K(n, { id: "Catalog updates are unavailable. You can still browse products and prices." })
|
|
433
433
|
}),
|
|
434
434
|
t
|
|
435
435
|
]
|
|
436
436
|
})
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
let { text:
|
|
441
|
-
return /* @__PURE__ */ K(
|
|
442
|
-
title:
|
|
443
|
-
children: /* @__PURE__ */ K(
|
|
439
|
+
function we() {
|
|
440
|
+
let { text: e } = t();
|
|
441
|
+
return /* @__PURE__ */ K(Ce, {
|
|
442
|
+
title: e("Products"),
|
|
443
|
+
children: /* @__PURE__ */ K(De, {})
|
|
444
444
|
});
|
|
445
445
|
}
|
|
446
|
-
function
|
|
447
|
-
let { text:
|
|
448
|
-
return /* @__PURE__ */ K(
|
|
449
|
-
title:
|
|
450
|
-
children: /* @__PURE__ */ K(
|
|
446
|
+
function Te() {
|
|
447
|
+
let { text: e } = t();
|
|
448
|
+
return /* @__PURE__ */ K(Ce, {
|
|
449
|
+
title: e("Prices"),
|
|
450
|
+
children: /* @__PURE__ */ K(Ae, {})
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
className: "text-2xl font-semibold tracking-tight",
|
|
459
|
-
children: t("Drift")
|
|
460
|
-
}), /* @__PURE__ */ K(Le, {})]
|
|
461
|
-
}) : null;
|
|
462
|
-
}
|
|
463
|
-
var Z = 100;
|
|
464
|
-
function Ae() {
|
|
465
|
-
let { adminQueries: e } = n(), t = H.useContext(X), r = T("", Z), { data: a, isPending: o, isFetching: c } = W(e.products({
|
|
466
|
-
limit: r.size,
|
|
467
|
-
cursor: r.cursor,
|
|
453
|
+
var Ee = 100;
|
|
454
|
+
function De() {
|
|
455
|
+
let { adminQueries: e } = r(), t = V.useContext(X), i = S("", Ee), { data: a, isPending: o, isFetching: c } = U(e.products({
|
|
456
|
+
limit: i.size,
|
|
457
|
+
cursor: i.cursor,
|
|
468
458
|
errorAction: "Load products"
|
|
469
459
|
}));
|
|
470
460
|
return /* @__PURE__ */ q("div", {
|
|
@@ -472,46 +462,46 @@ function Ae() {
|
|
|
472
462
|
children: [
|
|
473
463
|
/* @__PURE__ */ K("div", {
|
|
474
464
|
className: "flex justify-end gap-2",
|
|
475
|
-
children: t && /* @__PURE__ */ q(
|
|
465
|
+
children: t && /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(ge, {}), /* @__PURE__ */ K(ke, {})] })
|
|
476
466
|
}),
|
|
477
467
|
o ? /* @__PURE__ */ K("div", {
|
|
478
468
|
className: "flex flex-col gap-3 py-2",
|
|
479
469
|
children: Array.from({ length: 4 }).map((e, t) => /* @__PURE__ */ K(s, { className: "h-6 w-full" }, t))
|
|
480
470
|
}) : /* @__PURE__ */ K("div", {
|
|
481
471
|
className: "overflow-x-auto",
|
|
482
|
-
children: /* @__PURE__ */ q(
|
|
472
|
+
children: /* @__PURE__ */ q(k, { children: [/* @__PURE__ */ K(E, { children: /* @__PURE__ */ q(O, {
|
|
483
473
|
className: "hover:bg-transparent",
|
|
484
474
|
children: [
|
|
485
|
-
/* @__PURE__ */ K(
|
|
475
|
+
/* @__PURE__ */ K(w, {
|
|
486
476
|
className: "text-muted-foreground",
|
|
487
|
-
children: /* @__PURE__ */ K(
|
|
477
|
+
children: /* @__PURE__ */ K(n, { id: "Product" })
|
|
488
478
|
}),
|
|
489
|
-
/* @__PURE__ */ K(
|
|
479
|
+
/* @__PURE__ */ K(w, {
|
|
490
480
|
className: "text-muted-foreground",
|
|
491
|
-
children: /* @__PURE__ */ K(
|
|
481
|
+
children: /* @__PURE__ */ K(n, { id: "Key" })
|
|
492
482
|
}),
|
|
493
|
-
/* @__PURE__ */ K(
|
|
483
|
+
/* @__PURE__ */ K(w, {
|
|
494
484
|
className: "text-muted-foreground",
|
|
495
|
-
children: /* @__PURE__ */ K(
|
|
485
|
+
children: /* @__PURE__ */ K(n, { id: "Tier" })
|
|
496
486
|
}),
|
|
497
|
-
/* @__PURE__ */ K(
|
|
487
|
+
/* @__PURE__ */ K(w, {
|
|
498
488
|
className: "text-muted-foreground",
|
|
499
|
-
children: /* @__PURE__ */ K(
|
|
489
|
+
children: /* @__PURE__ */ K(n, { id: "Entitlements" })
|
|
500
490
|
}),
|
|
501
|
-
/* @__PURE__ */ K(
|
|
491
|
+
/* @__PURE__ */ K(w, {
|
|
502
492
|
className: "text-muted-foreground",
|
|
503
|
-
children: /* @__PURE__ */ K(
|
|
493
|
+
children: /* @__PURE__ */ K(n, { id: "State" })
|
|
504
494
|
}),
|
|
505
|
-
/* @__PURE__ */ K(
|
|
495
|
+
/* @__PURE__ */ K(w, {})
|
|
506
496
|
]
|
|
507
|
-
}) }), /* @__PURE__ */ q(
|
|
497
|
+
}) }), /* @__PURE__ */ q(T, { children: [(a?.data ?? []).map((e) => /* @__PURE__ */ K(Oe, { product: e }, e.id)), !a?.data?.length && /* @__PURE__ */ K(O, { children: /* @__PURE__ */ K(D, {
|
|
508
498
|
colSpan: 6,
|
|
509
499
|
className: "h-24 text-center text-muted-foreground",
|
|
510
|
-
children: /* @__PURE__ */ K(
|
|
500
|
+
children: /* @__PURE__ */ K(n, { id: "No products yet." })
|
|
511
501
|
}) })] })] })
|
|
512
502
|
}),
|
|
513
|
-
/* @__PURE__ */ K(
|
|
514
|
-
pages:
|
|
503
|
+
/* @__PURE__ */ K(C, {
|
|
504
|
+
pages: i,
|
|
515
505
|
rows: a?.data?.length ?? 0,
|
|
516
506
|
nextCursor: a?.next_cursor,
|
|
517
507
|
busy: c,
|
|
@@ -524,37 +514,37 @@ function Ae() {
|
|
|
524
514
|
]
|
|
525
515
|
});
|
|
526
516
|
}
|
|
527
|
-
function
|
|
528
|
-
let { toast: t, toastApiError:
|
|
529
|
-
return /* @__PURE__ */ q(
|
|
517
|
+
function Oe({ product: e }) {
|
|
518
|
+
let { toast: t, toastApiError: i, adminMutations: o } = r(), s = V.useContext(X), c = W(), l = H(o.setProductActive(c));
|
|
519
|
+
return /* @__PURE__ */ q(O, {
|
|
530
520
|
className: e.archived ? "opacity-60" : void 0,
|
|
531
521
|
children: [
|
|
532
|
-
/* @__PURE__ */ K(
|
|
522
|
+
/* @__PURE__ */ K(D, {
|
|
533
523
|
className: "font-medium",
|
|
534
524
|
children: e.display_name
|
|
535
525
|
}),
|
|
536
|
-
/* @__PURE__ */ K(
|
|
526
|
+
/* @__PURE__ */ K(D, {
|
|
537
527
|
className: "text-xs text-muted-foreground",
|
|
538
528
|
children: e.key
|
|
539
529
|
}),
|
|
540
|
-
/* @__PURE__ */ K(
|
|
541
|
-
/* @__PURE__ */ K(
|
|
530
|
+
/* @__PURE__ */ K(D, { children: e.tier_group ? `${e.tier_group} #${e.tier_rank}` : "—" }),
|
|
531
|
+
/* @__PURE__ */ K(D, { children: /* @__PURE__ */ K("span", {
|
|
542
532
|
className: "flex flex-wrap gap-1",
|
|
543
|
-
children: e.entitlements.map((e) => /* @__PURE__ */ K(
|
|
533
|
+
children: e.entitlements.map((e) => /* @__PURE__ */ K(A, {
|
|
544
534
|
variant: "secondary",
|
|
545
535
|
className: "text-[10px]",
|
|
546
536
|
children: e
|
|
547
537
|
}, e))
|
|
548
538
|
}) }),
|
|
549
|
-
/* @__PURE__ */ K(
|
|
539
|
+
/* @__PURE__ */ K(D, { children: e.archived ? /* @__PURE__ */ K(A, {
|
|
550
540
|
variant: "secondary",
|
|
551
|
-
children: /* @__PURE__ */ K(
|
|
541
|
+
children: /* @__PURE__ */ K(n, { id: "archived" })
|
|
552
542
|
}) : /* @__PURE__ */ K(te, { status: "active" }) }),
|
|
553
|
-
/* @__PURE__ */ K(
|
|
543
|
+
/* @__PURE__ */ K(D, {
|
|
554
544
|
className: "text-right",
|
|
555
545
|
children: s && /* @__PURE__ */ q("div", {
|
|
556
546
|
className: "flex justify-end gap-2",
|
|
557
|
-
children: [s && /* @__PURE__ */ K(
|
|
547
|
+
children: [s && /* @__PURE__ */ K(ke, { product: e }), /* @__PURE__ */ K(a, {
|
|
558
548
|
variant: "outline",
|
|
559
549
|
size: "sm",
|
|
560
550
|
disabled: !s || l.isPending,
|
|
@@ -566,7 +556,7 @@ function je({ product: e }) {
|
|
|
566
556
|
revision: e.revision
|
|
567
557
|
}), t.success(e.archived ? "Product activated" : "Product deactivated");
|
|
568
558
|
} catch (e) {
|
|
569
|
-
|
|
559
|
+
i(e, "Toggle product");
|
|
570
560
|
}
|
|
571
561
|
},
|
|
572
562
|
children: e.archived ? "Activate" : "Deactivate"
|
|
@@ -576,7 +566,7 @@ function je({ product: e }) {
|
|
|
576
566
|
]
|
|
577
567
|
});
|
|
578
568
|
}
|
|
579
|
-
function
|
|
569
|
+
function Z(e) {
|
|
580
570
|
return {
|
|
581
571
|
key: e?.key ?? "",
|
|
582
572
|
name: e?.display_name ?? "",
|
|
@@ -586,61 +576,61 @@ function Me(e) {
|
|
|
586
576
|
entitlements: (e?.entitlements ?? []).join(",")
|
|
587
577
|
};
|
|
588
578
|
}
|
|
589
|
-
function
|
|
590
|
-
let { toast:
|
|
591
|
-
defaultValues:
|
|
592
|
-
onSubmit: async ({ value:
|
|
593
|
-
let n =
|
|
579
|
+
function ke({ product: e }) {
|
|
580
|
+
let { toast: i, toastApiError: s, adminMutations: c } = r(), { text: l, id: u } = t(), [d, f] = V.useState(!1), p = W(), m = H(c.createProduct(p)), h = H(c.updateProduct(p)), _ = Y({
|
|
581
|
+
defaultValues: Z(e),
|
|
582
|
+
onSubmit: async ({ value: t }) => {
|
|
583
|
+
let n = t.entitlements.split(",").map((e) => e.trim()).filter(Boolean);
|
|
594
584
|
try {
|
|
595
|
-
|
|
596
|
-
id:
|
|
585
|
+
e ? (await h.mutateAsync({
|
|
586
|
+
id: e.id,
|
|
597
587
|
product: {
|
|
598
|
-
display_name:
|
|
599
|
-
description:
|
|
600
|
-
tier_group:
|
|
601
|
-
tier_rank: Number(
|
|
588
|
+
display_name: t.name,
|
|
589
|
+
description: t.description,
|
|
590
|
+
tier_group: t.tierGroup || null,
|
|
591
|
+
tier_rank: Number(t.tierRank) || 0,
|
|
602
592
|
entitlements: n,
|
|
603
|
-
expected_revision:
|
|
593
|
+
expected_revision: e.revision
|
|
604
594
|
}
|
|
605
|
-
}),
|
|
606
|
-
key:
|
|
607
|
-
display_name:
|
|
608
|
-
description:
|
|
609
|
-
tier_group:
|
|
610
|
-
tier_rank: Number(
|
|
595
|
+
}), i.success("Product updated")) : (await m.mutateAsync({
|
|
596
|
+
key: t.key,
|
|
597
|
+
display_name: t.name,
|
|
598
|
+
description: t.description,
|
|
599
|
+
tier_group: t.tierGroup || void 0,
|
|
600
|
+
tier_rank: Number(t.tierRank) || 0,
|
|
611
601
|
entitlements: n
|
|
612
|
-
}),
|
|
613
|
-
} catch (
|
|
614
|
-
s(
|
|
602
|
+
}), i.success("Product created")), _.reset(t), f(!1);
|
|
603
|
+
} catch (t) {
|
|
604
|
+
s(t, e ? "Update product" : "Create product");
|
|
615
605
|
}
|
|
616
606
|
}
|
|
617
607
|
});
|
|
618
|
-
return /* @__PURE__ */ q(
|
|
608
|
+
return /* @__PURE__ */ q(L, {
|
|
619
609
|
open: d,
|
|
620
|
-
onOpenChange: (
|
|
621
|
-
|
|
610
|
+
onOpenChange: (t) => {
|
|
611
|
+
t && _.reset(Z(e)), f(t);
|
|
622
612
|
},
|
|
623
|
-
children: [/* @__PURE__ */ K(
|
|
613
|
+
children: [/* @__PURE__ */ K(I, { render: e ? /* @__PURE__ */ K(a, {
|
|
624
614
|
variant: "outline",
|
|
625
615
|
size: "sm",
|
|
626
|
-
children: /* @__PURE__ */ K(
|
|
616
|
+
children: /* @__PURE__ */ K(n, { id: "Edit" })
|
|
627
617
|
}) : /* @__PURE__ */ q(a, {
|
|
628
618
|
size: "sm",
|
|
629
619
|
children: [/* @__PURE__ */ K(J, {
|
|
630
|
-
icon:
|
|
620
|
+
icon: de,
|
|
631
621
|
className: "size-4"
|
|
632
|
-
}), /* @__PURE__ */ K(
|
|
633
|
-
}) }), /* @__PURE__ */ q(
|
|
622
|
+
}), /* @__PURE__ */ K(n, { id: " Product" })]
|
|
623
|
+
}) }), /* @__PURE__ */ q(N, {
|
|
634
624
|
className: re,
|
|
635
|
-
children: [/* @__PURE__ */ q(
|
|
625
|
+
children: [/* @__PURE__ */ q(j, { children: [/* @__PURE__ */ K(P, { children: e ? "Edit product" : "New product" }), /* @__PURE__ */ K(F, { children: /* @__PURE__ */ K(n, { id: "A product is the thing a customer gets. You set what it costs afterwards, by adding a price to it." }) })] }), /* @__PURE__ */ q("form", {
|
|
636
626
|
onSubmit: (e) => {
|
|
637
|
-
e.preventDefault(), e.stopPropagation(),
|
|
627
|
+
e.preventDefault(), e.stopPropagation(), _.handleSubmit();
|
|
638
628
|
},
|
|
639
629
|
className: "grid gap-4",
|
|
640
630
|
children: [/* @__PURE__ */ q("div", {
|
|
641
631
|
className: "grid gap-3",
|
|
642
632
|
children: [
|
|
643
|
-
!
|
|
633
|
+
!e && /* @__PURE__ */ K(_.Field, {
|
|
644
634
|
name: "key",
|
|
645
635
|
validators: { onBlur: ({ value: e }) => e.trim() ? void 0 : "Enter a product key" },
|
|
646
636
|
children: (e) => /* @__PURE__ */ q($, {
|
|
@@ -654,10 +644,10 @@ function Ne({ product: t }) {
|
|
|
654
644
|
onChange: (t) => e.handleChange(t.target.value),
|
|
655
645
|
placeholder: l("premium-monthly"),
|
|
656
646
|
"aria-invalid": e.state.meta.errors.length > 0
|
|
657
|
-
}), /* @__PURE__ */ K(
|
|
647
|
+
}), /* @__PURE__ */ K(g, { errors: e.state.meta.errors })]
|
|
658
648
|
})
|
|
659
649
|
}),
|
|
660
|
-
/* @__PURE__ */ K(
|
|
650
|
+
/* @__PURE__ */ K(_.Field, {
|
|
661
651
|
name: "name",
|
|
662
652
|
validators: { onBlur: ({ value: e }) => e.trim() ? void 0 : "Enter a display name" },
|
|
663
653
|
children: (e) => /* @__PURE__ */ q($, {
|
|
@@ -670,10 +660,10 @@ function Ne({ product: t }) {
|
|
|
670
660
|
onBlur: e.handleBlur,
|
|
671
661
|
onChange: (t) => e.handleChange(t.target.value),
|
|
672
662
|
"aria-invalid": e.state.meta.errors.length > 0
|
|
673
|
-
}), /* @__PURE__ */ K(
|
|
663
|
+
}), /* @__PURE__ */ K(g, { errors: e.state.meta.errors })]
|
|
674
664
|
})
|
|
675
665
|
}),
|
|
676
|
-
/* @__PURE__ */ K(
|
|
666
|
+
/* @__PURE__ */ K(_.Field, {
|
|
677
667
|
name: "description",
|
|
678
668
|
children: (e) => /* @__PURE__ */ K($, {
|
|
679
669
|
label: l("Description"),
|
|
@@ -688,7 +678,7 @@ function Ne({ product: t }) {
|
|
|
688
678
|
}),
|
|
689
679
|
/* @__PURE__ */ q("div", {
|
|
690
680
|
className: "grid grid-cols-2 gap-3",
|
|
691
|
-
children: [/* @__PURE__ */ K(
|
|
681
|
+
children: [/* @__PURE__ */ K(_.Field, {
|
|
692
682
|
name: "tierGroup",
|
|
693
683
|
children: (e) => /* @__PURE__ */ K($, {
|
|
694
684
|
label: l("Tier group"),
|
|
@@ -701,7 +691,7 @@ function Ne({ product: t }) {
|
|
|
701
691
|
onChange: (t) => e.handleChange(t.target.value)
|
|
702
692
|
})
|
|
703
693
|
})
|
|
704
|
-
}), /* @__PURE__ */ K(
|
|
694
|
+
}), /* @__PURE__ */ K(_.Field, {
|
|
705
695
|
name: "tierRank",
|
|
706
696
|
children: (e) => /* @__PURE__ */ K($, {
|
|
707
697
|
label: l("Tier rank"),
|
|
@@ -717,7 +707,7 @@ function Ne({ product: t }) {
|
|
|
717
707
|
})
|
|
718
708
|
})]
|
|
719
709
|
}),
|
|
720
|
-
/* @__PURE__ */ K(
|
|
710
|
+
/* @__PURE__ */ K(_.Field, {
|
|
721
711
|
name: "entitlements",
|
|
722
712
|
children: (e) => /* @__PURE__ */ K($, {
|
|
723
713
|
label: l("Entitlements"),
|
|
@@ -733,32 +723,32 @@ function Ne({ product: t }) {
|
|
|
733
723
|
})
|
|
734
724
|
})
|
|
735
725
|
]
|
|
736
|
-
}), /* @__PURE__ */ K(
|
|
726
|
+
}), /* @__PURE__ */ K(M, { children: /* @__PURE__ */ K(_.Subscribe, {
|
|
737
727
|
selector: (e) => [
|
|
738
728
|
e.values.key,
|
|
739
729
|
e.values.name,
|
|
740
730
|
e.isSubmitting
|
|
741
731
|
],
|
|
742
|
-
children: ([
|
|
732
|
+
children: ([t, r, i]) => /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(a, {
|
|
743
733
|
type: "button",
|
|
744
734
|
variant: "outline",
|
|
745
|
-
disabled:
|
|
735
|
+
disabled: i,
|
|
746
736
|
onClick: () => f(!1),
|
|
747
|
-
children: /* @__PURE__ */ K(
|
|
737
|
+
children: /* @__PURE__ */ K(n, { id: "Cancel" })
|
|
748
738
|
}), /* @__PURE__ */ K(a, {
|
|
749
739
|
type: "submit",
|
|
750
|
-
disabled:
|
|
751
|
-
children:
|
|
740
|
+
disabled: i || !r.trim() || !e && !t.trim(),
|
|
741
|
+
children: i ? "Saving…" : "Save product"
|
|
752
742
|
})] })
|
|
753
743
|
}) })]
|
|
754
744
|
})]
|
|
755
745
|
})]
|
|
756
746
|
});
|
|
757
747
|
}
|
|
758
|
-
function
|
|
759
|
-
let { adminQueries: e } =
|
|
760
|
-
limit:
|
|
761
|
-
cursor:
|
|
748
|
+
function Ae() {
|
|
749
|
+
let { adminQueries: e } = r(), t = V.useContext(X), i = S("", Ee), { data: a } = U(e.allProducts({ errorAction: "Load products" })), { data: o, isPending: c, isFetching: l } = U(e.prices({
|
|
750
|
+
limit: i.size,
|
|
751
|
+
cursor: i.cursor,
|
|
762
752
|
errorAction: "Load prices"
|
|
763
753
|
}));
|
|
764
754
|
return /* @__PURE__ */ q("div", {
|
|
@@ -766,53 +756,53 @@ function Pe() {
|
|
|
766
756
|
children: [
|
|
767
757
|
/* @__PURE__ */ K("div", {
|
|
768
758
|
className: "flex justify-end",
|
|
769
|
-
children: t && /* @__PURE__ */ K(
|
|
759
|
+
children: t && /* @__PURE__ */ K(Me, { products: a?.data ?? [] })
|
|
770
760
|
}),
|
|
771
761
|
c ? /* @__PURE__ */ K("div", {
|
|
772
762
|
className: "flex flex-col gap-3 py-2",
|
|
773
763
|
children: Array.from({ length: 4 }).map((e, t) => /* @__PURE__ */ K(s, { className: "h-6 w-full" }, t))
|
|
774
764
|
}) : /* @__PURE__ */ K("div", {
|
|
775
765
|
className: "overflow-x-auto",
|
|
776
|
-
children: /* @__PURE__ */ q(
|
|
766
|
+
children: /* @__PURE__ */ q(k, { children: [/* @__PURE__ */ K(E, { children: /* @__PURE__ */ q(O, {
|
|
777
767
|
className: "hover:bg-transparent",
|
|
778
768
|
children: [
|
|
779
|
-
/* @__PURE__ */ K(
|
|
769
|
+
/* @__PURE__ */ K(w, {
|
|
780
770
|
className: "text-muted-foreground",
|
|
781
|
-
children: /* @__PURE__ */ K(
|
|
771
|
+
children: /* @__PURE__ */ K(n, { id: "Price" })
|
|
782
772
|
}),
|
|
783
|
-
/* @__PURE__ */ K(
|
|
773
|
+
/* @__PURE__ */ K(w, {
|
|
784
774
|
className: "text-muted-foreground",
|
|
785
|
-
children: /* @__PURE__ */ K(
|
|
775
|
+
children: /* @__PURE__ */ K(n, { id: "Product" })
|
|
786
776
|
}),
|
|
787
|
-
/* @__PURE__ */ K(
|
|
777
|
+
/* @__PURE__ */ K(w, {
|
|
788
778
|
className: "text-muted-foreground",
|
|
789
|
-
children: /* @__PURE__ */ K(
|
|
779
|
+
children: /* @__PURE__ */ K(n, { id: "Amount" })
|
|
790
780
|
}),
|
|
791
|
-
/* @__PURE__ */ K(
|
|
781
|
+
/* @__PURE__ */ K(w, {
|
|
792
782
|
className: "text-muted-foreground",
|
|
793
|
-
children: /* @__PURE__ */ K(
|
|
783
|
+
children: /* @__PURE__ */ K(n, { id: "Renews" })
|
|
794
784
|
}),
|
|
795
|
-
/* @__PURE__ */ K(
|
|
785
|
+
/* @__PURE__ */ K(w, {
|
|
796
786
|
className: "text-muted-foreground",
|
|
797
|
-
children: /* @__PURE__ */ K(
|
|
787
|
+
children: /* @__PURE__ */ K(n, { id: "Providers" })
|
|
798
788
|
}),
|
|
799
|
-
/* @__PURE__ */ K(
|
|
789
|
+
/* @__PURE__ */ K(w, {
|
|
800
790
|
className: "text-muted-foreground",
|
|
801
|
-
children: /* @__PURE__ */ K(
|
|
791
|
+
children: /* @__PURE__ */ K(n, { id: "State" })
|
|
802
792
|
}),
|
|
803
|
-
/* @__PURE__ */ K(
|
|
793
|
+
/* @__PURE__ */ K(w, {})
|
|
804
794
|
]
|
|
805
|
-
}) }), /* @__PURE__ */ q(
|
|
795
|
+
}) }), /* @__PURE__ */ q(T, { children: [(o?.data ?? []).map((e) => /* @__PURE__ */ K(je, {
|
|
806
796
|
price: e,
|
|
807
797
|
product: a?.data.find((t) => t.id === e.product_id)
|
|
808
|
-
}, e.id)), !o?.data?.length && /* @__PURE__ */ K(
|
|
798
|
+
}, e.id)), !o?.data?.length && /* @__PURE__ */ K(O, { children: /* @__PURE__ */ K(D, {
|
|
809
799
|
colSpan: 7,
|
|
810
800
|
className: "h-24 text-center text-muted-foreground",
|
|
811
|
-
children: /* @__PURE__ */ K(
|
|
801
|
+
children: /* @__PURE__ */ K(n, { id: "No prices yet." })
|
|
812
802
|
}) })] })] })
|
|
813
803
|
}),
|
|
814
|
-
/* @__PURE__ */ K(
|
|
815
|
-
pages:
|
|
804
|
+
/* @__PURE__ */ K(C, {
|
|
805
|
+
pages: i,
|
|
816
806
|
rows: o?.data?.length ?? 0,
|
|
817
807
|
nextCursor: o?.next_cursor,
|
|
818
808
|
busy: l,
|
|
@@ -825,48 +815,48 @@ function Pe() {
|
|
|
825
815
|
]
|
|
826
816
|
});
|
|
827
817
|
}
|
|
828
|
-
function
|
|
829
|
-
let { toast: o, toastApiError: s, adminMutations: c } =
|
|
818
|
+
function je({ price: e, product: t }) {
|
|
819
|
+
let { toast: o, toastApiError: s, adminMutations: c } = r(), l = t?.display_name ?? h(e.product_id, 13), u = V.useContext(X), d = W(), f = H(c.setPriceActive(d));
|
|
830
820
|
return /* @__PURE__ */ q(ee, {
|
|
831
821
|
to: `/catalog/prices/${encodeURIComponent(e.id)}`,
|
|
832
822
|
className: e.archived ? "opacity-60" : void 0,
|
|
833
823
|
children: [
|
|
834
|
-
/* @__PURE__ */ K(
|
|
824
|
+
/* @__PURE__ */ K(D, {
|
|
835
825
|
className: "text-xs text-muted-foreground",
|
|
836
|
-
children: /* @__PURE__ */ K(
|
|
826
|
+
children: /* @__PURE__ */ K(i, {
|
|
837
827
|
className: "underline-offset-2 hover:underline",
|
|
838
828
|
to: `/catalog/prices/${encodeURIComponent(e.id)}`,
|
|
839
829
|
children: e.id
|
|
840
830
|
})
|
|
841
831
|
}),
|
|
842
|
-
/* @__PURE__ */ K(
|
|
832
|
+
/* @__PURE__ */ K(D, {
|
|
843
833
|
className: "font-medium",
|
|
844
834
|
children: l
|
|
845
835
|
}),
|
|
846
|
-
/* @__PURE__ */ K(
|
|
836
|
+
/* @__PURE__ */ K(D, {
|
|
847
837
|
className: "tabular-nums",
|
|
848
838
|
children: se(e)
|
|
849
839
|
}),
|
|
850
|
-
/* @__PURE__ */ K(
|
|
851
|
-
/* @__PURE__ */ K(
|
|
840
|
+
/* @__PURE__ */ K(D, { children: ae(e) }),
|
|
841
|
+
/* @__PURE__ */ K(D, { children: /* @__PURE__ */ K("span", {
|
|
852
842
|
className: "flex flex-wrap gap-1",
|
|
853
|
-
children: e.provider ? /* @__PURE__ */ q(
|
|
843
|
+
children: e.provider ? /* @__PURE__ */ q(A, {
|
|
854
844
|
variant: "secondary",
|
|
855
|
-
children: [e.provider.psp, /* @__PURE__ */ K(
|
|
856
|
-
}) : (e.sell_via ?? []).map((e) => /* @__PURE__ */ K(
|
|
845
|
+
children: [e.provider.psp, /* @__PURE__ */ K(n, { id: "'s price" })]
|
|
846
|
+
}) : (e.sell_via ?? []).map((e) => /* @__PURE__ */ K(A, {
|
|
857
847
|
variant: "secondary",
|
|
858
848
|
children: e
|
|
859
849
|
}, e))
|
|
860
850
|
}) }),
|
|
861
|
-
/* @__PURE__ */ K(
|
|
851
|
+
/* @__PURE__ */ K(D, { children: e.archived ? /* @__PURE__ */ K(A, {
|
|
862
852
|
variant: "secondary",
|
|
863
|
-
children: /* @__PURE__ */ K(
|
|
853
|
+
children: /* @__PURE__ */ K(n, { id: "archived" })
|
|
864
854
|
}) : /* @__PURE__ */ K(te, { status: "active" }) }),
|
|
865
|
-
/* @__PURE__ */ K(
|
|
855
|
+
/* @__PURE__ */ K(D, {
|
|
866
856
|
className: "text-right",
|
|
867
857
|
children: u && /* @__PURE__ */ q("div", {
|
|
868
858
|
className: "flex justify-end gap-2",
|
|
869
|
-
children: [u && /* @__PURE__ */ K(
|
|
859
|
+
children: [u && /* @__PURE__ */ K(B, {
|
|
870
860
|
price: e,
|
|
871
861
|
productName: l,
|
|
872
862
|
productKey: t?.key
|
|
@@ -892,9 +882,9 @@ function Fe({ price: e, product: t }) {
|
|
|
892
882
|
]
|
|
893
883
|
});
|
|
894
884
|
}
|
|
895
|
-
var Q = ({ value: e }) => !e ||
|
|
896
|
-
function
|
|
897
|
-
let { toast:
|
|
885
|
+
var Q = ({ value: e }) => !e || z(e) ? void 0 : "Use hours, days or weeks, such as 30 days";
|
|
886
|
+
function Me({ products: e }) {
|
|
887
|
+
let { toast: i, toastApiError: s, adminMutations: c } = r(), { text: l, id: p } = t(), [m, h] = V.useState(!1), S = W(), C = H(c.createPrice(S)), w = Y({
|
|
898
888
|
defaultValues: {
|
|
899
889
|
productId: "",
|
|
900
890
|
amount: "",
|
|
@@ -903,17 +893,17 @@ function Ie({ products: t }) {
|
|
|
903
893
|
billingInterval: ""
|
|
904
894
|
},
|
|
905
895
|
onSubmit: async ({ value: e }) => {
|
|
906
|
-
let t =
|
|
896
|
+
let t = u(e.amount, e.currency);
|
|
907
897
|
if (t === null || BigInt(t) <= 0n) return;
|
|
908
|
-
let n =
|
|
909
|
-
if (!(e.accessDuration && !n || e.billingInterval && !
|
|
910
|
-
await
|
|
898
|
+
let n = z(e.accessDuration), r = z(e.billingInterval);
|
|
899
|
+
if (!(e.accessDuration && !n || e.billingInterval && !r)) try {
|
|
900
|
+
await C.mutateAsync({
|
|
911
901
|
product_id: e.productId,
|
|
912
902
|
unit_amount: t,
|
|
913
903
|
currency: e.currency,
|
|
914
904
|
...n ? { access_duration_hours: n } : {},
|
|
915
|
-
...
|
|
916
|
-
}), w.reset(),
|
|
905
|
+
...r ? { billing_interval_hours: r } : {}
|
|
906
|
+
}), w.reset(), i.success("Price created"), h(!1);
|
|
917
907
|
} catch (e) {
|
|
918
908
|
s(e, "Create price");
|
|
919
909
|
}
|
|
@@ -921,18 +911,18 @@ function Ie({ products: t }) {
|
|
|
921
911
|
}), T = (e) => {
|
|
922
912
|
e && w.reset(), h(e);
|
|
923
913
|
};
|
|
924
|
-
return /* @__PURE__ */ q(
|
|
925
|
-
open:
|
|
914
|
+
return /* @__PURE__ */ q(L, {
|
|
915
|
+
open: m,
|
|
926
916
|
onOpenChange: T,
|
|
927
|
-
children: [/* @__PURE__ */ K(
|
|
917
|
+
children: [/* @__PURE__ */ K(I, { render: /* @__PURE__ */ q(a, {
|
|
928
918
|
size: "sm",
|
|
929
919
|
children: [/* @__PURE__ */ K(J, {
|
|
930
|
-
icon:
|
|
920
|
+
icon: de,
|
|
931
921
|
className: "size-4"
|
|
932
|
-
}), /* @__PURE__ */ K(
|
|
933
|
-
}) }), /* @__PURE__ */ q(
|
|
922
|
+
}), /* @__PURE__ */ K(n, { id: " Price" })]
|
|
923
|
+
}) }), /* @__PURE__ */ q(N, {
|
|
934
924
|
className: re,
|
|
935
|
-
children: [/* @__PURE__ */ q(
|
|
925
|
+
children: [/* @__PURE__ */ q(j, { children: [/* @__PURE__ */ K(P, { children: /* @__PURE__ */ K(n, { id: "New price" }) }), /* @__PURE__ */ K(F, { children: /* @__PURE__ */ K(n, { id: "These terms cannot be changed later. To charge a different amount, create another price and deactivate this one." }) })] }), /* @__PURE__ */ q("form", {
|
|
936
926
|
onSubmit: (e) => {
|
|
937
927
|
e.preventDefault(), e.stopPropagation(), w.handleSubmit();
|
|
938
928
|
},
|
|
@@ -942,21 +932,21 @@ function Ie({ products: t }) {
|
|
|
942
932
|
children: [
|
|
943
933
|
/* @__PURE__ */ K(w.Field, {
|
|
944
934
|
name: "productId",
|
|
945
|
-
children: (
|
|
935
|
+
children: (t) => /* @__PURE__ */ K($, {
|
|
946
936
|
label: l("Product"),
|
|
947
937
|
id: "pr-prod",
|
|
948
|
-
children: /* @__PURE__ */ q(
|
|
949
|
-
items:
|
|
938
|
+
children: /* @__PURE__ */ q(x, {
|
|
939
|
+
items: e.map((e) => ({
|
|
950
940
|
value: e.id,
|
|
951
941
|
label: `${e.display_name} (${e.key})`
|
|
952
942
|
})),
|
|
953
|
-
value:
|
|
954
|
-
onValueChange: (
|
|
955
|
-
children: [/* @__PURE__ */ K(
|
|
956
|
-
id:
|
|
943
|
+
value: t.state.value || null,
|
|
944
|
+
onValueChange: (e) => t.handleChange(e ?? ""),
|
|
945
|
+
children: [/* @__PURE__ */ K(v, {
|
|
946
|
+
id: p("pr-prod"),
|
|
957
947
|
className: "w-full",
|
|
958
|
-
children: /* @__PURE__ */ K(
|
|
959
|
-
}), /* @__PURE__ */ K(
|
|
948
|
+
children: /* @__PURE__ */ K(_, { placeholder: l("Pick a product…") })
|
|
949
|
+
}), /* @__PURE__ */ K(y, { children: e.map((e) => /* @__PURE__ */ q(b, {
|
|
960
950
|
value: e.id,
|
|
961
951
|
children: [
|
|
962
952
|
e.display_name,
|
|
@@ -978,12 +968,12 @@ function Ie({ products: t }) {
|
|
|
978
968
|
name: "amount",
|
|
979
969
|
validators: {
|
|
980
970
|
onBlurListenTo: ["currency"],
|
|
981
|
-
onBlur: ({ value: e, fieldApi: t }) => BigInt(
|
|
971
|
+
onBlur: ({ value: e, fieldApi: t }) => BigInt(u(e, t.form.getFieldValue("currency")) ?? "0") > 0n ? void 0 : "Enter an amount greater than zero"
|
|
982
972
|
},
|
|
983
973
|
children: (e) => /* @__PURE__ */ q("div", {
|
|
984
974
|
className: "flex-1",
|
|
985
975
|
children: [/* @__PURE__ */ K(o, {
|
|
986
|
-
id:
|
|
976
|
+
id: p("pr-amount"),
|
|
987
977
|
type: "number",
|
|
988
978
|
step: "any",
|
|
989
979
|
min: "0",
|
|
@@ -991,17 +981,17 @@ function Ie({ products: t }) {
|
|
|
991
981
|
onBlur: e.handleBlur,
|
|
992
982
|
onChange: (t) => e.handleChange(t.target.value),
|
|
993
983
|
"aria-invalid": e.state.meta.errors.length > 0
|
|
994
|
-
}), /* @__PURE__ */ K(
|
|
984
|
+
}), /* @__PURE__ */ K(g, { errors: e.state.meta.errors })]
|
|
995
985
|
})
|
|
996
986
|
}), /* @__PURE__ */ K(w.Field, {
|
|
997
987
|
name: "currency",
|
|
998
|
-
validators: { onChange: ({ value: e }) =>
|
|
988
|
+
validators: { onChange: ({ value: e }) => f(e) === void 0 ? `Use ${d.join(", ")}` : void 0 },
|
|
999
989
|
children: (e) => /* @__PURE__ */ K(o, {
|
|
1000
|
-
id:
|
|
990
|
+
id: p("pr-cur"),
|
|
1001
991
|
"aria-label": l("Currency"),
|
|
1002
992
|
className: "w-24",
|
|
1003
993
|
value: e.state.value,
|
|
1004
|
-
maxLength: Math.max(...
|
|
994
|
+
maxLength: Math.max(...d.map((e) => e.length)),
|
|
1005
995
|
autoCapitalize: "characters",
|
|
1006
996
|
spellCheck: !1,
|
|
1007
997
|
placeholder: l("USD"),
|
|
@@ -1019,13 +1009,13 @@ function Ie({ products: t }) {
|
|
|
1019
1009
|
id: "pr-dur",
|
|
1020
1010
|
hint: "Such as 30 days, 1 week or 12 hours. Leave it empty for access that never expires.",
|
|
1021
1011
|
children: [/* @__PURE__ */ K(o, {
|
|
1022
|
-
id:
|
|
1012
|
+
id: p("pr-dur"),
|
|
1023
1013
|
placeholder: l("Never expires"),
|
|
1024
1014
|
value: e.state.value,
|
|
1025
1015
|
onBlur: e.handleBlur,
|
|
1026
1016
|
onChange: (t) => e.handleChange(t.target.value),
|
|
1027
1017
|
"aria-invalid": e.state.meta.errors.length > 0
|
|
1028
|
-
}), /* @__PURE__ */ K(
|
|
1018
|
+
}), /* @__PURE__ */ K(g, { errors: e.state.meta.errors })]
|
|
1029
1019
|
})
|
|
1030
1020
|
}),
|
|
1031
1021
|
/* @__PURE__ */ K(w.Field, {
|
|
@@ -1035,11 +1025,11 @@ function Ie({ products: t }) {
|
|
|
1035
1025
|
className: "grid gap-3 rounded-md border p-3",
|
|
1036
1026
|
children: [/* @__PURE__ */ q("div", {
|
|
1037
1027
|
className: "flex items-center justify-between gap-4",
|
|
1038
|
-
children: [/* @__PURE__ */ K(
|
|
1039
|
-
htmlFor:
|
|
1040
|
-
children: /* @__PURE__ */ K(
|
|
1028
|
+
children: [/* @__PURE__ */ K(R, {
|
|
1029
|
+
htmlFor: p("pr-renew"),
|
|
1030
|
+
children: /* @__PURE__ */ K(n, { id: "Recurring billing" })
|
|
1041
1031
|
}), /* @__PURE__ */ K(ne, {
|
|
1042
|
-
id:
|
|
1032
|
+
id: p("pr-renew"),
|
|
1043
1033
|
checked: !!e.state.value,
|
|
1044
1034
|
onCheckedChange: (t) => e.handleChange(t ? "30 days" : "")
|
|
1045
1035
|
})]
|
|
@@ -1048,25 +1038,25 @@ function Ie({ products: t }) {
|
|
|
1048
1038
|
id: "pr-billing",
|
|
1049
1039
|
hint: "Time between payments, such as 30 days, until the customer cancels.",
|
|
1050
1040
|
children: [/* @__PURE__ */ K(o, {
|
|
1051
|
-
id:
|
|
1041
|
+
id: p("pr-billing"),
|
|
1052
1042
|
required: !0,
|
|
1053
1043
|
value: e.state.value,
|
|
1054
1044
|
onBlur: e.handleBlur,
|
|
1055
1045
|
onChange: (t) => e.handleChange(t.target.value),
|
|
1056
1046
|
"aria-invalid": e.state.meta.errors.length > 0
|
|
1057
|
-
}), /* @__PURE__ */ K(
|
|
1047
|
+
}), /* @__PURE__ */ K(g, { errors: e.state.meta.errors })]
|
|
1058
1048
|
}) : /* @__PURE__ */ K("p", {
|
|
1059
1049
|
className: "text-xs text-muted-foreground",
|
|
1060
|
-
children: /* @__PURE__ */ K(
|
|
1050
|
+
children: /* @__PURE__ */ K(n, { id: "One-time payment." })
|
|
1061
1051
|
})]
|
|
1062
1052
|
})
|
|
1063
1053
|
})
|
|
1064
1054
|
]
|
|
1065
|
-
}), /* @__PURE__ */ q(
|
|
1055
|
+
}), /* @__PURE__ */ q(M, { children: [/* @__PURE__ */ K(a, {
|
|
1066
1056
|
type: "button",
|
|
1067
1057
|
variant: "outline",
|
|
1068
1058
|
onClick: () => T(!1),
|
|
1069
|
-
children: /* @__PURE__ */ K(
|
|
1059
|
+
children: /* @__PURE__ */ K(n, { id: "Cancel" })
|
|
1070
1060
|
}), /* @__PURE__ */ K(w.Subscribe, {
|
|
1071
1061
|
selector: (e) => [
|
|
1072
1062
|
e.values.productId,
|
|
@@ -1078,7 +1068,7 @@ function Ie({ products: t }) {
|
|
|
1078
1068
|
],
|
|
1079
1069
|
children: ([e, t, n, r, i, o]) => /* @__PURE__ */ K(a, {
|
|
1080
1070
|
type: "submit",
|
|
1081
|
-
disabled: o || !e || BigInt(
|
|
1071
|
+
disabled: o || !e || BigInt(u(t, n) ?? "0") <= 0n || Q({ value: r }) !== void 0 || Q({ value: i }) !== void 0,
|
|
1082
1072
|
children: o ? "Creating…" : "Create price"
|
|
1083
1073
|
})
|
|
1084
1074
|
})] })]
|
|
@@ -1086,101 +1076,14 @@ function Ie({ products: t }) {
|
|
|
1086
1076
|
})]
|
|
1087
1077
|
});
|
|
1088
1078
|
}
|
|
1089
|
-
function
|
|
1090
|
-
let {
|
|
1091
|
-
return /* @__PURE__ */ q("div", {
|
|
1092
|
-
className: "flex flex-col gap-3",
|
|
1093
|
-
children: [/* @__PURE__ */ K("div", {
|
|
1094
|
-
className: "flex justify-end",
|
|
1095
|
-
children: f && /* @__PURE__ */ q(a, {
|
|
1096
|
-
variant: "outline",
|
|
1097
|
-
size: "sm",
|
|
1098
|
-
disabled: g.isPending,
|
|
1099
|
-
onClick: async () => {
|
|
1100
|
-
try {
|
|
1101
|
-
await g.mutateAsync(), e.success("Re-reading every PSP: new drift appears here as it is found");
|
|
1102
|
-
} catch (e) {
|
|
1103
|
-
t(e, "Refresh drift");
|
|
1104
|
-
}
|
|
1105
|
-
},
|
|
1106
|
-
children: [/* @__PURE__ */ K(J, {
|
|
1107
|
-
icon: _e,
|
|
1108
|
-
className: g.isPending ? "size-4 animate-spin" : "size-4"
|
|
1109
|
-
}), /* @__PURE__ */ K(i, { id: "Refresh scan" })]
|
|
1110
|
-
})
|
|
1111
|
-
}), m ? /* @__PURE__ */ K("div", {
|
|
1112
|
-
className: "flex flex-col gap-3 py-2",
|
|
1113
|
-
children: Array.from({ length: 4 }).map((e, t) => /* @__PURE__ */ K(s, { className: "h-6 w-full" }, t))
|
|
1114
|
-
}) : p?.data?.length ? /* @__PURE__ */ K("div", {
|
|
1115
|
-
className: "overflow-x-auto",
|
|
1116
|
-
children: /* @__PURE__ */ q(j, { children: [/* @__PURE__ */ K(O, { children: /* @__PURE__ */ q(A, {
|
|
1117
|
-
className: "hover:bg-transparent",
|
|
1118
|
-
children: [
|
|
1119
|
-
/* @__PURE__ */ K(E, {
|
|
1120
|
-
className: "text-muted-foreground",
|
|
1121
|
-
children: /* @__PURE__ */ K(i, { id: "Provider" })
|
|
1122
|
-
}),
|
|
1123
|
-
/* @__PURE__ */ K(E, {
|
|
1124
|
-
className: "text-muted-foreground",
|
|
1125
|
-
children: /* @__PURE__ */ K(i, { id: "Kind" })
|
|
1126
|
-
}),
|
|
1127
|
-
/* @__PURE__ */ K(E, {
|
|
1128
|
-
className: "text-muted-foreground",
|
|
1129
|
-
children: /* @__PURE__ */ K(i, { id: "Resource" })
|
|
1130
|
-
}),
|
|
1131
|
-
/* @__PURE__ */ K(E, {
|
|
1132
|
-
className: "text-muted-foreground",
|
|
1133
|
-
children: /* @__PURE__ */ K(i, { id: "Field" })
|
|
1134
|
-
}),
|
|
1135
|
-
/* @__PURE__ */ K(E, {
|
|
1136
|
-
className: "text-muted-foreground",
|
|
1137
|
-
children: /* @__PURE__ */ K(i, { id: "OpenRails" })
|
|
1138
|
-
}),
|
|
1139
|
-
/* @__PURE__ */ K(E, {
|
|
1140
|
-
className: "text-muted-foreground",
|
|
1141
|
-
children: /* @__PURE__ */ K(i, { id: "Remote" })
|
|
1142
|
-
}),
|
|
1143
|
-
/* @__PURE__ */ K(E, {
|
|
1144
|
-
className: "text-muted-foreground",
|
|
1145
|
-
children: /* @__PURE__ */ K(i, { id: "Detected" })
|
|
1146
|
-
})
|
|
1147
|
-
]
|
|
1148
|
-
}) }), /* @__PURE__ */ K(D, { children: p.data.map((e) => /* @__PURE__ */ q(A, { children: [
|
|
1149
|
-
/* @__PURE__ */ K(k, { children: e.provider ?? "—" }),
|
|
1150
|
-
/* @__PURE__ */ K(k, { children: e.finding_type.replace(/^catalog\./, "") }),
|
|
1151
|
-
/* @__PURE__ */ q(k, {
|
|
1152
|
-
className: "text-xs",
|
|
1153
|
-
children: [
|
|
1154
|
-
e.resource_type,
|
|
1155
|
-
" ",
|
|
1156
|
-
_(e.resource_id || e.external_resource_id || "", 13)
|
|
1157
|
-
]
|
|
1158
|
-
}),
|
|
1159
|
-
/* @__PURE__ */ K(k, { children: e.field || "—" }),
|
|
1160
|
-
/* @__PURE__ */ K(k, {
|
|
1161
|
-
className: "max-w-40 truncate",
|
|
1162
|
-
children: e.openrails_value || "—"
|
|
1163
|
-
}),
|
|
1164
|
-
/* @__PURE__ */ K(k, {
|
|
1165
|
-
className: "max-w-40 truncate",
|
|
1166
|
-
children: e.external_value || "—"
|
|
1167
|
-
}),
|
|
1168
|
-
/* @__PURE__ */ K(k, { children: h(e.created_at) })
|
|
1169
|
-
] }, e.id)) })] })
|
|
1170
|
-
}) : /* @__PURE__ */ K("p", {
|
|
1171
|
-
className: "text-sm text-muted-foreground",
|
|
1172
|
-
children: /* @__PURE__ */ K(i, { id: "No open drift events. Catalog is in sync." })
|
|
1173
|
-
})]
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
function $({ label: t, id: n, hint: r, children: i }) {
|
|
1177
|
-
let { id: a } = e();
|
|
1079
|
+
function $({ label: e, id: n, hint: r, children: i }) {
|
|
1080
|
+
let { id: a } = t();
|
|
1178
1081
|
return /* @__PURE__ */ q("div", {
|
|
1179
1082
|
className: "grid gap-1.5",
|
|
1180
1083
|
children: [
|
|
1181
|
-
/* @__PURE__ */ K(
|
|
1084
|
+
/* @__PURE__ */ K(R, {
|
|
1182
1085
|
htmlFor: a(n),
|
|
1183
|
-
children:
|
|
1086
|
+
children: e
|
|
1184
1087
|
}),
|
|
1185
1088
|
r ? /* @__PURE__ */ K("p", {
|
|
1186
1089
|
className: "text-[13px] text-muted-foreground",
|
|
@@ -1191,6 +1094,6 @@ function $({ label: t, id: n, hint: r, children: i }) {
|
|
|
1191
1094
|
});
|
|
1192
1095
|
}
|
|
1193
1096
|
//#endregion
|
|
1194
|
-
export {
|
|
1097
|
+
export { Te as CatalogPricesPage, we as CatalogProductsPage };
|
|
1195
1098
|
|
|
1196
|
-
//# sourceMappingURL=admin-catalog-
|
|
1099
|
+
//# sourceMappingURL=admin-catalog-BlF5mnu4.js.map
|