@nextblock-cms/ecom 0.20.1 → 0.21.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 (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@nextblock-cms/ui"),d=require("@nextblock-cms/utils"),o=require("./ProductScopePicker.cjs.js");function n(r){if(!r)return"";const i=new Date(r);return Number.isNaN(i.getTime())?"":i.toISOString().slice(0,16)}function u(r,i){const s=d.getCurrencyMinorUnitFactor(i)===1?0:2;return r.toFixed(s)}function m(r,i){return r?.discount_amount?r.discount_type==="fixed"?u(d.minorUnitAmountToMajor(r.discount_amount,i),i):r.discount_amount:10}function p({action:r,products:i,coupon:s,selectedProductIds:l=[],submitLabel:c,currencyCode:a="USD"}){return e.jsxs("form",{action:r,children:[e.jsx("input",{type:"hidden",name:"currency_code",value:a}),e.jsxs(t.Card,{children:[e.jsx(t.CardHeader,{children:e.jsx(t.CardTitle,{children:s?.id?"Edit Coupon":"Create Coupon"})}),e.jsxs(t.CardContent,{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"coupon-code",children:"Code"}),e.jsx(t.Input,{id:"coupon-code",name:"code",defaultValue:s?.code||"",className:"uppercase",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"coupon-name",children:"Name"}),e.jsx(t.Input,{id:"coupon-name",name:"name",defaultValue:s?.name||"",required:!0})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"provider-scope",children:"Provider scope"}),e.jsxs("select",{id:"provider-scope",name:"provider_scope",defaultValue:s?.provider_scope||"all",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"all",children:"Stripe + Freemius"}),e.jsx("option",{value:"stripe",children:"Stripe only"}),e.jsx("option",{value:"freemius",children:"Freemius only"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"discount-type",children:"Discount type"}),e.jsxs("select",{id:"discount-type",name:"discount_type",defaultValue:s?.discount_type||"percent",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"percent",children:"Percent"}),e.jsx("option",{value:"fixed",children:"Fixed amount"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"discount-amount",children:"Amount"}),e.jsx(t.Input,{id:"discount-amount",name:"discount_amount",type:"number",min:"0.01",step:"0.01",defaultValue:m(s,a),required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Percent coupons use 1-100. Fixed coupons use regular amounts, for example $10.00."})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"starts-at",children:"Starts at"}),e.jsx(t.Input,{id:"starts-at",name:"starts_at",type:"datetime-local",defaultValue:n(s?.starts_at)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"ends-at",children:"Ends at"}),e.jsx(t.Input,{id:"ends-at",name:"ends_at",type:"datetime-local",defaultValue:n(s?.ends_at)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"redemption-limit",children:"Redemption limit"}),e.jsx(t.Input,{id:"redemption-limit",name:"redemption_limit",type:"number",min:"1",defaultValue:s?.redemption_limit||""})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"internal-note",children:"Internal note"}),e.jsx(t.Textarea,{id:"internal-note",name:"internal_note",defaultValue:s?.internal_note||"",rows:3})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("input",{type:"hidden",name:"is_active",value:"false"}),e.jsxs("label",{htmlFor:"coupon-active",className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{id:"coupon-active",name:"is_active",type:"checkbox",value:"true",defaultChecked:s?.is_active??!0,className:"mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Active"}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:"Active coupons can be applied by shoppers during cart and checkout."})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Product scope"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave every product unchecked to apply this coupon to all products in the selected provider scope."})]}),e.jsx(o.ProductScopePicker,{products:i,selectedProductIds:l})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t.Button,{type:"submit",children:c})})]})]})]})}exports.CouponEditorForm=p;
1
+ const e=require("./ProductScopePicker.cjs.js");let t=require("@nextblock-cms/utils"),n=require("react/jsx-runtime"),r=require("@nextblock-cms/ui");function i(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function a(e,n){let r=(0,t.getCurrencyMinorUnitFactor)(n)===1?0:2;return e.toFixed(r)}function o(e,n){return e?.discount_amount?e.discount_type===`fixed`?a((0,t.minorUnitAmountToMajor)(e.discount_amount,n),n):e.discount_amount:10}function s({action:t,products:a,coupon:s,selectedProductIds:c=[],submitLabel:l,currencyCode:u=`USD`}){return(0,n.jsxs)(`form`,{action:t,children:[(0,n.jsx)(`input`,{type:`hidden`,name:`currency_code`,value:u}),(0,n.jsxs)(r.Card,{children:[(0,n.jsx)(r.CardHeader,{children:(0,n.jsx)(r.CardTitle,{children:s?.id?`Edit Coupon`:`Create Coupon`})}),(0,n.jsxs)(r.CardContent,{className:`space-y-6`,children:[(0,n.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`coupon-code`,children:`Code`}),(0,n.jsx)(r.Input,{id:`coupon-code`,name:`code`,defaultValue:s?.code||``,className:`uppercase`,required:!0})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`coupon-name`,children:`Name`}),(0,n.jsx)(r.Input,{id:`coupon-name`,name:`name`,defaultValue:s?.name||``,required:!0})]})]}),(0,n.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`provider-scope`,children:`Provider scope`}),(0,n.jsxs)(`select`,{id:`provider-scope`,name:`provider_scope`,defaultValue:s?.provider_scope||`all`,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,n.jsx)(`option`,{value:`all`,children:`Stripe + Freemius`}),(0,n.jsx)(`option`,{value:`stripe`,children:`Stripe only`}),(0,n.jsx)(`option`,{value:`freemius`,children:`Freemius only`})]})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`discount-type`,children:`Discount type`}),(0,n.jsxs)(`select`,{id:`discount-type`,name:`discount_type`,defaultValue:s?.discount_type||`percent`,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,n.jsx)(`option`,{value:`percent`,children:`Percent`}),(0,n.jsx)(`option`,{value:`fixed`,children:`Fixed amount`})]})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`discount-amount`,children:`Amount`}),(0,n.jsx)(r.Input,{id:`discount-amount`,name:`discount_amount`,type:`number`,min:`0.01`,step:`0.01`,defaultValue:o(s,u),required:!0}),(0,n.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Percent coupons use 1-100. Fixed coupons use regular amounts, for example $10.00.`})]})]}),(0,n.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`starts-at`,children:`Starts at`}),(0,n.jsx)(r.Input,{id:`starts-at`,name:`starts_at`,type:`datetime-local`,defaultValue:i(s?.starts_at)})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`ends-at`,children:`Ends at`}),(0,n.jsx)(r.Input,{id:`ends-at`,name:`ends_at`,type:`datetime-local`,defaultValue:i(s?.ends_at)})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`redemption-limit`,children:`Redemption limit`}),(0,n.jsx)(r.Input,{id:`redemption-limit`,name:`redemption_limit`,type:`number`,min:`1`,defaultValue:s?.redemption_limit||``})]})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`internal-note`,children:`Internal note`}),(0,n.jsx)(r.Textarea,{id:`internal-note`,name:`internal_note`,defaultValue:s?.internal_note||``,rows:3})]}),(0,n.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-4`,children:[(0,n.jsx)(`input`,{type:`hidden`,name:`is_active`,value:`false`}),(0,n.jsxs)(`label`,{htmlFor:`coupon-active`,className:`flex cursor-pointer items-start gap-3`,children:[(0,n.jsx)(`input`,{id:`coupon-active`,name:`is_active`,type:`checkbox`,value:`true`,defaultChecked:s?.is_active??!0,className:`mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary`}),(0,n.jsxs)(`span`,{children:[(0,n.jsx)(`span`,{className:`block text-sm font-medium`,children:`Active`}),(0,n.jsx)(`span`,{className:`block text-sm text-muted-foreground`,children:`Active coupons can be applied by shoppers during cart and checkout.`})]})]})]}),(0,n.jsxs)(`div`,{className:`space-y-3`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h3`,{className:`font-semibold`,children:`Product scope`}),(0,n.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Leave every product unchecked to apply this coupon to all products in the selected provider scope.`})]}),(0,n.jsx)(e.ProductScopePicker,{products:a,selectedProductIds:c})]}),(0,n.jsx)(`div`,{className:`flex justify-end`,children:(0,n.jsx)(r.Button,{type:`submit`,children:l})})]})]})]})}exports.CouponEditorForm=s;
@@ -19,5 +19,5 @@ export declare function CouponEditorForm({ action, products, coupon, selectedPro
19
19
  selectedProductIds?: string[];
20
20
  submitLabel: string;
21
21
  currencyCode?: string;
22
- }): import("react").JSX.Element;
22
+ }): import('react').JSX.Element;
23
23
  export {};
