@openrails/billing-ui 0.272.0 → 0.274.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.
Files changed (160) hide show
  1. package/dist/admin/components/customer-search.d.ts +5 -0
  2. package/dist/admin/components/missing-record.d.ts +6 -0
  3. package/dist/admin/components/status-badge.d.ts +1 -0
  4. package/dist/admin/context.d.ts +20 -2
  5. package/dist/admin/lib/api/endpoints.d.ts +3 -1
  6. package/dist/admin/lib/api/index.d.ts +2 -0
  7. package/dist/admin/lib/api/types.d.ts +2 -0
  8. package/dist/admin/lib/capabilities.d.ts +4 -0
  9. package/dist/admin/lib/dialog-width.d.ts +4 -3
  10. package/dist/admin/lib/error-text.d.ts +4 -0
  11. package/dist/admin/lib/mutations.d.ts +6 -1
  12. package/dist/admin/lib/queries.d.ts +3 -0
  13. package/dist/admin/lib/tile-grids.d.ts +6 -0
  14. package/dist/admin/messages.d.ts +89 -0
  15. package/dist/admin/pages/payments/index.d.ts +1 -2
  16. package/dist/admin/pages/subscriptions/index.d.ts +1 -2
  17. package/dist/{admin-attempts-DyDDt-qw.js → admin-attempts-Dzipkstg.js} +145 -144
  18. package/dist/admin-attempts-Dzipkstg.js.map +1 -0
  19. package/dist/{admin-auth-1aZIgXiS.js → admin-auth-BCl_Tv3t.js} +2 -2
  20. package/dist/{admin-auth-1aZIgXiS.js.map → admin-auth-BCl_Tv3t.js.map} +1 -1
  21. package/dist/{admin-badge-pgG6D9-a.js → admin-badge-kmYQM9Ge.js} +2 -2
  22. package/dist/{admin-badge-pgG6D9-a.js.map → admin-badge-kmYQM9Ge.js.map} +1 -1
  23. package/dist/{admin-button-CrcYk5r0.js → admin-button-Cq9ZfX4R.js} +2 -2
  24. package/dist/{admin-button-CrcYk5r0.js.map → admin-button-Cq9ZfX4R.js.map} +1 -1
  25. package/dist/{admin-capabilities-BDcZeHL_.js → admin-capabilities-k5fQZhN9.js} +35 -14
  26. package/dist/admin-capabilities-k5fQZhN9.js.map +1 -0
  27. package/dist/{admin-card-DvTMc5Se.js → admin-card-C8k67jJv.js} +2 -2
  28. package/dist/{admin-card-DvTMc5Se.js.map → admin-card-C8k67jJv.js.map} +1 -1
  29. package/dist/{admin-catalog-BlF5mnu4.js → admin-catalog-CON-GwKL.js} +286 -286
  30. package/dist/{admin-catalog-BlF5mnu4.js.map → admin-catalog-CON-GwKL.js.map} +1 -1
  31. package/dist/{admin-cursor-pager-CIb3Jw2F.js → admin-cursor-pager-DqFruoNu.js} +6 -6
  32. package/dist/{admin-cursor-pager-CIb3Jw2F.js.map → admin-cursor-pager-DqFruoNu.js.map} +1 -1
  33. package/dist/admin-customer-search-CJHB80rg.js +117 -0
  34. package/dist/admin-customer-search-CJHB80rg.js.map +1 -0
  35. package/dist/{admin-customers-EpfoWDh-.js → admin-customers-CWWOrcVR.js} +18 -17
  36. package/dist/{admin-customers-EpfoWDh-.js.map → admin-customers-CWWOrcVR.js.map} +1 -1
  37. package/dist/admin-dashboard-BiShWFk2.js +456 -0
  38. package/dist/admin-dashboard-BiShWFk2.js.map +1 -0
  39. package/dist/admin-data-table-CdsjYJh5.js +107 -0
  40. package/dist/admin-data-table-CdsjYJh5.js.map +1 -0
  41. package/dist/admin-detail-BWSC1aCH.js +338 -0
  42. package/dist/admin-detail-BWSC1aCH.js.map +1 -0
  43. package/dist/admin-detail-CKRtK43V.js +728 -0
  44. package/dist/admin-detail-CKRtK43V.js.map +1 -0
  45. package/dist/admin-detail-CMmhZQ2A.js +346 -0
  46. package/dist/admin-detail-CMmhZQ2A.js.map +1 -0
  47. package/dist/admin-detail-CiONe1Pt.js +1357 -0
  48. package/dist/admin-detail-CiONe1Pt.js.map +1 -0
  49. package/dist/{admin-detail-3wFIDPNB.js → admin-detail-Cyuf_i9U.js} +62 -62
  50. package/dist/{admin-detail-3wFIDPNB.js.map → admin-detail-Cyuf_i9U.js.map} +1 -1
  51. package/dist/{admin-dialog-BSRf9Zre.js → admin-dialog-Ch7rTOCr.js} +3 -3
  52. package/dist/{admin-dialog-BSRf9Zre.js.map → admin-dialog-Ch7rTOCr.js.map} +1 -1
  53. package/dist/admin-dialog-width-CC7QHT1p.js +6 -0
  54. package/dist/admin-dialog-width-CC7QHT1p.js.map +1 -0
  55. package/dist/{admin-dropdown-menu-D0E5rwmn.js → admin-dropdown-menu-Bah3f8AZ.js} +2 -2
  56. package/dist/{admin-dropdown-menu-D0E5rwmn.js.map → admin-dropdown-menu-Bah3f8AZ.js.map} +1 -1
  57. package/dist/{admin-fact-card-BPSVhS15.js → admin-fact-card-Bt__Cd_U.js} +2 -2
  58. package/dist/{admin-fact-card-BPSVhS15.js.map → admin-fact-card-Bt__Cd_U.js.map} +1 -1
  59. package/dist/{admin-health-D0L5Kig7.js → admin-health-pzTO6_0v.js} +249 -248
  60. package/dist/admin-health-pzTO6_0v.js.map +1 -0
  61. package/dist/{admin-imports-CgZB5JAV.js → admin-imports-tT5et8-V.js} +62 -62
  62. package/dist/{admin-imports-CgZB5JAV.js.map → admin-imports-tT5et8-V.js.map} +1 -1
  63. package/dist/{admin-input-DJAK9nmk.js → admin-input-DvRZy_2a.js} +2 -2
  64. package/dist/{admin-input-DJAK9nmk.js.map → admin-input-DvRZy_2a.js.map} +1 -1
  65. package/dist/{admin-label-aviN9Gng.js → admin-label-QZtWJGH-.js} +2 -2
  66. package/dist/{admin-label-aviN9Gng.js.map → admin-label-QZtWJGH-.js.map} +1 -1
  67. package/dist/{admin-linked-table-row-BGr7JXeM.js → admin-linked-table-row-6jkCKwMn.js} +4 -4
  68. package/dist/{admin-linked-table-row-BGr7JXeM.js.map → admin-linked-table-row-6jkCKwMn.js.map} +1 -1
  69. package/dist/{admin-map-dialog-DS2Wz6G3.js → admin-map-dialog-BV54mvMQ.js} +22 -22
  70. package/dist/{admin-map-dialog-DS2Wz6G3.js.map → admin-map-dialog-BV54mvMQ.js.map} +1 -1
  71. package/dist/{admin-metering-D-e-37Jn.js → admin-metering-Bv5EcX6M.js} +306 -306
  72. package/dist/{admin-metering-D-e-37Jn.js.map → admin-metering-Bv5EcX6M.js.map} +1 -1
  73. package/dist/admin-missing-record-BXqGFDt3.js +42 -0
  74. package/dist/admin-missing-record-BXqGFDt3.js.map +1 -0
  75. package/dist/admin-ops-h3RjpcNu.js +356 -0
  76. package/dist/admin-ops-h3RjpcNu.js.map +1 -0
  77. package/dist/admin-orders-DYxPiuTl.js +192 -0
  78. package/dist/admin-orders-DYxPiuTl.js.map +1 -0
  79. package/dist/{admin-parked-B8xHkV2e.js → admin-parked-ClKA60d5.js} +51 -51
  80. package/dist/{admin-parked-B8xHkV2e.js.map → admin-parked-ClKA60d5.js.map} +1 -1
  81. package/dist/admin-payments-BlIuy3wL.js +220 -0
  82. package/dist/admin-payments-BlIuy3wL.js.map +1 -0
  83. package/dist/{admin-price-detail-CSI5oKdb.js → admin-price-detail-BjWYU5A-.js} +98 -98
  84. package/dist/{admin-price-detail-CSI5oKdb.js.map → admin-price-detail-BjWYU5A-.js.map} +1 -1
  85. package/dist/{admin-price-wizard-CBEcNGvP.js → admin-price-wizard-CTbkbmYc.js} +61 -61
  86. package/dist/{admin-price-wizard-CBEcNGvP.js.map → admin-price-wizard-CTbkbmYc.js.map} +1 -1
  87. package/dist/{admin-proposals-Cuj7tvaM.js → admin-proposals-Ci9Q8j7Y.js} +64 -64
  88. package/dist/{admin-proposals-Cuj7tvaM.js.map → admin-proposals-Ci9Q8j7Y.js.map} +1 -1
  89. package/dist/{admin-provider-prices-B6vwnVPi.js → admin-provider-prices-B6Ayq-eN.js} +66 -66
  90. package/dist/{admin-provider-prices-B6vwnVPi.js.map → admin-provider-prices-B6Ayq-eN.js.map} +1 -1
  91. package/dist/{admin-range-picker-De36L-AP.js → admin-range-picker-nfflPp21.js} +9 -9
  92. package/dist/{admin-range-picker-De36L-AP.js.map → admin-range-picker-nfflPp21.js.map} +1 -1
  93. package/dist/{admin-records-H0MlhEVY.js → admin-records-CrTCorWH.js} +43 -43
  94. package/dist/{admin-records-H0MlhEVY.js.map → admin-records-CrTCorWH.js.map} +1 -1
  95. package/dist/{admin-reports-BFGS_PWf.js → admin-reports-BO6wrvtw.js} +50 -50
  96. package/dist/{admin-reports-BFGS_PWf.js.map → admin-reports-BO6wrvtw.js.map} +1 -1
  97. package/dist/{admin-select-BUcEU5Rg.js → admin-select-DvfJ80Rg.js} +2 -2
  98. package/dist/{admin-select-BUcEU5Rg.js.map → admin-select-DvfJ80Rg.js.map} +1 -1
  99. package/dist/{admin-settings-DYC-c7mJ.js → admin-settings-BOoTzhyf.js} +332 -332
  100. package/dist/admin-settings-BOoTzhyf.js.map +1 -0
  101. package/dist/{admin-shared-lfIUEbPY.js → admin-shared-BbGT_qTo.js} +21 -21
  102. package/dist/{admin-shared-lfIUEbPY.js.map → admin-shared-BbGT_qTo.js.map} +1 -1
  103. package/dist/{admin-skeleton-B0yzYY_X.js → admin-skeleton-B2a4ScVE.js} +2 -2
  104. package/dist/{admin-skeleton-B0yzYY_X.js.map → admin-skeleton-B2a4ScVE.js.map} +1 -1
  105. package/dist/admin-status-badge-Bp6cssXY.js +51 -0
  106. package/dist/admin-status-badge-Bp6cssXY.js.map +1 -0
  107. package/dist/admin-subscriptions-D9JmoicC.js +275 -0
  108. package/dist/admin-subscriptions-D9JmoicC.js.map +1 -0
  109. package/dist/{admin-switch-DDorugaw.js → admin-switch-DBBxJRZP.js} +2 -2
  110. package/dist/{admin-switch-DDorugaw.js.map → admin-switch-DBBxJRZP.js.map} +1 -1
  111. package/dist/{admin-table-BU6Tie69.js → admin-table-CPDoVfK4.js} +2 -2
  112. package/dist/{admin-table-BU6Tie69.js.map → admin-table-CPDoVfK4.js.map} +1 -1
  113. package/dist/{admin-tabs-D5lqdVcC.js → admin-tabs-DDUv3kiu.js} +2 -2
  114. package/dist/{admin-tabs-D5lqdVcC.js.map → admin-tabs-DDUv3kiu.js.map} +1 -1
  115. package/dist/{admin-textarea-Dc6lnEub.js → admin-textarea-d3fu_waS.js} +2 -2
  116. package/dist/{admin-textarea-Dc6lnEub.js.map → admin-textarea-d3fu_waS.js.map} +1 -1
  117. package/dist/admin-tile-grids-CzGpidd9.js +6 -0
  118. package/dist/admin-tile-grids-CzGpidd9.js.map +1 -0
  119. package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js → admin-typed-confirm-dialog-BVklYjFo.js} +11 -11
  120. package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js.map → admin-typed-confirm-dialog-BVklYjFo.js.map} +1 -1
  121. package/dist/{admin-utils-B9eEBNsR.js → admin-utils-DTT53IpS.js} +266 -223
  122. package/dist/admin-utils-DTT53IpS.js.map +1 -0
  123. package/dist/{admin-widget-viz-8aukE3v_.js → admin-widget-viz-Exsqz3Dw.js} +165 -128
  124. package/dist/admin-widget-viz-Exsqz3Dw.js.map +1 -0
  125. package/dist/admin.css +1 -1
  126. package/dist/admin.js +531 -405
  127. package/dist/admin.js.map +1 -1
  128. package/dist/index.js +1 -1
  129. package/dist/styles.css +1 -1
  130. package/package.json +1 -1
  131. package/dist/admin-attempts-DyDDt-qw.js.map +0 -1
  132. package/dist/admin-capabilities-BDcZeHL_.js.map +0 -1
  133. package/dist/admin-dashboard-CJE63yz4.js +0 -420
  134. package/dist/admin-dashboard-CJE63yz4.js.map +0 -1
  135. package/dist/admin-data-table-hvFcJepL.js +0 -96
  136. package/dist/admin-data-table-hvFcJepL.js.map +0 -1
  137. package/dist/admin-detail-BRP6pL7t.js +0 -328
  138. package/dist/admin-detail-BRP6pL7t.js.map +0 -1
  139. package/dist/admin-detail-CRzFb_pa.js +0 -1331
  140. package/dist/admin-detail-CRzFb_pa.js.map +0 -1
  141. package/dist/admin-detail-QLxU8r-5.js +0 -344
  142. package/dist/admin-detail-QLxU8r-5.js.map +0 -1
  143. package/dist/admin-detail-pPC8Q9l-.js +0 -710
  144. package/dist/admin-detail-pPC8Q9l-.js.map +0 -1
  145. package/dist/admin-dialog-width-BPrgdYlj.js +0 -6
  146. package/dist/admin-dialog-width-BPrgdYlj.js.map +0 -1
  147. package/dist/admin-health-D0L5Kig7.js.map +0 -1
  148. package/dist/admin-ops-CQP4TzWM.js +0 -235
  149. package/dist/admin-ops-CQP4TzWM.js.map +0 -1
  150. package/dist/admin-orders-BJ7W5S8P.js +0 -192
  151. package/dist/admin-orders-BJ7W5S8P.js.map +0 -1
  152. package/dist/admin-payments-CzkzqYA1.js +0 -246
  153. package/dist/admin-payments-CzkzqYA1.js.map +0 -1
  154. package/dist/admin-settings-DYC-c7mJ.js.map +0 -1
  155. package/dist/admin-status-badge-0-K37EfN.js +0 -43
  156. package/dist/admin-status-badge-0-K37EfN.js.map +0 -1
  157. package/dist/admin-subscriptions-CvW-YFs0.js +0 -301
  158. package/dist/admin-subscriptions-CvW-YFs0.js.map +0 -1
  159. package/dist/admin-utils-B9eEBNsR.js.map +0 -1
  160. package/dist/admin-widget-viz-8aukE3v_.js.map +0 -1
