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