@@ -1,189 +1,231 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { Card as m, CardHeader as u, CardTitle as p, CardContent as h, Label as d, Input as n, Textarea as f, Button as v } from "@nextblock-cms/ui";
3
- import { minorUnitAmountToMajor as y, getCurrencyMinorUnitFactor as N } from "@nextblock-cms/utils";
4
- import { ProductScopePicker as x } from "./ProductScopePicker.es.js";
5
- function c(i) {
6
- if (!i)
7
- return "";
8
- const a = new Date(i);
9
- return Number.isNaN(a.getTime()) ? "" : a.toISOString().slice(0, 16);
1
+ import { ProductScopePicker as e } from "./ProductScopePicker.es.js";
2
+ import { getCurrencyMinorUnitFactor as t, minorUnitAmountToMajor as n } from "@nextblock-cms/utils";
3
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import { Button as a, Card as o, CardContent as s, CardHeader as c, CardTitle as l, Input as u, Label as d, Textarea as f } from "@nextblock-cms/ui";
5
+ //#region libs/ecommerce/src/lib/pages/cms/coupons/CouponEditorForm.tsx
6
+ function p(e) {
7
+ if (!e) return "";
8
+ let t = new Date(e);
9
+ return Number.isNaN(t.getTime()) ? "" : t.toISOString().slice(0, 16);
10
10
  }
11
- function g(i, a) {
12
- const r = N(a) === 1 ? 0 : 2;
13
- return i.toFixed(r);
11
+ function m(e, n) {
12
+ let r = t(n) === 1 ? 0 : 2;
13
+ return e.toFixed(r);
14
14
  }
15
- function b(i, a) {
16
- return i?.discount_amount ? i.discount_type === "fixed" ? g(
17
- y(i.discount_amount, a),
18
- a
19
- ) : i.discount_amount : 10;
15
+ function h(e, t) {
16
+ return e?.discount_amount ? e.discount_type === "fixed" ? m(n(e.discount_amount, t), t) : e.discount_amount : 10;
20
17
  }
21
- function V({
22
- action: i,
23
- products: a,
24
- coupon: r,
25
- selectedProductIds: s = [],
26
- submitLabel: o,
27
- currencyCode: l = "USD"
28
- }) {
29
- return /* @__PURE__ */ t("form", { action: i, children: [
30
- /* @__PURE__ */ e("input", { type: "hidden", name: "currency_code", value: l }),
31
- /* @__PURE__ */ t(m, { children: [
32
- /* @__PURE__ */ e(u, { children: /* @__PURE__ */ e(p, { children: r?.id ? "Edit Coupon" : "Create Coupon" }) }),
33
- /* @__PURE__ */ t(h, { className: "space-y-6", children: [
34
- /* @__PURE__ */ t("div", { className: "grid gap-4 md:grid-cols-2", children: [
35
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
36
- /* @__PURE__ */ e(d, { htmlFor: "coupon-code", children: "Code" }),
37
- /* @__PURE__ */ e(
38
- n,
39
- {
40
- id: "coupon-code",
41
- name: "code",
42
- defaultValue: r?.code || "",
43
- className: "uppercase",
44
- required: !0
45
- }
46
- )
47
- ] }),
48
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
49
- /* @__PURE__ */ e(d, { htmlFor: "coupon-name", children: "Name" }),
50
- /* @__PURE__ */ e(n, { id: "coupon-name", name: "name", defaultValue: r?.name || "", required: !0 })
51
- ] })
52
- ] }),
53
- /* @__PURE__ */ t("div", { className: "grid gap-4 md:grid-cols-3", children: [
54
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
55
- /* @__PURE__ */ e(d, { htmlFor: "provider-scope", children: "Provider scope" }),
56
- /* @__PURE__ */ t(
57
- "select",
58
- {
59
- id: "provider-scope",
60
- name: "provider_scope",
61
- defaultValue: r?.provider_scope || "all",
62
- className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
63
- children: [
64
- /* @__PURE__ */ e("option", { value: "all", children: "Stripe + Freemius" }),
65
- /* @__PURE__ */ e("option", { value: "stripe", children: "Stripe only" }),
66
- /* @__PURE__ */ e("option", { value: "freemius", children: "Freemius only" })
67
- ]
68
- }
69
- )
70
- ] }),
71
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
72
- /* @__PURE__ */ e(d, { htmlFor: "discount-type", children: "Discount type" }),
73
- /* @__PURE__ */ t(
74
- "select",
75
- {
76
- id: "discount-type",
77
- name: "discount_type",
78
- defaultValue: r?.discount_type || "percent",
79
- className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
80
- children: [
81
- /* @__PURE__ */ e("option", { value: "percent", children: "Percent" }),
82
- /* @__PURE__ */ e("option", { value: "fixed", children: "Fixed amount" })
83
- ]
84
- }
85
- )
86
- ] }),
87
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
88
- /* @__PURE__ */ e(d, { htmlFor: "discount-amount", children: "Amount" }),
89
- /* @__PURE__ */ e(
90
- n,
91
- {
92
- id: "discount-amount",
93
- name: "discount_amount",
94
- type: "number",
95
- min: "0.01",
96
- step: "0.01",
97
- defaultValue: b(r, l),
98
- required: !0
99
- }
100
- ),
101
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "Percent coupons use 1-100. Fixed coupons use regular amounts, for example $10.00." })
102
- ] })
103
- ] }),
104
- /* @__PURE__ */ t("div", { className: "grid gap-4 md:grid-cols-3", children: [
105
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
106
- /* @__PURE__ */ e(d, { htmlFor: "starts-at", children: "Starts at" }),
107
- /* @__PURE__ */ e(
108
- n,
109
- {
110
- id: "starts-at",
111
- name: "starts_at",
112
- type: "datetime-local",
113
- defaultValue: c(r?.starts_at)
114
- }
115
- )
116
- ] }),
117
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
118
- /* @__PURE__ */ e(d, { htmlFor: "ends-at", children: "Ends at" }),
119
- /* @__PURE__ */ e(
120
- n,
121
- {
122
- id: "ends-at",
123
- name: "ends_at",
124
- type: "datetime-local",
125
- defaultValue: c(r?.ends_at)
126
- }
127
- )
128
- ] }),
129
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
130
- /* @__PURE__ */ e(d, { htmlFor: "redemption-limit", children: "Redemption limit" }),
131
- /* @__PURE__ */ e(
132
- n,
133
- {
134
- id: "redemption-limit",
135
- name: "redemption_limit",
136
- type: "number",
137
- min: "1",
138
- defaultValue: r?.redemption_limit || ""
139
- }
140
- )
141
- ] })
142
- ] }),
143
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
144
- /* @__PURE__ */ e(d, { htmlFor: "internal-note", children: "Internal note" }),
145
- /* @__PURE__ */ e(
146
- f,
147
- {
148
- id: "internal-note",
149
- name: "internal_note",
150
- defaultValue: r?.internal_note || "",
151
- rows: 3
152
- }
153
- )
154
- ] }),
155
- /* @__PURE__ */ t("div", { className: "rounded-lg border bg-muted/20 p-4", children: [
156
- /* @__PURE__ */ e("input", { type: "hidden", name: "is_active", value: "false" }),
157
- /* @__PURE__ */ t("label", { htmlFor: "coupon-active", className: "flex cursor-pointer items-start gap-3", children: [
158
- /* @__PURE__ */ e(
159
- "input",
160
- {
161
- id: "coupon-active",
162
- name: "is_active",
163
- type: "checkbox",
164
- value: "true",
165
- defaultChecked: r?.is_active ?? !0,
166
- className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
167
- }
168
- ),
169
- /* @__PURE__ */ t("span", { children: [
170
- /* @__PURE__ */ e("span", { className: "block text-sm font-medium", children: "Active" }),
171
- /* @__PURE__ */ e("span", { className: "block text-sm text-muted-foreground", children: "Active coupons can be applied by shoppers during cart and checkout." })
172
- ] })
173
- ] })
174
- ] }),
175
- /* @__PURE__ */ t("div", { className: "space-y-3", children: [
176
- /* @__PURE__ */ t("div", { children: [
177
- /* @__PURE__ */ e("h3", { className: "font-semibold", children: "Product scope" }),
178
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Leave every product unchecked to apply this coupon to all products in the selected provider scope." })
179
- ] }),
180
- /* @__PURE__ */ e(x, { products: a, selectedProductIds: s })
181
- ] }),
182
- /* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(v, { type: "submit", children: o }) })
183
- ] })
184
- ] })
185
- ] });
18
+ function g({ action: t, products: n, coupon: m, selectedProductIds: g = [], submitLabel: _, currencyCode: v = "USD" }) {
19
+ return /* @__PURE__ */ i("form", {
20
+ action: t,
21
+ children: [/* @__PURE__ */ r("input", {
22
+ type: "hidden",
23
+ name: "currency_code",
24
+ value: v
25
+ }), /* @__PURE__ */ i(o, { children: [/* @__PURE__ */ r(c, { children: /* @__PURE__ */ r(l, { children: m?.id ? "Edit Coupon" : "Create Coupon" }) }), /* @__PURE__ */ i(s, {
26
+ className: "space-y-6",
27
+ children: [
28
+ /* @__PURE__ */ i("div", {
29
+ className: "grid gap-4 md:grid-cols-2",
30
+ children: [/* @__PURE__ */ i("div", {
31
+ className: "space-y-2",
32
+ children: [/* @__PURE__ */ r(d, {
33
+ htmlFor: "coupon-code",
34
+ children: "Code"
35
+ }), /* @__PURE__ */ r(u, {
36
+ id: "coupon-code",
37
+ name: "code",
38
+ defaultValue: m?.code || "",
39
+ className: "uppercase",
40
+ required: !0
41
+ })]
42
+ }), /* @__PURE__ */ i("div", {
43
+ className: "space-y-2",
44
+ children: [/* @__PURE__ */ r(d, {
45
+ htmlFor: "coupon-name",
46
+ children: "Name"
47
+ }), /* @__PURE__ */ r(u, {
48
+ id: "coupon-name",
49
+ name: "name",
50
+ defaultValue: m?.name || "",
51
+ required: !0
52
+ })]
53
+ })]
54
+ }),
55
+ /* @__PURE__ */ i("div", {
56
+ className: "grid gap-4 md:grid-cols-3",
57
+ children: [
58
+ /* @__PURE__ */ i("div", {
59
+ className: "space-y-2",
60
+ children: [/* @__PURE__ */ r(d, {
61
+ htmlFor: "provider-scope",
62
+ children: "Provider scope"
63
+ }), /* @__PURE__ */ i("select", {
64
+ id: "provider-scope",
65
+ name: "provider_scope",
66
+ defaultValue: m?.provider_scope || "all",
67
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
68
+ children: [
69
+ /* @__PURE__ */ r("option", {
70
+ value: "all",
71
+ children: "Stripe + Freemius"
72
+ }),
73
+ /* @__PURE__ */ r("option", {
74
+ value: "stripe",
75
+ children: "Stripe only"
76
+ }),
77
+ /* @__PURE__ */ r("option", {
78
+ value: "freemius",
79
+ children: "Freemius only"
80
+ })
81
+ ]
82
+ })]
83
+ }),
84
+ /* @__PURE__ */ i("div", {
85
+ className: "space-y-2",
86
+ children: [/* @__PURE__ */ r(d, {
87
+ htmlFor: "discount-type",
88
+ children: "Discount type"
89
+ }), /* @__PURE__ */ i("select", {
90
+ id: "discount-type",
91
+ name: "discount_type",
92
+ defaultValue: m?.discount_type || "percent",
93
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
94
+ children: [/* @__PURE__ */ r("option", {
95
+ value: "percent",
96
+ children: "Percent"
97
+ }), /* @__PURE__ */ r("option", {
98
+ value: "fixed",
99
+ children: "Fixed amount"
100
+ })]
101
+ })]
102
+ }),
103
+ /* @__PURE__ */ i("div", {
104
+ className: "space-y-2",
105
+ children: [
106
+ /* @__PURE__ */ r(d, {
107
+ htmlFor: "discount-amount",
108
+ children: "Amount"
109
+ }),
110
+ /* @__PURE__ */ r(u, {
111
+ id: "discount-amount",
112
+ name: "discount_amount",
113
+ type: "number",
114
+ min: "0.01",
115
+ step: "0.01",
116
+ defaultValue: h(m, v),
117
+ required: !0
118
+ }),
119
+ /* @__PURE__ */ r("p", {
120
+ className: "text-xs text-muted-foreground",
121
+ children: "Percent coupons use 1-100. Fixed coupons use regular amounts, for example $10.00."
122
+ })
123
+ ]
124
+ })
125
+ ]
126
+ }),
127
+ /* @__PURE__ */ i("div", {
128
+ className: "grid gap-4 md:grid-cols-3",
129
+ children: [
130
+ /* @__PURE__ */ i("div", {
131
+ className: "space-y-2",
132
+ children: [/* @__PURE__ */ r(d, {
133
+ htmlFor: "starts-at",
134
+ children: "Starts at"
135
+ }), /* @__PURE__ */ r(u, {
136
+ id: "starts-at",
137
+ name: "starts_at",
138
+ type: "datetime-local",
139
+ defaultValue: p(m?.starts_at)
140
+ })]
141
+ }),
142
+ /* @__PURE__ */ i("div", {
143
+ className: "space-y-2",
144
+ children: [/* @__PURE__ */ r(d, {
145
+ htmlFor: "ends-at",
146
+ children: "Ends at"
147
+ }), /* @__PURE__ */ r(u, {
148
+ id: "ends-at",
149
+ name: "ends_at",
150
+ type: "datetime-local",
151
+ defaultValue: p(m?.ends_at)
152
+ })]
153
+ }),
154
+ /* @__PURE__ */ i("div", {
155
+ className: "space-y-2",
156
+ children: [/* @__PURE__ */ r(d, {
157
+ htmlFor: "redemption-limit",
158
+ children: "Redemption limit"
159
+ }), /* @__PURE__ */ r(u, {
160
+ id: "redemption-limit",
161
+ name: "redemption_limit",
162
+ type: "number",
163
+ min: "1",
164
+ defaultValue: m?.redemption_limit || ""
165
+ })]
166
+ })
167
+ ]
168
+ }),
169
+ /* @__PURE__ */ i("div", {
170
+ className: "space-y-2",
171
+ children: [/* @__PURE__ */ r(d, {
172
+ htmlFor: "internal-note",
173
+ children: "Internal note"
174
+ }), /* @__PURE__ */ r(f, {
175
+ id: "internal-note",
176
+ name: "internal_note",
177
+ defaultValue: m?.internal_note || "",
178
+ rows: 3
179
+ })]
180
+ }),
181
+ /* @__PURE__ */ i("div", {
182
+ className: "rounded-lg border bg-muted/20 p-4",
183
+ children: [/* @__PURE__ */ r("input", {
184
+ type: "hidden",
185
+ name: "is_active",
186
+ value: "false"
187
+ }), /* @__PURE__ */ i("label", {
188
+ htmlFor: "coupon-active",
189
+ className: "flex cursor-pointer items-start gap-3",
190
+ children: [/* @__PURE__ */ r("input", {
191
+ id: "coupon-active",
192
+ name: "is_active",
193
+ type: "checkbox",
194
+ value: "true",
195
+ defaultChecked: m?.is_active ?? !0,
196
+ className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
197
+ }), /* @__PURE__ */ i("span", { children: [/* @__PURE__ */ r("span", {
198
+ className: "block text-sm font-medium",
199
+ children: "Active"
200
+ }), /* @__PURE__ */ r("span", {
201
+ className: "block text-sm text-muted-foreground",
202
+ children: "Active coupons can be applied by shoppers during cart and checkout."
203
+ })] })]
204
+ })]
205
+ }),
206
+ /* @__PURE__ */ i("div", {
207
+ className: "space-y-3",
208
+ children: [/* @__PURE__ */ i("div", { children: [/* @__PURE__ */ r("h3", {
209
+ className: "font-semibold",
210
+ children: "Product scope"
211
+ }), /* @__PURE__ */ r("p", {
212
+ className: "text-sm text-muted-foreground",
213
+ children: "Leave every product unchecked to apply this coupon to all products in the selected provider scope."
214
+ })] }), /* @__PURE__ */ r(e, {
215
+ products: n,
216
+ selectedProductIds: g
217
+ })]
218
+ }),
219
+ /* @__PURE__ */ r("div", {
220
+ className: "flex justify-end",
221
+ children: /* @__PURE__ */ r(a, {
222
+ type: "submit",
223
+ children: _
224
+ })
225
+ })
226
+ ]
227
+ })] })]
228
+ });
186
229
  }