@@ -1,1331 +0,0 @@
1
- import { D as e, T as t, c as n, f as r, p as i, r as a, s as o } from "./admin-utils-B9eEBNsR.js";
2
- import { t as s } from "./admin-button-CrcYk5r0.js";
3
- import { t as c } from "./admin-input-DJAK9nmk.js";
4
- import { a as l } from "./admin-capabilities-BDcZeHL_.js";
5
- import { t as u } from "./admin-auth-1aZIgXiS.js";
6
- import { a as d, i as f, n as p, o as m, s as h, t as g, u as _ } from "./admin-format-DoohJ7Fg.js";
7
- import { n as v } from "./admin-confirm-katGq0Qo.js";
8
- import { t as y } from "./admin-form-field-errors-hbUMIriS.js";
9
- import { a as b, i as x, n as S, r as C, t as w } from "./admin-select-BUcEU5Rg.js";
10
- import { n as T, t as E } from "./admin-cursor-pager-CIb3Jw2F.js";
11
- import { a as D, n as O, o as k, r as A, s as j, t as M } from "./admin-table-BU6Tie69.js";
12
- import { t as N } from "./admin-linked-table-row-BGr7JXeM.js";
13
- import { t as P } from "./admin-badge-pgG6D9-a.js";
14
- import { t as F } from "./admin-status-badge-0-K37EfN.js";
15
- import { a as I, i as L, n as R, o as z, r as B, s as ee, t as V } from "./admin-dialog-BSRf9Zre.js";
16
- import { t as H } from "./admin-label-aviN9Gng.js";
17
- import { n as te } from "./admin-dialog-width-BPrgdYlj.js";
18
- import { a as U, o as W, r as G, t as K } from "./admin-card-DvTMc5Se.js";
19
- import { n as ne, t as re } from "./admin-invoice-profile-model-Cgjy3zV8.js";
20
- import { t as ie } from "./admin-dunning-B2zgtrOo.js";
21
- import * as q from "react";
22
- import { useState as ae } from "react";
23
- import { useMutation as J, useQuery as Y, useQueryClient as X } from "@tanstack/react-query";
24
- import { Fragment as oe, jsx as Z, jsxs as Q } from "react/jsx-runtime";
25
- import { HugeiconsIcon as se } from "@hugeicons/react";
26
- import { Add01Icon as ce, ArrowLeft01Icon as le, Delete02Icon as ue } from "@hugeicons/core-free-icons";
27
- import { useForm as de } from "@tanstack/react-form";
28
- //#region src/admin/pages/customers/invoice-profile.tsx
29
- function fe({ customerId: e }) {
30
- let { orderQueries: n } = i(), r = l(), o = Y(n.profile(e));
31
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(W, { children: /* @__PURE__ */ Z(t, { id: "Invoice profile" }) }) }), /* @__PURE__ */ Q(G, { children: [/* @__PURE__ */ Z(a, {
32
- className: "text-sm underline",
33
- to: `/orders?customer_id=${e}&origin=usage`,
34
- children: /* @__PURE__ */ Z(t, { id: "View customer usage orders" })
35
- }), o.isPending ? /* @__PURE__ */ Z("p", { children: /* @__PURE__ */ Z(t, { id: "Loading invoice profile…" }) }) : o.error ? /* @__PURE__ */ Z("p", {
36
- role: "alert",
37
- className: "text-destructive",
38
- children: o.error.message
39
- }) : /* @__PURE__ */ Z(pe, {
40
- customerId: e,
41
- profile: o.data,
42
- readOnly: !r
43
- }, e)] })] });
44
- }
45
- function pe({ customerId: n, profile: r, readOnly: a = !1 }) {
46
- let { id: o, text: l } = e(), { invoiceProfileMutation: u } = i(), [d, f] = ae(() => ne(r)), [p, m] = ae(null), [h, g] = ae(!1), _ = X(), v = J(u(_, n)), y = (e) => {
47
- f((t) => ({
48
- ...t,
49
- ...e
50
- })), g(!1);
51
- };
52
- async function b() {
53
- m(null), g(!1);
54
- try {
55
- await v.mutateAsync(re(d, r)), g(!0);
56
- } catch (e) {
57
- m(e instanceof Error ? e.message : "Invoice profile update failed.");
58
- }
59
- }
60
- return /* @__PURE__ */ Q("form", {
61
- className: "mt-4 space-y-4",
62
- onSubmit: (e) => {
63
- e.preventDefault(), v.isPending || b();
64
- },
65
- children: [
66
- /* @__PURE__ */ Z("p", {
67
- className: "text-sm text-muted-foreground",
68
- children: /* @__PURE__ */ Z(t, { id: "Terms and billing facts for future usage orders. Billed orders keep their original snapshots. Tax details are recorded; no tax is calculated." })
69
- }),
70
- /* @__PURE__ */ Q("fieldset", {
71
- disabled: a || v.isPending,
72
- className: "space-y-4",
73
- children: [
74
- /* @__PURE__ */ Q("div", {
75
- className: "grid gap-3 sm:grid-cols-2",
76
- children: [/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(H, {
77
- htmlFor: o("invoice-profile-terms"),
78
- children: /* @__PURE__ */ Z(t, { id: "Payment terms (days)" })
79
- }), /* @__PURE__ */ Z(c, {
80
- id: o("invoice-profile-terms"),
81
- type: "number",
82
- min: 0,
83
- step: 1,
84
- value: d.terms,
85
- onChange: (e) => y({ terms: e.target.value })
86
- })] }), /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(H, {
87
- htmlFor: o("invoice-profile-method"),
88
- children: /* @__PURE__ */ Z(t, { id: "Collection method" })
89
- }), /* @__PURE__ */ Q("select", {
90
- id: o("invoice-profile-method"),
91
- className: "h-9 w-full rounded-md border bg-background px-2",
92
- value: d.method,
93
- onChange: (e) => y({ method: e.target.value }),
94
- children: [/* @__PURE__ */ Z("option", {
95
- value: "charge_automatically",
96
- children: /* @__PURE__ */ Z(t, { id: "Saved payment method" })
97
- }), /* @__PURE__ */ Z("option", {
98
- value: "send_invoice",
99
- children: /* @__PURE__ */ Z(t, { id: "Manual remittance" })
100
- })]
101
- })] })]
102
- }),
103
- /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(H, {
104
- htmlFor: o("invoice-profile-po"),
105
- children: /* @__PURE__ */ Z(t, { id: "Purchase order" })
106
- }), /* @__PURE__ */ Z(c, {
107
- id: o("invoice-profile-po"),
108
- value: d.po,
109
- onChange: (e) => y({ po: e.target.value })
110
- })] }),
111
- /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(H, {
112
- htmlFor: o("invoice-profile-memo"),
113
- children: /* @__PURE__ */ Z(t, { id: "Invoice memo" })
114
- }), /* @__PURE__ */ Z(c, {
115
- id: o("invoice-profile-memo"),
116
- value: d.memo,
117
- onChange: (e) => y({ memo: e.target.value })
118
- })] }),
119
- /* @__PURE__ */ Q("div", {
120
- className: "space-y-2",
121
- children: [
122
- /* @__PURE__ */ Z("p", {
123
- className: "text-sm font-medium",
124
- children: /* @__PURE__ */ Z(t, { id: "Billing contacts" })
125
- }),
126
- d.contacts.map((e, n) => /* @__PURE__ */ Q("div", {
127
- className: "flex gap-2",
128
- children: [
129
- /* @__PURE__ */ Z(c, {
130
- "aria-label": `Contact ${n + 1} name`,
131
- placeholder: l("Name"),
132
- value: e.name,
133
- onChange: (e) => y({ contacts: d.contacts.map((t, r) => r === n ? {
134
- ...t,
135
- name: e.target.value
136
- } : t) })
137
- }),
138
- /* @__PURE__ */ Z(c, {
139
- "aria-label": `Contact ${n + 1} email`,
140
- type: "email",
141
- placeholder: l("Email"),
142
- value: e.email,
143
- onChange: (e) => y({ contacts: d.contacts.map((t, r) => r === n ? {
144
- ...t,
145
- email: e.target.value
146
- } : t) })
147
- }),
148
- /* @__PURE__ */ Z(s, {
149
- type: "button",
150
- variant: "outline",
151
- "aria-label": `Remove contact ${n + 1}`,
152
- onClick: () => y({ contacts: d.contacts.filter((e, t) => t !== n) }),
153
- children: /* @__PURE__ */ Z(t, { id: "Remove" })
154
- })
155
- ]
156
- }, n)),
157
- /* @__PURE__ */ Z(s, {
158
- type: "button",
159
- variant: "outline",
160
- onClick: () => y({ contacts: [...d.contacts, {
161
- name: "",
162
- email: ""
163
- }] }),
164
- children: /* @__PURE__ */ Z(t, { id: "Add contact" })
165
- })
166
- ]
167
- }),
168
- /* @__PURE__ */ Q("div", {
169
- className: "space-y-2",
170
- children: [
171
- /* @__PURE__ */ Z("p", {
172
- className: "text-sm font-medium",
173
- children: /* @__PURE__ */ Z(t, { id: "Tax details" })
174
- }),
175
- d.tax.map((e, n) => /* @__PURE__ */ Q("div", {
176
- className: "flex gap-2",
177
- children: [
178
- /* @__PURE__ */ Z(c, {
179
- "aria-label": `Tax detail ${n + 1} name`,
180
- placeholder: l("Name, such as tax_id"),
181
- value: e.key,
182
- onChange: (e) => y({ tax: d.tax.map((t, r) => r === n ? {
183
- ...t,
184
- key: e.target.value
185
- } : t) })
186
- }),
187
- /* @__PURE__ */ Z(c, {
188
- "aria-label": `Tax detail ${n + 1} value`,
189
- placeholder: l("Value"),
190
- value: e.value,
191
- onChange: (e) => y({ tax: d.tax.map((t, r) => r === n ? {
192
- ...t,
193
- value: e.target.value
194
- } : t) })
195
- }),
196
- /* @__PURE__ */ Z(s, {
197
- type: "button",
198
- variant: "outline",
199
- "aria-label": `Remove tax detail ${n + 1}`,
200
- onClick: () => y({ tax: d.tax.filter((e, t) => t !== n) }),
201
- children: /* @__PURE__ */ Z(t, { id: "Remove" })
202
- })
203
- ]
204
- }, n)),
205
- /* @__PURE__ */ Z(s, {
206
- type: "button",
207
- variant: "outline",
208
- onClick: () => y({ tax: [...d.tax, {
209
- key: "",
210
- value: ""
211
- }] }),
212
- children: /* @__PURE__ */ Z(t, { id: "Add tax detail" })
213
- })
214
- ]
215
- })
216
- ]
217
- }),
218
- p && /* @__PURE__ */ Z("p", {
219
- role: "alert",
220
- className: "text-destructive",
221
- children: p
222
- }),
223
- h && /* @__PURE__ */ Z("p", {
224
- role: "status",
225
- className: "text-sm",
226
- children: /* @__PURE__ */ Z(t, { id: "Invoice profile saved. Billed orders were not changed." })
227
- }),
228
- !a && /* @__PURE__ */ Z(s, {
229
- type: "submit",
230
- disabled: v.isPending,
231
- children: v.isPending ? "Saving…" : "Save invoice profile"
232
- })
233
- ]
234
- });
235
- }
236
- //#endregion
237
- //#region src/admin/pages/customers/default-card-badges.tsx
238
- function me({ currencies: e = [] }) {
239
- return /* @__PURE__ */ Z(oe, { children: e.map((e) => /* @__PURE__ */ Q(P, {
240
- variant: "secondary",
241
- className: "mt-1 mr-1",
242
- children: [/* @__PURE__ */ Z(t, { id: "Default · " }), e]
243
- }, e)) });
244
- }
245
- //#endregion
246
- //#region src/admin/pages/customers/credit-form.ts
247
- function he(e, t = Date.now()) {
248
- let n = g(e.amount, e.decimals);
249
- if (n === null || BigInt(n) <= 0n) throw Error(`Enter a positive amount with at most ${e.decimals} decimal places, within the supported range.`);
250
- let r = e.currency.trim();
251
- if (!r) throw Error("Select a currency.");
252
- let i;
253
- if (e.expires) {
254
- let n = new Date(e.expires).getTime();
255
- if (!Number.isFinite(n) || n <= t) throw Error("Expiry must be a valid future date.");
256
- i = new Date(n).toISOString();
257
- }
258
- return {
259
- amount: n,
260
- currency: r,
261
- source: "admin",
262
- source_id: e.sourceID,
263
- expires_at: i,
264
- description: e.description.trim() || void 0
265
- };
266
- }
267
- function ge(e) {
268
- return (e.state === "active" || e.state === "scheduled") && /^\d+$/.test(e.remaining_amount) && BigInt(e.remaining_amount) > 0n;
269
- }
270
- function _e(e, t) {
271
- if (!ge(e)) throw Error("This grant has no remaining credit to revoke.");
272
- if (t = t.trim(), !t || t.length > 500) throw Error("Enter a reason of up to 500 characters.");
273
- return {
274
- grant: e.id,
275
- reason: t
276
- };
277
- }
278
- //#endregion
279
- //#region src/admin/pages/customers/credits.tsx
280
- var $ = (e) => e instanceof Error ? e.message : "The request failed. Try again.";
281
- function ve({ customerId: e, currencies: t }) {
282
- let { activeMerchant: n } = u(), r = n?.slug ?? "";
283
- return /* @__PURE__ */ Z(ye, {
284
- merchant: r,
285
- customer: e,
286
- initialCurrency: t[0] ?? "USD"
287
- }, `${r}:${e}`);
288
- }
289
- function ye({ merchant: n, customer: r, initialCurrency: a }) {
290
- let { id: o, text: u } = e(), { creditQueries: d } = i(), f = l(), [g, v] = q.useState(a), [y, b] = q.useState(a), x = T(g, 25), S = T(g, 25), [C, w] = q.useState(!1), [N, P] = q.useState(null), F = Y(d.grants(n, r, g, x.size, x.cursor)), I = Y(d.transactions(n, r, g, S.size, S.cursor)), L = p(g);
291
- return /* @__PURE__ */ Q(K, { children: [
292
- /* @__PURE__ */ Q(U, {
293
- className: "gap-3",
294
- children: [
295
- /* @__PURE__ */ Q("div", {
296
- className: "flex items-center justify-between gap-3",
297
- children: [/* @__PURE__ */ Z(W, {
298
- className: "text-sm",
299
- children: /* @__PURE__ */ Z(t, { id: "Credits" })
300
- }), f && /* @__PURE__ */ Z(s, {
301
- size: "sm",
302
- disabled: L === void 0,
303
- onClick: () => w(!0),
304
- children: /* @__PURE__ */ Z(t, { id: "Grant credit" })
305
- })]
306
- }),
307
- /* @__PURE__ */ Q("form", {
308
- className: "flex max-w-sm items-end gap-2",
309
- onSubmit: (e) => {
310
- e.preventDefault();
311
- let t = y.trim();
312
- t && v(t.toUpperCase());
313
- },
314
- children: [/* @__PURE__ */ Q("div", {
315
- className: "grid gap-1",
316
- children: [/* @__PURE__ */ Z(H, {
317
- htmlFor: o("credit-currency"),
318
- children: /* @__PURE__ */ Z(t, { id: "Currency" })
319
- }), /* @__PURE__ */ Z(c, {
320
- id: o("credit-currency"),
321
- value: y,
322
- onChange: (e) => b(e.target.value),
323
- placeholder: u("USD")
324
- })]
325
- }), /* @__PURE__ */ Z(s, {
326
- type: "submit",
327
- variant: "outline",
328
- size: "sm",
329
- children: /* @__PURE__ */ Z(t, { id: "View" })
330
- })]
331
- }),
332
- L === void 0 && /* @__PURE__ */ Q("p", {
333
- className: "text-xs text-muted-foreground",
334
- children: [g, /* @__PURE__ */ Z(t, { id: " is not a supported currency." })]
335
- })
336
- ]
337
- }),
338
- /* @__PURE__ */ Q(G, {
339
- className: "grid gap-6",
340
- children: [/* @__PURE__ */ Q("section", {
341
- "aria-label": u("Credit grants"),
342
- children: [
343
- /* @__PURE__ */ Q("h3", {
344
- className: "mb-2 text-sm font-medium",
345
- children: [/* @__PURE__ */ Z(t, { id: "Grants · " }), g]
346
- }),
347
- F.isPending ? /* @__PURE__ */ Z("p", {
348
- className: "text-sm text-muted-foreground",
349
- children: /* @__PURE__ */ Z(t, { id: "Loading grants…" })
350
- }) : F.error ? /* @__PURE__ */ Z("p", {
351
- role: "alert",
352
- className: "text-sm text-destructive",
353
- children: $(F.error)
354
- }) : F.data?.data.length ? /* @__PURE__ */ Z("div", {
355
- className: "overflow-x-auto",
356
- children: /* @__PURE__ */ Q(M, { children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Q(j, { children: [
357
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Grant" }) }),
358
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Original" }) }),
359
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Remaining" }) }),
360
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Spent" }) }),
361
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Expired" }) }),
362
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Revoked" }) }),
363
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "State" }) }),
364
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Expires" }) }),
365
- /* @__PURE__ */ Z(D, {})
366
- ] }) }), /* @__PURE__ */ Z(O, { children: F.data.data.map((e) => /* @__PURE__ */ Q(j, { children: [
367
- /* @__PURE__ */ Q(A, { children: [
368
- /* @__PURE__ */ Z("span", {
369
- title: e.id,
370
- children: _(e.id)
371
- }),
372
- /* @__PURE__ */ Z("div", {
373
- className: "text-xs text-muted-foreground",
374
- children: m(e.created_at)
375
- }),
376
- /* @__PURE__ */ Z("div", {
377
- className: "text-xs text-muted-foreground",
378
- children: e.description ?? e.source_type
379
- })
380
- ] }),
381
- [
382
- e.amount,
383
- e.remaining_amount,
384
- e.spent_amount,
385
- e.expired_amount,
386
- e.revoked_amount
387
- ].map((t, n) => /* @__PURE__ */ Z(A, {
388
- className: "tabular-nums",
389
- children: h(t, e.currency)
390
- }, n)),
391
- /* @__PURE__ */ Z(A, { children: e.state }),
392
- /* @__PURE__ */ Z(A, { children: e.expires_at ? m(e.expires_at) : "No expiry" }),
393
- /* @__PURE__ */ Z(A, { children: f && /* @__PURE__ */ Z(s, {
394
- size: "sm",
395
- variant: "outline",
396
- disabled: !ge(e),
397
- onClick: () => P(e),
398
- children: /* @__PURE__ */ Z(t, { id: "Revoke" })
399
- }) })
400
- ] }, e.id)) })] })
401
- }) : /* @__PURE__ */ Z("p", {
402
- className: "text-sm text-muted-foreground",
403
- children: /* @__PURE__ */ Z(t, { id: "No credit grants in this currency." })
404
- }),
405
- /* @__PURE__ */ Z(E, {
406
- pages: x,
407
- rows: F.data?.data?.length ?? 0,
408
- nextCursor: F.data?.next_cursor,
409
- busy: F.isFetching
410
- })
411
- ]
412
- }), /* @__PURE__ */ Q("section", {
413
- "aria-label": u("Credit transaction ledger"),
414
- children: [
415
- /* @__PURE__ */ Q("h3", {
416
- className: "mb-2 text-sm font-medium",
417
- children: [/* @__PURE__ */ Z(t, { id: "Transaction ledger · " }), g]
418
- }),
419
- I.isPending ? /* @__PURE__ */ Z("p", {
420
- className: "text-sm text-muted-foreground",
421
- children: /* @__PURE__ */ Z(t, { id: "Loading transactions…" })
422
- }) : I.error ? /* @__PURE__ */ Z("p", {
423
- role: "alert",
424
- className: "text-sm text-destructive",
425
- children: $(I.error)
426
- }) : I.data?.data.length ? /* @__PURE__ */ Q(M, { children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Q(j, { children: [
427
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Date" }) }),
428
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Type" }) }),
429
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Amount" }) }),
430
- /* @__PURE__ */ Z(D, { children: /* @__PURE__ */ Z(t, { id: "Source" }) })
431
- ] }) }), /* @__PURE__ */ Z(O, { children: I.data.data.map((e) => /* @__PURE__ */ Q(j, { children: [
432
- /* @__PURE__ */ Z(A, {
433
- title: e.id,
434
- children: m(e.created_at)
435
- }),
436
- /* @__PURE__ */ Z(A, { children: e.type.replaceAll("_", " ") }),
437
- /* @__PURE__ */ Z(A, {
438
- className: "tabular-nums",
439
- children: h(e.amount, e.currency)
440
- }),
441
- /* @__PURE__ */ Z(A, { children: e.source || "—" })
442
- ] }, e.id)) })] }) : /* @__PURE__ */ Z("p", {
443
- className: "text-sm text-muted-foreground",
444
- children: /* @__PURE__ */ Z(t, { id: "No transactions in this currency." })
445
- }),
446
- /* @__PURE__ */ Z(E, {
447
- pages: S,
448
- rows: I.data?.data?.length ?? 0,
449
- nextCursor: I.data?.next_cursor,
450
- busy: I.isFetching
451
- })
452
- ]
453
- })]
454
- }),
455
- C && L !== void 0 && /* @__PURE__ */ Z(be, {
456
- merchant: n,
457
- customer: r,
458
- currency: g,
459
- decimals: L,
460
- onClose: () => w(!1)
461
- }),
462
- N && /* @__PURE__ */ Z(xe, {
463
- merchant: n,
464
- customer: r,
465
- grant: N,
466
- onClose: () => P(null)
467
- })
468
- ] });
469
- }
470
- function be({ merchant: n, customer: r, currency: a, decimals: o, onClose: l }) {
471
- let { toast: u, creditMutations: d } = i(), { id: f } = e(), p = X(), m = J(d.grant(p, n, r)), [h, g] = q.useState(""), [_, v] = q.useState(""), [y, b] = q.useState(""), [x] = q.useState(() => crypto.randomUUID()), [S, C] = q.useState("");
472
- return /* @__PURE__ */ Z(V, {
473
- open: !0,
474
- onOpenChange: (e) => {
475
- !e && !m.isPending && l();
476
- },
477
- children: /* @__PURE__ */ Q(R, { children: [/* @__PURE__ */ Q(I, { children: [/* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Z(t, { id: "Grant credit" }) }), /* @__PURE__ */ Q(B, { children: [
478
- /* @__PURE__ */ Z(t, { id: "Add credit in " }),
479
- a,
480
- /* @__PURE__ */ Z(t, { id: " to this customer." })
481
- ] })] }), /* @__PURE__ */ Q("form", {
482
- className: "grid gap-4",
483
- onSubmit: async (e) => {
484
- e.preventDefault(), C("");
485
- try {
486
- let e = he({
487
- amount: h,
488
- currency: a,
489
- decimals: o,
490
- expires: _,
491
- description: y,
492
- sourceID: x
493
- });
494
- await m.mutateAsync(e), u.success("Credit granted"), l();
495
- } catch (e) {
496
- C($(e));
497
- }
498
- },
499
- children: [
500
- /* @__PURE__ */ Q("div", {
501
- className: "grid gap-1",
502
- children: [/* @__PURE__ */ Q(H, {
503
- htmlFor: f("grant-amount"),
504
- children: [
505
- /* @__PURE__ */ Z(t, { id: "Amount (" }),
506
- a,
507
- ")"
508
- ]
509
- }), /* @__PURE__ */ Z(c, {
510
- id: f("grant-amount"),
511
- inputMode: "decimal",
512
- value: h,
513
- onChange: (e) => g(e.target.value),
514
- autoFocus: !0
515
- })]
516
- }),
517
- /* @__PURE__ */ Q("div", {
518
- className: "grid gap-1",
519
- children: [/* @__PURE__ */ Z(H, {
520
- htmlFor: f("grant-expiry"),
521
- children: /* @__PURE__ */ Z(t, { id: "Expires (optional)" })
522
- }), /* @__PURE__ */ Z(c, {
523
- id: f("grant-expiry"),
524
- type: "datetime-local",
525
- value: _,
526
- onChange: (e) => v(e.target.value)
527
- })]
528
- }),
529
- /* @__PURE__ */ Q("div", {
530
- className: "grid gap-1",
531
- children: [/* @__PURE__ */ Z(H, {
532
- htmlFor: f("grant-description"),
533
- children: /* @__PURE__ */ Z(t, { id: "Description (optional)" })
534
- }), /* @__PURE__ */ Z(c, {
535
- id: f("grant-description"),
536
- value: y,
537
- onChange: (e) => b(e.target.value),
538
- maxLength: 500
539
- })]
540
- }),
541
- S && /* @__PURE__ */ Z("p", {
542
- role: "alert",
543
- className: "text-sm text-destructive",
544
- children: S
545
- }),
546
- /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(s, {
547
- type: "button",
548
- variant: "outline",
549
- disabled: m.isPending,
550
- onClick: l,
551
- children: /* @__PURE__ */ Z(t, { id: "Cancel" })
552
- }), /* @__PURE__ */ Z(s, {
553
- type: "submit",
554
- disabled: m.isPending,
555
- children: m.isPending ? "Granting…" : "Grant credit"
556
- })] })
557
- ]
558
- })] })
559
- });
560
- }
561
- function xe({ merchant: n, customer: r, grant: a, onClose: o }) {
562
- let { toast: l, creditMutations: u } = i(), { id: d } = e(), f = X(), p = J(u.revoke(f, n, r)), [m, g] = q.useState(""), [_, v] = q.useState("");
563
- return /* @__PURE__ */ Z(V, {
564
- open: !0,
565
- onOpenChange: (e) => {
566
- !e && !p.isPending && o();
567
- },
568
- children: /* @__PURE__ */ Q(R, { children: [/* @__PURE__ */ Q(I, { children: [/* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Z(t, { id: "Revoke remaining credit" }) }), /* @__PURE__ */ Q(B, { children: [
569
- /* @__PURE__ */ Z(t, { id: "Revoke the unspent remainder of" }),
570
- " ",
571
- h(a.remaining_amount, a.currency),
572
- /* @__PURE__ */ Z(t, { id: ". Active holds may prevent revocation. Payment refunds are managed separately." })
573
- ] })] }), /* @__PURE__ */ Q("form", {
574
- className: "grid gap-4",
575
- onSubmit: async (e) => {
576
- e.preventDefault(), v("");
577
- try {
578
- let e = await p.mutateAsync(_e(a, m));
579
- l.success(e.replayed ? "Credit was already revoked" : `${h(e.revoked_amount, e.currency)} revoked`), o();
580
- } catch (e) {
581
- v($(e));
582
- }
583
- },
584
- children: [
585
- /* @__PURE__ */ Q("div", {
586
- className: "grid gap-1",
587
- children: [/* @__PURE__ */ Z(H, {
588
- htmlFor: d("revoke-reason"),
589
- children: /* @__PURE__ */ Z(t, { id: "Reason" })
590
- }), /* @__PURE__ */ Z(c, {
591
- id: d("revoke-reason"),
592
- value: m,
593
- onChange: (e) => g(e.target.value),
594
- maxLength: 500,
595
- autoFocus: !0
596
- })]
597
- }),
598
- _ && /* @__PURE__ */ Z("p", {
599
- role: "alert",
600
- className: "text-sm text-destructive",
601
- children: _
602
- }),
603
- /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(s, {
604
- type: "button",
605
- variant: "outline",
606
- disabled: p.isPending,
607
- onClick: o,
608
- children: /* @__PURE__ */ Z(t, { id: "Cancel" })
609
- }), /* @__PURE__ */ Z(s, {
610
- type: "submit",
611
- variant: "destructive",
612
- disabled: !ge(a) || p.isPending,
613
- children: p.isPending ? "Revoking…" : "Revoke credit"
614
- })] })
615
- ]
616
- })] })
617
- });
618
- }
619
- //#endregion
620
- //#region src/admin/pages/customers/grant-duration.ts
621
- var Se = [
622
- {
623
- value: "1",
624
- label: "1 day",
625
- days: 1
626
- },
627
- {
628
- value: "7",
629
- label: "7 days",
630
- days: 7
631
- },
632
- {
633
- value: "30",
634
- label: "30 days",
635
- days: 30
636
- },
637
- {
638
- value: "365",
639
- label: "365 days",
640
- days: 365
641
- },
642
- {
643
- value: "until",
644
- label: "Until a date"
645
- },
646
- {
647
- value: "never",
648
- label: "Never expires"
649
- }
650
- ], Ce = (e) => e.toISOString().slice(0, 10);
651
- function we(e, t, n = /* @__PURE__ */ new Date()) {
652
- if (e === "never") return {};
653
- if (e === "until") {
654
- if (!/^\d{4}-\d{2}-\d{2}$/.test(t) || t < Ce(n)) return null;
655
- let e = /* @__PURE__ */ new Date(`${t}T00:00:00Z`);
656
- return e.setUTCDate(e.getUTCDate() + 1), { endsAt: e.toISOString() };
657
- }
658
- let r = Se.find((t) => t.value === e);
659
- return r && "days" in r ? { hours: r.days * 24 } : null;
660
- }
661
- //#endregion
662
- //#region src/admin/pages/customers/detail.tsx
663
- function Te() {
664
- let { text: c } = e(), { props: u } = r(), { adminQueries: d } = i(), f = l(), { customerId: p = "" } = n(), g = o(), { data: _, isPending: v } = Y(d.customer(p));
665
- return v ? /* @__PURE__ */ Z("p", {
666
- className: "text-sm text-muted-foreground",
667
- children: /* @__PURE__ */ Z(t, { id: "Loading…" })
668
- }) : _ ? /* @__PURE__ */ Q("div", {
669
- className: "flex min-w-0 flex-col gap-4",
670
- children: [
671
- /* @__PURE__ */ Q("div", {
672
- className: "flex items-center gap-3",
673
- children: [
674
- /* @__PURE__ */ Z(s, {
675
- variant: "ghost",
676
- size: "icon",
677
- onClick: () => g(-1),
678
- "aria-label": c("Back"),
679
- children: /* @__PURE__ */ Z(se, {
680
- icon: le,
681
- className: "size-4"
682
- })
683
- }),
684
- /* @__PURE__ */ Q("div", {
685
- className: "min-w-0",
686
- children: [/* @__PURE__ */ Z("h2", {
687
- className: "truncate text-base font-semibold",
688
- children: _.contact?.name || _.contact?.email || "Customer"
689
- }), /* @__PURE__ */ Q("p", {
690
- className: "truncate text-xs text-muted-foreground",
691
- children: [
692
- _.id,
693
- /* @__PURE__ */ Z(t, { id: " · since " }),
694
- m(_.created_at),
695
- /* @__PURE__ */ Z(t, { id: " · last seen" }),
696
- " ",
697
- m(_.last_seen_at)
698
- ]
699
- })]
700
- }),
701
- f && /* @__PURE__ */ Z("div", {
702
- className: "ml-auto flex gap-2",
703
- children: /* @__PURE__ */ Z(Me, { customerId: p })
704
- })
705
- ]
706
- }),
707
- /* @__PURE__ */ Z(Ne, { contact: _.contact }),
708
- u.userHref && /* @__PURE__ */ Z("a", {
709
- className: "underline",
710
- href: u.userHref(_.id),
711
- children: /* @__PURE__ */ Z(t, { id: "View user account" })
712
- }),
713
- u.customerPanels?.(_),
714
- _.balances.length > 0 && /* @__PURE__ */ Z("div", {
715
- className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-4",
716
- children: _.balances.map((e) => /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, {
717
- className: "pb-1",
718
- children: /* @__PURE__ */ Q(W, {
719
- className: "text-xs font-normal text-muted-foreground uppercase",
720
- children: [e.currency, /* @__PURE__ */ Z(t, { id: " balance" })]
721
- })
722
- }), /* @__PURE__ */ Q(G, { children: [/* @__PURE__ */ Z("p", {
723
- className: "text-lg font-semibold",
724
- children: h(e.balance_amount, e.currency)
725
- }), /* @__PURE__ */ Q("p", {
726
- className: "text-xs text-muted-foreground",
727
- children: [
728
- /* @__PURE__ */ Z(t, { id: "held " }),
729
- h(e.held_amount, e.currency),
730
- /* @__PURE__ */ Z(t, { id: " · owed" }),
731
- " ",
732
- h(e.owed_amount, e.currency)
733
- ]
734
- })] })] }, e.currency))
735
- }),
736
- _.balances.some((e) => BigInt(e.owed_amount) > 0n) && /* @__PURE__ */ Z("p", {
737
- className: "text-sm",
738
- children: /* @__PURE__ */ Z(a, {
739
- className: "underline-offset-2 hover:underline",
740
- to: `/orders?customer_id=${_.id}&origin=usage&overdue=true`,
741
- children: /* @__PURE__ */ Z(t, { id: "Overdue usage orders" })
742
- })
743
- }),
744
- /* @__PURE__ */ Z(ve, {
745
- customerId: p,
746
- currencies: _.balances.map((e) => e.currency)
747
- }),
748
- /* @__PURE__ */ Z(fe, { customerId: p }),
749
- /* @__PURE__ */ Q("div", {
750
- className: "grid gap-4 lg:grid-cols-3 lg:items-start",
751
- children: [/* @__PURE__ */ Q("div", {
752
- className: "grid gap-4 lg:col-span-2",
753
- children: [
754
- /* @__PURE__ */ Z(Ee, { customerId: p }),
755
- /* @__PURE__ */ Z(De, { customerId: p }),
756
- /* @__PURE__ */ Z(Oe, { customerId: p })
757
- ]
758
- }), /* @__PURE__ */ Q("div", {
759
- className: "grid gap-4",
760
- children: [/* @__PURE__ */ Z(ke, { customerId: p }), /* @__PURE__ */ Z(Ae, { customerId: p })]
761
- })]
762
- })
763
- ]
764
- }) : /* @__PURE__ */ Z("p", {
765
- className: "text-sm text-muted-foreground",
766
- children: /* @__PURE__ */ Z(t, { id: "Customer not found." })
767
- });
768
- }
769
- function Ee({ customerId: e }) {
770
- let { adminQueries: n } = i(), r = T(e, 25), { data: o, isFetching: s } = Y(n.customerSubscriptions(e, r.size, r.cursor)), c = o?.data ?? [];
771
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(W, {
772
- className: "text-sm",
773
- children: /* @__PURE__ */ Z(t, { id: "Subscriptions" })
774
- }) }), /* @__PURE__ */ Q(G, {
775
- className: "grid gap-3",
776
- children: [c.length === 0 ? /* @__PURE__ */ Z("p", {
777
- className: "text-sm text-muted-foreground",
778
- children: /* @__PURE__ */ Z(t, { id: "No subscriptions." })
779
- }) : /* @__PURE__ */ Q(M, { children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Q(j, {
780
- className: "hover:bg-transparent",
781
- children: [
782
- /* @__PURE__ */ Z(D, {
783
- className: "text-muted-foreground",
784
- children: /* @__PURE__ */ Z(t, { id: "Subscription" })
785
- }),
786
- /* @__PURE__ */ Z(D, {
787
- className: "text-muted-foreground",
788
- children: /* @__PURE__ */ Z(t, { id: "Status" })
789
- }),
790
- /* @__PURE__ */ Z(D, {
791
- className: "text-muted-foreground",
792
- children: /* @__PURE__ */ Z(t, { id: "Rail" })
793
- }),
794
- /* @__PURE__ */ Z(D, {
795
- className: "text-muted-foreground",
796
- children: /* @__PURE__ */ Z(t, { id: "Period ends" })
797
- }),
798
- /* @__PURE__ */ Z(D, {
799
- className: "text-muted-foreground",
800
- children: /* @__PURE__ */ Z(t, { id: "Dunning" })
801
- })
802
- ]
803
- }) }), /* @__PURE__ */ Z(O, { children: c.map((e) => /* @__PURE__ */ Q(N, {
804
- to: `/subscriptions/${e.id}`,
805
- children: [
806
- /* @__PURE__ */ Z(A, { children: /* @__PURE__ */ Z(a, {
807
- className: "text-xs underline-offset-2 hover:underline",
808
- to: `/subscriptions/${e.id}`,
809
- children: _(e.id, 13)
810
- }) }),
811
- /* @__PURE__ */ Z(A, { children: /* @__PURE__ */ Z(F, { status: e.status }) }),
812
- /* @__PURE__ */ Z(A, { children: e.rail }),
813
- /* @__PURE__ */ Z(A, {
814
- className: "tabular-nums",
815
- children: m(e.current_period_ends_at)
816
- }),
817
- /* @__PURE__ */ Z(A, {
818
- className: "text-xs",
819
- children: e.dunning ? ie(e.dunning) : "—"
820
- })
821
- ]
822
- }, e.id)) })] }), /* @__PURE__ */ Z(E, {
823
- pages: r,
824
- rows: o?.data?.length ?? 0,
825
- nextCursor: o?.next_cursor,
826
- busy: s
827
- })]
828
- })] });
829
- }
830
- function De({ customerId: e }) {
831
- let { adminQueries: n } = i(), r = T(e, 25), { data: o, isFetching: s } = Y(n.customerPayments(e, r.size, r.cursor)), c = o?.data ?? [];
832
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(W, {
833
- className: "text-sm",
834
- children: /* @__PURE__ */ Z(t, { id: "Payments" })
835
- }) }), /* @__PURE__ */ Q(G, {
836
- className: "grid gap-3",
837
- children: [c.length === 0 ? /* @__PURE__ */ Z("p", {
838
- className: "text-sm text-muted-foreground",
839
- children: /* @__PURE__ */ Z(t, { id: "No payments." })
840
- }) : /* @__PURE__ */ Q(M, { children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Q(j, {
841
- className: "hover:bg-transparent",
842
- children: [
843
- /* @__PURE__ */ Z(D, {
844
- className: "text-muted-foreground",
845
- children: /* @__PURE__ */ Z(t, { id: "Payment" })
846
- }),
847
- /* @__PURE__ */ Z(D, {
848
- className: "text-muted-foreground",
849
- children: /* @__PURE__ */ Z(t, { id: "Status" })
850
- }),
851
- /* @__PURE__ */ Z(D, {
852
- className: "text-muted-foreground",
853
- children: /* @__PURE__ */ Z(t, { id: "Amount" })
854
- }),
855
- /* @__PURE__ */ Z(D, {
856
- className: "text-muted-foreground",
857
- children: /* @__PURE__ */ Z(t, { id: "Kind" })
858
- }),
859
- /* @__PURE__ */ Z(D, {
860
- className: "text-muted-foreground",
861
- children: /* @__PURE__ */ Z(t, { id: "Rail" })
862
- }),
863
- /* @__PURE__ */ Z(D, {
864
- className: "text-muted-foreground",
865
- children: /* @__PURE__ */ Z(t, { id: "Purchased" })
866
- })
867
- ]
868
- }) }), /* @__PURE__ */ Z(O, { children: c.map((e) => /* @__PURE__ */ Q(N, {
869
- to: `/payments/${e.id}`,
870
- children: [
871
- /* @__PURE__ */ Z(A, { children: /* @__PURE__ */ Z(a, {
872
- className: "text-xs underline-offset-2 hover:underline",
873
- to: `/payments/${e.id}`,
874
- children: _(e.id, 13)
875
- }) }),
876
- /* @__PURE__ */ Z(A, { children: /* @__PURE__ */ Z(F, { status: e.status }) }),
877
- /* @__PURE__ */ Z(A, {
878
- className: "tabular-nums",
879
- children: h(e.amount, e.currency)
880
- }),
881
- /* @__PURE__ */ Z(A, { children: e.kind }),
882
- /* @__PURE__ */ Z(A, { children: e.rail ?? e.channel }),
883
- /* @__PURE__ */ Z(A, {
884
- className: "tabular-nums",
885
- children: m(e.created_at)
886
- })
887
- ]
888
- }, e.id)) })] }), /* @__PURE__ */ Z(E, {
889
- pages: r,
890
- rows: o?.data?.length ?? 0,
891
- nextCursor: o?.next_cursor,
892
- busy: s
893
- })]
894
- })] });
895
- }
896
- function Oe({ customerId: e }) {
897
- let { adminQueries: n, queryKeys: r, deleteCustomerPaymentMethod: a, toastApiError: o } = i(), c = l(), u = v(), p = X(), m = J({
898
- mutationFn: (t) => a(e, t),
899
- onSuccess: () => p.invalidateQueries({ queryKey: [...r.customer(e), "payment-methods"] }),
900
- onError: (e) => o(e, "Remove payment method")
901
- }), h = T(e, 25), { data: g, isFetching: _ } = Y(n.customerPaymentMethodsPage(e, h.size, h.cursor)), y = g?.data ?? [];
902
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Q(U, { children: [/* @__PURE__ */ Z(W, {
903
- className: "text-sm",
904
- children: /* @__PURE__ */ Z(t, { id: "Payment methods" })
905
- }), /* @__PURE__ */ Z(s, {
906
- variant: "ghost",
907
- size: "sm",
908
- onClick: () => void p.invalidateQueries({ queryKey: [...r.customer(e), "payment-methods"] }),
909
- children: /* @__PURE__ */ Z(t, { id: "Refresh payment methods" })
910
- })] }), /* @__PURE__ */ Q(G, {
911
- className: "grid gap-3",
912
- children: [y.length === 0 ? /* @__PURE__ */ Z("p", {
913
- className: "text-sm text-muted-foreground",
914
- children: /* @__PURE__ */ Z(t, { id: "No payment methods on file." })
915
- }) : /* @__PURE__ */ Z("div", {
916
- className: "flex flex-wrap gap-3",
917
- children: y.map((e) => /* @__PURE__ */ Q("div", {
918
- className: "rounded-md border p-3 text-sm",
919
- children: [
920
- /* @__PURE__ */ Z("p", {
921
- className: "font-medium",
922
- children: f(e.card)
923
- }),
924
- /* @__PURE__ */ Q("p", {
925
- className: "text-xs text-muted-foreground",
926
- children: [
927
- e.rail,
928
- /* @__PURE__ */ Z(t, { id: " · exp " }),
929
- d(e.card)
930
- ]
931
- }),
932
- /* @__PURE__ */ Z(me, { currencies: e.default_currencies ?? [] }),
933
- c && e.rail === "nmi" && e.status !== "removed" && /* @__PURE__ */ Z(s, {
934
- size: "sm",
935
- variant: "outline",
936
- className: "mt-2",
937
- disabled: m.isPending,
938
- onClick: async () => {
939
- await u({
940
- title: "Remove this saved card?",
941
- description: "The vault will remove the card once no active subscription or payment uses it. Transaction history remains.",
942
- confirmLabel: "Remove saved card"
943
- }) && m.mutate(e.id);
944
- },
945
- children: "Remove saved card"
946
- }),
947
- e.health.expiry_status && e.health.expiry_status !== "valid" && /* @__PURE__ */ Z(P, {
948
- variant: "secondary",
949
- className: "bg-held-surface text-held mt-1",
950
- children: e.health.expiry_status
951
- })
952
- ]
953
- }, e.id))
954
- }), /* @__PURE__ */ Z(E, {
955
- pages: h,
956
- rows: g?.data?.length ?? 0,
957
- nextCursor: g?.next_cursor,
958
- busy: _
959
- })]
960
- })] });
961
- }
962
- function ke({ customerId: e }) {
963
- let { adminQueries: n } = i(), r = T(e, 25), { data: a, isFetching: o } = Y(n.customerEntitlements(e, r.size, r.cursor)), s = a?.data ?? [];
964
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(W, {
965
- className: "text-sm",
966
- children: /* @__PURE__ */ Z(t, { id: "Entitlements" })
967
- }) }), /* @__PURE__ */ Q(G, {
968
- className: "grid gap-3",
969
- children: [
970
- /* @__PURE__ */ Z("p", {
971
- className: "text-xs text-muted-foreground",
972
- children: /* @__PURE__ */ Z(t, { id: "The keys of the products this customer holds now." })
973
- }),
974
- s.length === 0 ? /* @__PURE__ */ Z("p", {
975
- className: "text-sm text-muted-foreground",
976
- children: /* @__PURE__ */ Z(t, { id: "No entitlements." })
977
- }) : /* @__PURE__ */ Z("div", {
978
- className: "flex flex-wrap gap-2",
979
- children: s.map((e) => /* @__PURE__ */ Z(P, {
980
- variant: "secondary",
981
- children: e.entitlement
982
- }, e.entitlement))
983
- }),
984
- /* @__PURE__ */ Z(E, {
985
- pages: r,
986
- rows: a?.data?.length ?? 0,
987
- nextCursor: a?.next_cursor,
988
- busy: o
989
- })
990
- ]
991
- })] });
992
- }
993
- function Ae({ customerId: n }) {
994
- let { text: r } = e(), { adminQueries: a } = i(), o = l(), s = T(n, 25), { data: c, isFetching: u } = Y(a.customerProductAccess(n, s.size, s.cursor)), d = c?.data ?? [];
995
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(W, {
996
- className: "text-sm",
997
- children: /* @__PURE__ */ Z(t, { id: "Product access" })
998
- }) }), /* @__PURE__ */ Q(G, {
999
- className: "grid gap-3",
1000
- children: [d.length === 0 ? /* @__PURE__ */ Z("p", {
1001
- className: "text-sm text-muted-foreground",
1002
- children: /* @__PURE__ */ Z(t, { id: "No product access." })
1003
- }) : /* @__PURE__ */ Z("div", {
1004
- className: "grid gap-4",
1005
- children: d.map((e) => /* @__PURE__ */ Q("div", {
1006
- className: "flex min-w-0 items-start gap-3",
1007
- children: [/* @__PURE__ */ Q("div", {
1008
- className: "min-w-0 flex-1",
1009
- children: [
1010
- /* @__PURE__ */ Q("div", {
1011
- className: "flex min-w-0 items-center gap-2",
1012
- children: [/* @__PURE__ */ Z("p", {
1013
- className: "truncate text-sm font-medium",
1014
- children: e.product_name || _(e.product_id, 13)
1015
- }), /* @__PURE__ */ Z(F, { status: e.status })]
1016
- }),
1017
- /* @__PURE__ */ Z("p", {
1018
- className: "mt-1 text-xs text-muted-foreground",
1019
- children: e.source_type === "grant" ? `Granted (${e.grant_reason ?? "staff"})${e.note ? `: ${e.note}` : ""}` : e.source_type
1020
- }),
1021
- /* @__PURE__ */ Z("p", {
1022
- className: "text-xs text-muted-foreground tabular-nums",
1023
- children: e.ends_at ? `Ends ${m(e.ends_at)}` : "No end date"
1024
- })
1025
- ]
1026
- }), o && /* @__PURE__ */ Z(je, {
1027
- customerId: n,
1028
- grantId: e.id,
1029
- label: r("Revoke product access")
1030
- })]
1031
- }, e.id))
1032
- }), /* @__PURE__ */ Z(E, {
1033
- pages: s,
1034
- rows: c?.data?.length ?? 0,
1035
- nextCursor: c?.next_cursor,
1036
- busy: u
1037
- })]
1038
- })] });
1039
- }
1040
- function je({ customerId: n, grantId: r, label: a }) {
1041
- let { toast: o, toastApiError: l, adminMutations: u } = i(), { id: d } = e(), f = X(), p = J(u.revokeCustomerProductAccess(f, n)), [m, h] = q.useState(!1), [g, _] = q.useState("");
1042
- return /* @__PURE__ */ Q(V, {
1043
- open: m,
1044
- onOpenChange: h,
1045
- children: [/* @__PURE__ */ Z(ee, { render: /* @__PURE__ */ Z(s, {
1046
- variant: "ghost",
1047
- size: "icon",
1048
- "aria-label": a,
1049
- children: /* @__PURE__ */ Z(se, {
1050
- icon: ue,
1051
- className: "size-4 text-destructive"
1052
- })
1053
- }) }), /* @__PURE__ */ Q(R, {
1054
- className: te,
1055
- children: [
1056
- /* @__PURE__ */ Q(I, { children: [/* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Z(t, { id: "Take the product back" }) }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z(t, { id: "The customer loses its entitlements now. The grant stays on record with your reason." }) })] }),
1057
- /* @__PURE__ */ Q("div", {
1058
- className: "flex flex-col gap-1.5",
1059
- children: [/* @__PURE__ */ Z(H, {
1060
- htmlFor: d("revoke-access-reason"),
1061
- children: /* @__PURE__ */ Z(t, { id: "Reason" })
1062
- }), /* @__PURE__ */ Z(c, {
1063
- id: d("revoke-access-reason"),
1064
- value: g,
1065
- onChange: (e) => _(e.target.value),
1066
- maxLength: 500
1067
- })]
1068
- }),
1069
- /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(s, {
1070
- variant: "outline",
1071
- onClick: () => h(!1),
1072
- children: /* @__PURE__ */ Z(t, { id: "Cancel" })
1073
- }), /* @__PURE__ */ Z(s, {
1074
- variant: "destructive",
1075
- disabled: !g.trim() || p.isPending,
1076
- onClick: async () => {
1077
- try {
1078
- await p.mutateAsync({
1079
- grantId: r,
1080
- reason: g.trim()
1081
- }), o.success("Product access revoked"), h(!1);
1082
- } catch (e) {
1083
- l(e, a);
1084
- }
1085
- },
1086
- children: p.isPending ? "Revoking…" : "Revoke"
1087
- })] })
1088
- ]
1089
- })]
1090
- });
1091
- }
1092
- function Me({ customerId: n }) {
1093
- let { toast: r, toastApiError: a, adminMutations: o, adminQueries: l } = i(), { id: u, text: d } = e(), [f, p] = q.useState(!1), m = X(), h = J(o.grantCustomerProductAccess(m, n)), { data: g } = Y({
1094
- ...l.allProducts(),
1095
- enabled: f
1096
- }), _ = de({
1097
- defaultValues: {
1098
- productId: "",
1099
- duration: "30",
1100
- until: "",
1101
- note: ""
1102
- },
1103
- onSubmit: async ({ value: e }) => {
1104
- let t = we(e.duration, e.until);
1105
- if (t) try {
1106
- await h.mutateAsync({
1107
- productId: e.productId,
1108
- ...t,
1109
- note: e.note.trim() || void 0
1110
- }), r.success("Product access granted"), v(!1);
1111
- } catch (e) {
1112
- a(e, "Grant product access");
1113
- }
1114
- }
1115
- }), v = (e) => {
1116
- p(e), e || (_.reset(), h.reset());
1117
- };
1118
- return /* @__PURE__ */ Q(V, {
1119
- open: f,
1120
- onOpenChange: v,
1121
- children: [/* @__PURE__ */ Z(ee, { render: /* @__PURE__ */ Q(s, {
1122
- variant: "outline",
1123
- size: "sm",
1124
- children: [/* @__PURE__ */ Z(se, {
1125
- icon: ce,
1126
- className: "size-4"
1127
- }), /* @__PURE__ */ Z(t, { id: " Product access" })]
1128
- }) }), /* @__PURE__ */ Q(R, {
1129
- className: te,
1130
- children: [/* @__PURE__ */ Q(I, { children: [/* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Z(t, { id: "Grant product access" }) }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z(t, { id: "Give this customer one of your products without a payment. They hold its keys while the grant lasts, including keys you add to the product later." }) })] }), /* @__PURE__ */ Q("form", {
1131
- onSubmit: (e) => {
1132
- e.preventDefault(), e.stopPropagation(), _.handleSubmit();
1133
- },
1134
- className: "grid gap-4",
1135
- children: [/* @__PURE__ */ Q("div", {
1136
- className: "grid gap-3",
1137
- children: [
1138
- /* @__PURE__ */ Z(_.Field, {
1139
- name: "productId",
1140
- validators: { onChange: ({ value: e }) => e ? void 0 : "Pick a product" },
1141
- children: (e) => /* @__PURE__ */ Q("div", {
1142
- className: "grid gap-1.5",
1143
- children: [
1144
- /* @__PURE__ */ Z(H, {
1145
- htmlFor: u("pa-product"),
1146
- children: /* @__PURE__ */ Z(t, { id: "Product" })
1147
- }),
1148
- /* @__PURE__ */ Q(w, {
1149
- value: e.state.value,
1150
- onValueChange: (t) => e.handleChange(t ?? ""),
1151
- children: [/* @__PURE__ */ Z(x, {
1152
- className: "w-full",
1153
- id: u("pa-product"),
1154
- "aria-invalid": e.state.meta.errors.length > 0,
1155
- children: /* @__PURE__ */ Z(b, { placeholder: d("Pick a product") })
1156
- }), /* @__PURE__ */ Z(S, { children: (g?.data ?? []).map((e) => /* @__PURE__ */ Q(C, {
1157
- value: e.id,
1158
- children: [
1159
- e.display_name,
1160
- " (",
1161
- e.key,
1162
- ")"
1163
- ]
1164
- }, e.id)) })]
1165
- }),
1166
- /* @__PURE__ */ Z(y, { errors: e.state.meta.errors })
1167
- ]
1168
- })
1169
- }),
1170
- /* @__PURE__ */ Z(_.Field, {
1171
- name: "duration",
1172
- children: (e) => /* @__PURE__ */ Q("div", {
1173
- className: "grid gap-1.5",
1174
- children: [
1175
- /* @__PURE__ */ Z(H, {
1176
- htmlFor: u("pa-duration"),
1177
- children: /* @__PURE__ */ Z(t, { id: "How long it lasts" })
1178
- }),
1179
- /* @__PURE__ */ Z("p", {
1180
- className: "text-[13px] text-muted-foreground",
1181
- children: /* @__PURE__ */ Z(t, { id: "Days are added after any access they already have." })
1182
- }),
1183
- /* @__PURE__ */ Q(w, {
1184
- items: Se.map((e) => ({
1185
- value: e.value,
1186
- label: e.label
1187
- })),
1188
- value: e.state.value,
1189
- onValueChange: (t) => {
1190
- t && e.handleChange(t);
1191
- },
1192
- children: [/* @__PURE__ */ Z(x, {
1193
- className: "w-full",
1194
- id: u("pa-duration"),
1195
- children: /* @__PURE__ */ Z(b, {})
1196
- }), /* @__PURE__ */ Z(S, { children: Se.map((e) => /* @__PURE__ */ Z(C, {
1197
- value: e.value,
1198
- children: e.label
1199
- }, e.value)) })]
1200
- })
1201
- ]
1202
- })
1203
- }),
1204
- /* @__PURE__ */ Z(_.Subscribe, {
1205
- selector: (e) => e.values.duration,
1206
- children: (e) => e === "until" ? /* @__PURE__ */ Z(_.Field, {
1207
- name: "until",
1208
- validators: { onChange: ({ value: e }) => we("until", e) ? void 0 : "Pick today or a later date" },
1209
- children: (e) => /* @__PURE__ */ Q("div", {
1210
- className: "grid gap-1.5",
1211
- children: [
1212
- /* @__PURE__ */ Z(H, {
1213
- htmlFor: u("pa-until"),
1214
- children: /* @__PURE__ */ Z(t, { id: "Last day (UTC)" })
1215
- }),
1216
- /* @__PURE__ */ Z(c, {
1217
- id: u("pa-until"),
1218
- type: "date",
1219
- min: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
1220
- value: e.state.value,
1221
- onBlur: e.handleBlur,
1222
- onChange: (t) => e.handleChange(t.target.value),
1223
- "aria-invalid": e.state.meta.errors.length > 0
1224
- }),
1225
- /* @__PURE__ */ Z(y, { errors: e.state.meta.errors })
1226
- ]
1227
- })
1228
- }) : null
1229
- }),
1230
- /* @__PURE__ */ Z(_.Field, {
1231
- name: "note",
1232
- children: (e) => /* @__PURE__ */ Q("div", {
1233
- className: "grid gap-1.5",
1234
- children: [/* @__PURE__ */ Z(H, {
1235
- htmlFor: u("pa-note"),
1236
- children: /* @__PURE__ */ Z(t, { id: "Note" })
1237
- }), /* @__PURE__ */ Z(c, {
1238
- id: u("pa-note"),
1239
- value: e.state.value,
1240
- onBlur: e.handleBlur,
1241
- onChange: (t) => e.handleChange(t.target.value),
1242
- placeholder: d("Why it was granted")
1243
- })]
1244
- })
1245
- })
1246
- ]
1247
- }), /* @__PURE__ */ Z(L, { children: /* @__PURE__ */ Z(_.Subscribe, {
1248
- selector: (e) => [
1249
- e.values.productId,
1250
- e.canSubmit,
1251
- e.isSubmitting,
1252
- we(e.values.duration, e.values.until) !== null
1253
- ],
1254
- children: ([e, n, r, i]) => /* @__PURE__ */ Q(oe, { children: [/* @__PURE__ */ Z(s, {
1255
- type: "button",
1256
- variant: "outline",
1257
- disabled: r,
1258
- onClick: () => v(!1),
1259
- children: /* @__PURE__ */ Z(t, { id: "Cancel" })
1260
- }), /* @__PURE__ */ Z(s, {
1261
- type: "submit",
1262
- disabled: !e || !n || r || !i,
1263
- children: r ? "Granting…" : "Grant access"
1264
- })] })
1265
- }) })]
1266
- })]
1267
- })]
1268
- });
1269
- }
1270
- function Ne({ contact: e }) {
1271
- return /* @__PURE__ */ Q(K, { children: [/* @__PURE__ */ Z(U, {
1272
- className: "pb-1",
1273
- children: /* @__PURE__ */ Z(W, {
1274
- className: "text-sm",
1275
- children: /* @__PURE__ */ Z(t, { id: "Contact" })
1276
- })
1277
- }), /* @__PURE__ */ Z(G, {
1278
- className: "text-sm",
1279
- children: e ? /* @__PURE__ */ Q("dl", {
1280
- className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1",
1281
- children: [
1282
- /* @__PURE__ */ Z("dt", {
1283
- className: "text-muted-foreground",
1284
- children: /* @__PURE__ */ Z(t, { id: "Email" })
1285
- }),
1286
- /* @__PURE__ */ Z("dd", {
1287
- className: "truncate",
1288
- children: e.email ?? "—"
1289
- }),
1290
- /* @__PURE__ */ Z("dt", {
1291
- className: "text-muted-foreground",
1292
- children: /* @__PURE__ */ Z(t, { id: "Name" })
1293
- }),
1294
- /* @__PURE__ */ Z("dd", {
1295
- className: "truncate",
1296
- children: e.name ?? "—"
1297
- }),
1298
- /* @__PURE__ */ Z("dt", {
1299
- className: "text-muted-foreground",
1300
- children: /* @__PURE__ */ Z(t, { id: "Username" })
1301
- }),
1302
- /* @__PURE__ */ Z("dd", {
1303
- className: "truncate",
1304
- children: e.username ?? "—"
1305
- }),
1306
- e.active !== null && /* @__PURE__ */ Q(oe, { children: [/* @__PURE__ */ Z("dt", {
1307
- className: "text-muted-foreground",
1308
- children: /* @__PURE__ */ Z(t, { id: "Directory" })
1309
- }), /* @__PURE__ */ Z("dd", { children: /* @__PURE__ */ Z(P, {
1310
- variant: e.active ? "secondary" : "outline",
1311
- children: e.active ? "Active" : "Deactivated"
1312
- }) })] }),
1313
- /* @__PURE__ */ Z("dt", {
1314
- className: "text-muted-foreground",
1315
- children: /* @__PURE__ */ Z(t, { id: "Synced" })
1316
- }),
1317
- /* @__PURE__ */ Z("dd", {
1318
- className: "tabular-nums",
1319
- children: e.synced_at ? m(e.synced_at) : "Live"
1320
- })
1321
- ]
1322
- }) : /* @__PURE__ */ Z("p", {
1323
- className: "text-muted-foreground",
1324
- children: /* @__PURE__ */ Z(t, { id: "Your directory holds no contact for this customer." })
1325
- })
1326
- })] });
1327
- }
1328
- //#endregion
1329
- export { Te as CustomerDetailPage };
1330
-
1331
- //# sourceMappingURL=admin-detail-CRzFb_pa.js.map