187
- export {
188
- V as CouponEditorForm
189
- };
230
+ //#endregion
231
+ export { g as CouponEditorForm };
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("next/link"),r=require("@nextblock-cms/ui"),p=require("@nextblock-cms/db/server"),u=require("lucide-react"),h=require("@nextblock-cms/utils"),d=require("./actions.cjs.js"),f=require("./CreateCouponDialog.cjs.js"),j=require("./product-options.cjs.js");function y(t,n){return t.discount_type==="percent"?`${t.discount_amount}%`:h.formatPrice(t.discount_amount,n)}function g(t,n){return n?t==="synced"||t==="not_required"?"default":"secondary":"outline"}function v(t,n){const i=new Set;for(const c of t||[]){const a=c.product_id;a&&i.add(n.get(a)||a)}return i.size}function _(t,n){const i=v(t,n);return i===0?"All eligible products":`${i} scoped SKU${i===1?"":"s"}`}async function N({searchParams:t}){const n=p.getServiceRoleSupabaseClient();let i=n.from("coupons").select(`
1
+ const e=require("../../../../_virtual/_rolldown/runtime.cjs.js"),t=require("./actions.cjs.js"),n=require("./CreateCouponDialog.cjs.js"),r=require("./product-options.cjs.js");let i=require("next/link");i=e.__toESM(i,1);let a=require("lucide-react"),o=require("@nextblock-cms/utils"),s=require("react/jsx-runtime"),c=require("@nextblock-cms/db/server"),l=require("@nextblock-cms/ui");function u(e,t){return e.discount_type===`percent`?`${e.discount_amount}%`:(0,o.formatPrice)(e.discount_amount,t)}function d(e,t){return t?e===`synced`||e===`not_required`?`default`:`secondary`:`outline`}function f(e,t){let n=new Set;for(let r of e||[]){let e=r.product_id;e&&n.add(t.get(e)||e)}return n.size}function p(e,t){let n=f(e,t);return n===0?`All eligible products`:`${n} scoped SKU${n===1?``:`s`}`}async function m({searchParams:e}){let o=(0,c.getServiceRoleSupabaseClient)(),f=o.from(`coupons`).select(`
2
2
  *,
3
3
  coupon_products(product_id),
4
4
  coupon_freemius_mappings(sync_status, sync_error)
5
- `).order("created_at",{ascending:!1});t?.q&&(i=i.or(`code.ilike.%${t.q}%,name.ilike.%${t.q}%`)),t?.status==="active"?i=i.eq("is_active",!0):t?.status==="inactive"&&(i=i.eq("is_active",!1));const[{data:c},{data:a},{data:l}]=await Promise.all([i,n.from("products").select("id, title, sku, payment_provider, freemius_product_id, language:languages(code, name), product_media(sort_order, media(file_path, object_key))").order("title",{ascending:!0}),n.from("currencies").select("code, is_default").eq("is_active",!0)]),o=l?.find(s=>s.is_default)?.code||l?.[0]?.code||"USD",x=new Map((a||[]).map(s=>[s.id,s.sku?.trim().toUpperCase()||s.id]));return e.jsxs("div",{className:"mx-auto w-full max-w-7xl space-y-6 px-6 py-8",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-end md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Coupons"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create provider-aware discounts for Stripe checkout and Freemius licenses."})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("form",{className:"flex gap-2",action:"/cms/coupons",children:[e.jsx("input",{name:"q",placeholder:"Search coupons",defaultValue:t?.q||"",className:"h-10 rounded-md border border-input bg-background px-3 py-2 text-sm"}),e.jsxs("select",{name:"status",defaultValue:t?.status||"all",className:"h-10 rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"inactive",children:"Inactive"})]}),e.jsx(r.Button,{type:"submit",variant:"outline",children:"Filter"})]}),e.jsx(f.CreateCouponDialog,{action:d.createCouponAction,products:j.normalizeCouponProductOptions(a),currencyCode:o})]})]}),e.jsxs(r.Card,{children:[e.jsxs(r.CardHeader,{children:[e.jsx(r.CardTitle,{children:"All Coupons"}),e.jsx(r.CardDescription,{children:"Freemius sync runs when a coupon is created, updated, toggled, or manually resynced."})]}),e.jsx(r.CardContent,{children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/40 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"Code"}),e.jsx("th",{className:"px-4 py-3",children:"Scope"}),e.jsx("th",{className:"px-4 py-3",children:"Discount"}),e.jsx("th",{className:"px-4 py-3",children:"Usage"}),e.jsx("th",{className:"px-4 py-3",children:"Sync"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",children:c?.length?c.map(s=>e.jsxs("tr",{className:"align-top",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono font-semibold",children:s.code}),e.jsx(r.Badge,{variant:s.is_active?"default":"outline",children:s.is_active?"Active":"Inactive"})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.name})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("span",{className:"capitalize",children:s.provider_scope}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:_(s.coupon_products,x)})]}),e.jsx("td",{className:"px-4 py-3 font-medium",children:y(s,o)}),e.jsxs("td",{className:"px-4 py-3",children:[s.redemptions_count||0,s.redemption_limit?` / ${s.redemption_limit}`:""]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(r.Badge,{variant:g(s.freemius_sync_status,s.is_active),children:s.freemius_sync_status}),s.freemius_sync_error?e.jsx("p",{className:"mt-1 max-w-[220px] text-xs text-destructive",children:s.freemius_sync_error}):null]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(r.Button,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(m,{href:`/cms/coupons/${s.id}/edit`,children:"Edit"})}),e.jsx("form",{action:async()=>{"use server";await d.toggleCouponActiveAction(s.id,!s.is_active)},children:e.jsx(r.Button,{type:"submit",variant:"outline",size:"sm",children:s.is_active?"Disable":"Enable"})}),e.jsx("form",{action:async()=>{"use server";await d.syncCouponAction(s.id)},children:e.jsx(r.Button,{type:"submit",variant:"ghost",size:"icon",title:"Resync Freemius","aria-label":`Resync Freemius coupon ${s.code}`,children:e.jsx(u.RefreshCw,{className:"h-4 w-4"})})}),e.jsx("form",{action:async()=>{"use server";await d.deleteCouponAction(s.id)},children:e.jsx(r.Button,{type:"submit",variant:"ghost",size:"icon",className:"text-destructive","aria-label":`Delete coupon ${s.code}`,children:e.jsx(u.Trash2,{className:"h-4 w-4"})})})]})})]},s.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-10 text-center text-muted-foreground",children:"No coupons yet."})})})]})})})]})]})}exports.CouponsPage=N;
5
+ `).order(`created_at`,{ascending:!1});e?.q&&(f=f.or(`code.ilike.%${e.q}%,name.ilike.%${e.q}%`)),e?.status===`active`?f=f.eq(`is_active`,!0):e?.status===`inactive`&&(f=f.eq(`is_active`,!1));let[{data:m},{data:h},{data:g}]=await Promise.all([f,o.from(`products`).select(`id, title, sku, payment_provider, freemius_product_id, language:languages(code, name), product_media(sort_order, media(file_path, object_key))`).order(`title`,{ascending:!0}),o.from(`currencies`).select(`code, is_default`).eq(`is_active`,!0)]),_=g?.find(e=>e.is_default)?.code||g?.[0]?.code||`USD`,v=new Map((h||[]).map(e=>[e.id,e.sku?.trim().toUpperCase()||e.id]));return(0,s.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl space-y-6 px-6 py-8`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-end md:justify-between`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight`,children:`Coupons`}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Create provider-aware discounts for Stripe checkout and Freemius licenses.`})]}),(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,s.jsxs)(`form`,{className:`flex gap-2`,action:`/cms/coupons`,children:[(0,s.jsx)(`input`,{name:`q`,placeholder:`Search coupons`,defaultValue:e?.q||``,className:`h-10 rounded-md border border-input bg-background px-3 py-2 text-sm`}),(0,s.jsxs)(`select`,{name:`status`,defaultValue:e?.status||`all`,className:`h-10 rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,s.jsx)(`option`,{value:`all`,children:`All`}),(0,s.jsx)(`option`,{value:`active`,children:`Active`}),(0,s.jsx)(`option`,{value:`inactive`,children:`Inactive`})]}),(0,s.jsx)(l.Button,{type:`submit`,variant:`outline`,children:`Filter`})]}),(0,s.jsx)(n.CreateCouponDialog,{action:t.createCouponAction,products:r.normalizeCouponProductOptions(h),currencyCode:_})]})]}),(0,s.jsxs)(l.Card,{children:[(0,s.jsxs)(l.CardHeader,{children:[(0,s.jsx)(l.CardTitle,{children:`All Coupons`}),(0,s.jsx)(l.CardDescription,{children:`Freemius sync runs when a coupon is created, updated, toggled, or manually resynced.`})]}),(0,s.jsx)(l.CardContent,{children:(0,s.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:(0,s.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,s.jsx)(`thead`,{className:`border-b bg-muted/40 text-xs uppercase text-muted-foreground`,children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{className:`px-4 py-3`,children:`Code`}),(0,s.jsx)(`th`,{className:`px-4 py-3`,children:`Scope`}),(0,s.jsx)(`th`,{className:`px-4 py-3`,children:`Discount`}),(0,s.jsx)(`th`,{className:`px-4 py-3`,children:`Usage`}),(0,s.jsx)(`th`,{className:`px-4 py-3`,children:`Sync`}),(0,s.jsx)(`th`,{className:`px-4 py-3 text-right`,children:`Actions`})]})}),(0,s.jsx)(`tbody`,{className:`divide-y`,children:m?.length?m.map(e=>(0,s.jsxs)(`tr`,{className:`align-top`,children:[(0,s.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`font-mono font-semibold`,children:e.code}),(0,s.jsx)(l.Badge,{variant:e.is_active?`default`:`outline`,children:e.is_active?`Active`:`Inactive`})]}),(0,s.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.name})]}),(0,s.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,s.jsx)(`span`,{className:`capitalize`,children:e.provider_scope}),(0,s.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:p(e.coupon_products,v)})]}),(0,s.jsx)(`td`,{className:`px-4 py-3 font-medium`,children:u(e,_)}),(0,s.jsxs)(`td`,{className:`px-4 py-3`,children:[e.redemptions_count||0,e.redemption_limit?` / ${e.redemption_limit}`:``]}),(0,s.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,s.jsx)(l.Badge,{variant:d(e.freemius_sync_status,e.is_active),children:e.freemius_sync_status}),e.freemius_sync_error?(0,s.jsx)(`p`,{className:`mt-1 max-w-[220px] text-xs text-destructive`,children:e.freemius_sync_error}):null]}),(0,s.jsx)(`td`,{className:`px-4 py-3`,children:(0,s.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,s.jsx)(l.Button,{asChild:!0,variant:`outline`,size:`sm`,children:(0,s.jsx)(i.default,{href:`/cms/coupons/${e.id}/edit`,children:`Edit`})}),(0,s.jsx)(`form`,{action:async()=>{"use server";await t.toggleCouponActiveAction(e.id,!e.is_active)},children:(0,s.jsx)(l.Button,{type:`submit`,variant:`outline`,size:`sm`,children:e.is_active?`Disable`:`Enable`})}),(0,s.jsx)(`form`,{action:async()=>{"use server";await t.syncCouponAction(e.id)},children:(0,s.jsx)(l.Button,{type:`submit`,variant:`ghost`,size:`icon`,title:`Resync Freemius`,"aria-label":`Resync Freemius coupon ${e.code}`,children:(0,s.jsx)(a.RefreshCw,{className:`h-4 w-4`})})}),(0,s.jsx)(`form`,{action:async()=>{"use server";await t.deleteCouponAction(e.id)},children:(0,s.jsx)(l.Button,{type:`submit`,variant:`ghost`,size:`icon`,className:`text-destructive`,"aria-label":`Delete coupon ${e.code}`,children:(0,s.jsx)(a.Trash2,{className:`h-4 w-4`})})})]})})]},e.id)):(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:6,className:`px-4 py-10 text-center text-muted-foreground`,children:`No coupons yet.`})})})]})})})]})]})}exports.CouponsPage=m;
@@ -4,5 +4,5 @@ type SearchParams = {
4
4
  };
5
5
  export declare function CouponsPage({ searchParams, }: {
6
6
  searchParams?: SearchParams;
7
- }): Promise<import("react").JSX.Element>;
7
+ }): Promise<import('react').JSX.Element>;
8
8
  export {};