@nextblock-cms/ecom 0.20.3 → 0.21.1

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 (446) hide show
  1. package/README.md +43 -0
  2. package/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/index.cjs +1 -0
  4. package/index.es.js +38 -146
  5. package/lib/CurrencyProvider.cjs +1 -0
  6. package/lib/CurrencyProvider.d.ts +1 -1
  7. package/lib/CurrencyProvider.es.js +85 -95
  8. package/lib/PaymentReadinessProvider.cjs +1 -0
  9. package/lib/PaymentReadinessProvider.d.ts +1 -1
  10. package/lib/PaymentReadinessProvider.es.js +24 -27
  11. package/lib/cart-store.cjs +1 -0
  12. package/lib/cart-store.es.js +109 -121
  13. package/lib/components/AccountNavigationMenu.cjs +1 -0
  14. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  15. package/lib/components/AccountNavigationMenu.es.js +36 -50
  16. package/lib/components/AddToCartButton.cjs +1 -0
  17. package/lib/components/AddToCartButton.d.ts +1 -1
  18. package/lib/components/AddToCartButton.es.js +94 -89
  19. package/lib/components/Cart.cjs +1 -0
  20. package/lib/components/Cart.d.ts +1 -1
  21. package/lib/components/Cart.es.js +261 -180
  22. package/lib/components/CartDrawer.cjs +1 -0
  23. package/lib/components/CartDrawer.d.ts +1 -1
  24. package/lib/components/CartDrawer.es.js +218 -148
  25. package/lib/components/CartIcon.cjs +1 -0
  26. package/lib/components/CartIcon.d.ts +1 -1
  27. package/lib/components/CartIcon.es.js +33 -35
  28. package/lib/components/Checkout.cjs +1 -0
  29. package/lib/components/Checkout.d.ts +1 -1
  30. package/lib/components/Checkout.es.js +1092 -1108
  31. package/lib/components/CouponForm.cjs +1 -0
  32. package/lib/components/CouponForm.d.ts +1 -1
  33. package/lib/components/CouponForm.es.js +136 -148
  34. package/lib/components/CurrencySwitcher.cjs +1 -0
  35. package/lib/components/CurrencySwitcher.d.ts +1 -1
  36. package/lib/components/CurrencySwitcher.es.js +22 -18
  37. package/lib/components/CustomerProfileForm.cjs +1 -0
  38. package/lib/components/CustomerProfileForm.es.js +454 -313
  39. package/lib/components/FeaturedProduct.cjs +1 -0
  40. package/lib/components/FeaturedProduct.d.ts +1 -1
  41. package/lib/components/FeaturedProduct.es.js +98 -83
  42. package/lib/components/FreemiusLicensePanel.cjs +1 -0
  43. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  44. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  45. package/lib/components/InvoiceDocument.cjs +1 -0
  46. package/lib/components/InvoiceDocument.es.js +256 -192
  47. package/lib/components/InvoiceViewerShell.cjs +29 -0
  48. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  49. package/lib/components/InvoiceViewerShell.es.js +75 -106
  50. package/lib/components/ProductCard.cjs +1 -0
  51. package/lib/components/ProductCard.d.ts +1 -1
  52. package/lib/components/ProductCard.es.js +186 -171
  53. package/lib/components/ProductDetailsLayout.cjs +1 -0
  54. package/lib/components/ProductDetailsLayout.es.js +405 -404
  55. package/lib/components/ProductGallery.cjs +1 -0
  56. package/lib/components/ProductGallery.d.ts +1 -1
  57. package/lib/components/ProductGallery.es.js +51 -54
  58. package/lib/components/ProductGrid.cjs +1 -0
  59. package/lib/components/ProductGrid.d.ts +1 -1
  60. package/lib/components/ProductGrid.es.js +23 -25
  61. package/lib/components/ShippingEstimator.cjs +1 -0
  62. package/lib/components/ShippingEstimator.d.ts +1 -1
  63. package/lib/components/ShippingEstimator.es.js +158 -153
  64. package/lib/components/ShortDescription.cjs +1 -0
  65. package/lib/components/ShortDescription.es.js +17 -17
  66. package/lib/components/SimpleTiptapRenderer.cjs +1 -0
  67. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  68. package/lib/components/SubscriptionSelector.cjs +1 -0
  69. package/lib/components/SubscriptionSelector.es.js +159 -154
  70. package/lib/countries.cjs +1 -0
  71. package/lib/countries.es.js +232 -75
  72. package/lib/coupon-server.cjs +1 -0
  73. package/lib/coupon-server.es.js +180 -224
  74. package/lib/coupons.cjs +1 -0
  75. package/lib/coupons.es.js +12 -14
  76. package/lib/currency-constants.cjs +1 -0
  77. package/lib/currency-constants.es.js +4 -4
  78. package/lib/currency-rest-client.cjs +1 -0
  79. package/lib/currency-rest-client.es.js +15 -22
  80. package/lib/currency-store.cjs +1 -0
  81. package/lib/currency-store.es.js +20 -27
  82. package/lib/currency-sync.cjs +1 -0
  83. package/lib/currency-sync.es.js +124 -170
  84. package/lib/currency.cjs +1 -0
  85. package/lib/currency.es.js +242 -310
  86. package/lib/customer-addresses.cjs +1 -0
  87. package/lib/customer-addresses.es.js +80 -109
  88. package/lib/customer-orders.cjs +1 -0
  89. package/lib/customer-orders.es.js +31 -43
  90. package/lib/customer.cjs +1 -0
  91. package/lib/customer.es.js +43 -52
  92. package/lib/export-helpers.cjs +1 -0
  93. package/lib/export-helpers.es.js +53 -52
  94. package/lib/factory.cjs +1 -0
  95. package/lib/factory.es.js +10 -7
  96. package/lib/freemius-coupons.cjs +1 -0
  97. package/lib/freemius-coupons.es.js +245 -262
  98. package/lib/freemius-license-claim.cjs +1 -0
  99. package/lib/freemius-license-claim.es.js +87 -71
  100. package/lib/freemius-license.cjs +1 -0
  101. package/lib/freemius-license.es.js +32 -39
  102. package/lib/freemius-order-sync.cjs +1 -0
  103. package/lib/freemius-order-sync.es.js +226 -290
  104. package/lib/freemius-trial-provision.cjs +1 -0
  105. package/lib/freemius-trial-provision.es.js +136 -130
  106. package/lib/inventory-settings.cjs +1 -0
  107. package/lib/inventory-settings.es.js +69 -77
  108. package/lib/invoice-server.cjs +33 -0
  109. package/lib/invoice-server.es.js +94 -141
  110. package/lib/invoice-ui.cjs +1 -0
  111. package/lib/invoice-ui.es.js +50 -66
  112. package/lib/invoice.cjs +1 -0
  113. package/lib/invoice.es.js +85 -94
  114. package/lib/order-inventory.cjs +61 -0
  115. package/lib/order-inventory.es.js +67 -79
  116. package/lib/order-tax-details.cjs +1 -0
  117. package/lib/order-tax-details.es.js +142 -153
  118. package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
  119. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  120. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  121. package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
  122. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  123. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  124. package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
  125. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  126. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  127. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
  128. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  129. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  130. package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
  131. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  132. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  133. package/lib/pages/cms/coupons/actions.cjs +1 -0
  134. package/lib/pages/cms/coupons/actions.es.js +112 -115
  135. package/lib/pages/cms/coupons/index.cjs +1 -0
  136. package/lib/pages/cms/coupons/index.es.js +3 -0
  137. package/lib/pages/cms/coupons/product-options.cjs +1 -0
  138. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  139. package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
  140. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  141. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
  143. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  144. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  145. package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
  146. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  147. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  148. package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
  149. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  150. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  151. package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
  152. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  153. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  154. package/lib/pages/cms/orders/actions.cjs +7 -0
  155. package/lib/pages/cms/orders/actions.es.js +53 -69
  156. package/lib/pages/cms/orders/export-actions.cjs +1 -0
  157. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  158. package/lib/pages/cms/orders/index.cjs +1 -0
  159. package/lib/pages/cms/orders/index.es.js +6 -0
  160. package/lib/pages/cms/orders/server-actions.cjs +1 -0
  161. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  162. package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
  163. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  164. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  165. package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
  166. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  167. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  168. package/lib/pages/cms/payments/actions.cjs +1 -0
  169. package/lib/pages/cms/payments/actions.es.js +38 -48
  170. package/lib/pages/cms/payments/index.cjs +1 -0
  171. package/lib/pages/cms/payments/index.es.js +3 -0
  172. package/lib/pages/cms/payments/queries.cjs +1 -0
  173. package/lib/pages/cms/payments/queries.es.js +38 -48
  174. package/lib/pages/cms/products/ProductsPage.cjs +1 -0
  175. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  176. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  177. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
  178. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  179. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
  180. package/lib/pages/cms/products/actions.cjs +44 -0
  181. package/lib/pages/cms/products/actions.es.js +121 -162
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  184. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  187. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  190. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  191. package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
  192. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
  194. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  197. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  198. package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
  199. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  200. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  203. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  204. package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
  205. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  206. package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
  207. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  208. package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
  209. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  210. package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
  211. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  212. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  213. package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
  214. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  215. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  218. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  221. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  222. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
  224. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  225. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  226. package/lib/pages/cms/products/index.cjs +1 -0
  227. package/lib/pages/cms/products/index.es.js +8 -0
  228. package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
  229. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  230. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  233. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  234. package/lib/pages/cms/products/inventory/actions.cjs +3 -0
  235. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  236. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
  237. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  238. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  239. package/lib/pages/cms/products/product-price-sync.cjs +1 -0
  240. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  241. package/lib/pages/cms/products/server-actions.cjs +1 -0
  242. package/lib/pages/cms/products/server-actions.es.js +250 -233
  243. package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
  244. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  245. package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
  246. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  247. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  248. package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
  249. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  250. package/lib/pages/cms/shipping/index.cjs +1 -0
  251. package/lib/pages/cms/shipping/index.es.js +3 -0
  252. package/lib/pages/cms/shipping/server-actions.cjs +1 -0
  253. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  254. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
  255. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  256. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  257. package/lib/pages/cms/taxes/actions.cjs +1 -0
  258. package/lib/pages/cms/taxes/actions.es.js +41 -53
  259. package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
  260. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  261. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  262. package/lib/pages/cms/taxes/index.cjs +1 -0
  263. package/lib/pages/cms/taxes/index.es.js +3 -0
  264. package/lib/payment-config.cjs +1 -0
  265. package/lib/payment-config.es.js +110 -126
  266. package/lib/product-actions.cjs +238 -0
  267. package/lib/product-actions.es.js +289 -544
  268. package/lib/product-context.cjs +1 -0
  269. package/lib/product-context.es.js +13 -15
  270. package/lib/product-schema.cjs +1 -0
  271. package/lib/product-schema.es.js +99 -134
  272. package/lib/providers/freemius.cjs +1 -0
  273. package/lib/providers/freemius.es.js +446 -530
  274. package/lib/providers/stripe.cjs +1 -0
  275. package/lib/providers/stripe.es.js +417 -477
  276. package/lib/server-actions/coupon-actions.cjs +1 -0
  277. package/lib/server-actions/coupon-actions.es.js +22 -22
  278. package/lib/server-actions/customer-actions.cjs +1 -0
  279. package/lib/server-actions/customer-actions.es.js +26 -28
  280. package/lib/server-actions/product-actions.cjs +1 -0
  281. package/lib/server-actions/product-actions.es.js +9 -15
  282. package/lib/server-actions/shipping-actions.cjs +1 -0
  283. package/lib/server-actions/shipping-actions.es.js +27 -24
  284. package/lib/server-actions/tax-actions.cjs +1 -0
  285. package/lib/server-actions/tax-actions.es.js +33 -39
  286. package/lib/shared-inventory.cjs +15 -0
  287. package/lib/shared-inventory.es.js +111 -160
  288. package/lib/shipping/resolver.cjs +7 -0
  289. package/lib/shipping/resolver.es.js +44 -61
  290. package/lib/shipping-rate-currency.cjs +1 -0
  291. package/lib/shipping-rate-currency.es.js +52 -67
  292. package/lib/states.cjs +1 -0
  293. package/lib/states.es.js +333 -154
  294. package/lib/stripe/checkout.cjs +1 -0
  295. package/lib/stripe/checkout.es.js +125 -181
  296. package/lib/stripe/client.cjs +1 -0
  297. package/lib/stripe/client.es.js +14 -19
  298. package/lib/stripe/order-sync.cjs +1 -0
  299. package/lib/stripe/order-sync.es.js +106 -126
  300. package/lib/stripe/webhooks.cjs +1 -0
  301. package/lib/stripe/webhooks.es.js +37 -31
  302. package/lib/tax-calculation.cjs +1 -0
  303. package/lib/tax-calculation.es.js +84 -98
  304. package/lib/trials.cjs +1 -0
  305. package/lib/trials.es.js +24 -30
  306. package/lib/types.cjs +1 -0
  307. package/lib/types.es.js +21 -27
  308. package/lib/use-cart.cjs +1 -0
  309. package/lib/use-cart.es.js +38 -40
  310. package/lib/use-price-formatter.cjs +1 -0
  311. package/lib/use-price-formatter.es.js +10 -11
  312. package/lib/variation-utils.cjs +1 -0
  313. package/lib/variation-utils.es.js +199 -261
  314. package/lib/zod-config.cjs +1 -0
  315. package/lib/zod-config.es.js +5 -6
  316. package/package.json +22 -21
  317. package/server.cjs +1 -0
  318. package/server.es.js +56 -211
  319. package/index.cjs.js +0 -1
  320. package/lib/CurrencyProvider.cjs.js +0 -1
  321. package/lib/PaymentReadinessProvider.cjs.js +0 -1
  322. package/lib/cart-store.cjs.js +0 -1
  323. package/lib/components/AccountNavigationMenu.cjs.js +0 -1
  324. package/lib/components/AddToCartButton.cjs.js +0 -1
  325. package/lib/components/Cart.cjs.js +0 -1
  326. package/lib/components/CartDrawer.cjs.js +0 -1
  327. package/lib/components/CartIcon.cjs.js +0 -1
  328. package/lib/components/Checkout.cjs.js +0 -1
  329. package/lib/components/CouponForm.cjs.js +0 -1
  330. package/lib/components/CurrencySwitcher.cjs.js +0 -1
  331. package/lib/components/CustomerProfileForm.cjs.js +0 -1
  332. package/lib/components/FeaturedProduct.cjs.js +0 -1
  333. package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
  334. package/lib/components/InvoiceDocument.cjs.js +0 -1
  335. package/lib/components/InvoiceViewerShell.cjs.js +0 -29
  336. package/lib/components/ProductCard.cjs.js +0 -1
  337. package/lib/components/ProductDetailsLayout.cjs.js +0 -1
  338. package/lib/components/ProductGallery.cjs.js +0 -1
  339. package/lib/components/ProductGrid.cjs.js +0 -1
  340. package/lib/components/ShippingEstimator.cjs.js +0 -1
  341. package/lib/components/ShortDescription.cjs.js +0 -1
  342. package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
  343. package/lib/components/SubscriptionSelector.cjs.js +0 -1
  344. package/lib/countries.cjs.js +0 -1
  345. package/lib/coupon-server.cjs.js +0 -1
  346. package/lib/coupons.cjs.js +0 -1
  347. package/lib/currency-constants.cjs.js +0 -1
  348. package/lib/currency-rest-client.cjs.js +0 -1
  349. package/lib/currency-store.cjs.js +0 -1
  350. package/lib/currency-sync.cjs.js +0 -1
  351. package/lib/currency.cjs.js +0 -1
  352. package/lib/customer-addresses.cjs.js +0 -1
  353. package/lib/customer-orders.cjs.js +0 -1
  354. package/lib/customer.cjs.js +0 -1
  355. package/lib/export-helpers.cjs.js +0 -1
  356. package/lib/factory.cjs.js +0 -1
  357. package/lib/freemius-coupons.cjs.js +0 -1
  358. package/lib/freemius-license-claim.cjs.js +0 -1
  359. package/lib/freemius-license.cjs.js +0 -1
  360. package/lib/freemius-order-sync.cjs.js +0 -1
  361. package/lib/freemius-trial-provision.cjs.js +0 -1
  362. package/lib/inventory-settings.cjs.js +0 -1
  363. package/lib/invoice-server.cjs.js +0 -33
  364. package/lib/invoice-ui.cjs.js +0 -1
  365. package/lib/invoice.cjs.js +0 -1
  366. package/lib/order-inventory.cjs.js +0 -61
  367. package/lib/order-tax-details.cjs.js +0 -1
  368. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
  369. package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
  370. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
  371. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
  372. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
  373. package/lib/pages/cms/coupons/actions.cjs.js +0 -1
  374. package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
  375. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
  376. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
  377. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
  378. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
  379. package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
  380. package/lib/pages/cms/orders/actions.cjs.js +0 -7
  381. package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
  382. package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
  383. package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
  384. package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
  385. package/lib/pages/cms/payments/actions.cjs.js +0 -1
  386. package/lib/pages/cms/payments/queries.cjs.js +0 -1
  387. package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
  388. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
  389. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
  390. package/lib/pages/cms/products/actions.cjs.js +0 -44
  391. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
  392. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
  393. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
  394. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
  395. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
  396. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
  397. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
  398. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
  399. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
  400. package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
  401. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
  402. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
  403. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
  404. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
  405. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
  406. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
  407. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
  408. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
  409. package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
  410. package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
  411. package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
  412. package/lib/pages/cms/products/server-actions.cjs.js +0 -1
  413. package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
  414. package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
  415. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
  416. package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
  417. package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
  418. package/lib/pages/cms/taxes/actions.cjs.js +0 -1
  419. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
  420. package/lib/payment-config.cjs.js +0 -1
  421. package/lib/product-actions.cjs.js +0 -238
  422. package/lib/product-context.cjs.js +0 -1
  423. package/lib/product-schema.cjs.js +0 -1
  424. package/lib/providers/freemius.cjs.js +0 -5
  425. package/lib/providers/stripe.cjs.js +0 -1
  426. package/lib/server-actions/coupon-actions.cjs.js +0 -1
  427. package/lib/server-actions/customer-actions.cjs.js +0 -1
  428. package/lib/server-actions/product-actions.cjs.js +0 -1
  429. package/lib/server-actions/shipping-actions.cjs.js +0 -1
  430. package/lib/server-actions/tax-actions.cjs.js +0 -1
  431. package/lib/shared-inventory.cjs.js +0 -15
  432. package/lib/shipping/resolver.cjs.js +0 -7
  433. package/lib/shipping-rate-currency.cjs.js +0 -1
  434. package/lib/states.cjs.js +0 -1
  435. package/lib/stripe/checkout.cjs.js +0 -1
  436. package/lib/stripe/client.cjs.js +0 -1
  437. package/lib/stripe/order-sync.cjs.js +0 -1
  438. package/lib/stripe/webhooks.cjs.js +0 -1
  439. package/lib/tax-calculation.cjs.js +0 -1
  440. package/lib/trials.cjs.js +0 -1
  441. package/lib/types.cjs.js +0 -1
  442. package/lib/use-cart.cjs.js +0 -1
  443. package/lib/use-price-formatter.cjs.js +0 -1
  444. package/lib/variation-utils.cjs.js +0 -1
  445. package/lib/zod-config.cjs.js +0 -1
  446. package/server.cjs.js +0 -1
@@ -1,233 +1,250 @@
1
- 'use server';
2
- import { getServiceRoleSupabaseClient as n, createClient as i } from "@nextblock-cms/db/server";
3
- import { createProduct as y, deleteProduct as h, syncCategoriesForTranslationGroup as A } from "../../../product-actions.es.js";
4
- import { syncProductSaleCouponToFreemius as S } from "../../../freemius-coupons.es.js";
5
- import { normalizeCurrencyRecord as g } from "../../../currency.es.js";
6
- import { sanitizeProductFormValuesForStoreManagedCurrencies as _ } from "./product-price-sync.es.js";
7
- import { revalidatePath as s } from "next/cache";
8
- import { redirect as P } from "next/navigation";
9
- function d(r) {
10
- return r.toLowerCase().trim().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
11
- }
12
- async function F(r) {
13
- const e = i(), { data: t } = await e.from("currencies").select(
14
- "code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
15
- ).eq("is_active", !0).order("code", { ascending: !0 }), o = _(
16
- r,
17
- (t || []).map((c) => g(c))
18
- ), a = await y(e, o);
19
- if (o.payment_provider === "freemius" && a?.id)
20
- try {
21
- await S({
22
- productId: a.id,
23
- client: n()
24
- });
25
- } catch (c) {
26
- console.error("Failed to sync Freemius sale coupon on create:", c);
27
- }
28
- s("/cms/products"), P("/cms/products");
29
- }
30
- async function q(r, e, t, o) {
31
- const a = {
32
- author_id: t,
33
- meta: o,
34
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
35
- }, c = async () => {
36
- const { error: f } = await r.from("product_drafts").update(a).eq("product_id", e);
37
- if (f)
38
- throw new Error(`Failed to save product draft: ${f.message}`);
39
- }, { data: u, error: l } = await r.from("product_drafts").select("id").eq("product_id", e).maybeSingle();
40
- if (l)
41
- throw new Error(`Failed to read product draft: ${l.message}`);
42
- if (u) {
43
- await c();
44
- return;
45
- }
46
- const { data: w, error: p } = await r.from("blocks").select(
47
- "id, page_id, post_id, product_id, language_id, block_type, content, order, created_at, updated_at"
48
- ).eq("product_id", e).order("order", { ascending: !0 });
49
- if (p)
50
- throw new Error(`Failed to read product blocks: ${p.message}`);
51
- const { error: m } = await r.from("product_drafts").insert({
52
- ...a,
53
- blocks: w ?? [],
54
- product_id: e
55
- });
56
- if (m) {
57
- if (m.code === "23505") {
58
- await c();
59
- return;
60
- }
61
- throw new Error(`Failed to save product draft: ${m.message}`);
62
- }
63
- }
64
- async function k(r, e) {
65
- const t = i(), { data: { user: o } } = await t.auth.getUser();
66
- if (!o)
67
- throw new Error("User not authenticated.");
68
- const { data: a } = await t.from("currencies").select(
69
- "code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
70
- ).eq("is_active", !0).order("code", { ascending: !0 }), c = _(
71
- e,
72
- (a || []).map((u) => g(u))
73
- );
74
- return await q(t, r, o.id, c), { success: !0 };
75
- }
76
- async function $(r) {
77
- const e = i();
78
- await h(e, r), s("/cms/products");
79
- }
80
- function b(r) {
81
- return Array.from(
82
- new Set(
83
- r.map((e) => e.trim()).filter(Boolean)
84
- )
85
- );
86
- }
87
- async function O(r) {
88
- const e = b(r);
89
- if (e.length === 0)
90
- return { success: !1, error: "Select at least one product." };
91
- const t = i(), { error: o } = await t.from("products").delete().in("id", e);
92
- return o ? { success: !1, error: o.message } : (s("/cms/products"), { success: !0, count: e.length });
93
- }
94
- async function z(r) {
95
- const e = b(r);
96
- if (e.length === 0)
97
- return { success: !1, error: "Select at least one product." };
98
- const t = i(), { error: o } = await t.from("products").update({
99
- status: "draft",
100
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
101
- }).in("id", e);
102
- return o ? { success: !1, error: o.message } : (s("/cms/products"), { success: !0, count: e.length });
103
- }
104
- async function U(r) {
105
- const e = String(r || "").trim();
106
- if (!e)
107
- return { error: "Missing product id." };
108
- const t = i(), {
109
- data: { user: o }
110
- } = await t.auth.getUser();
111
- if (!o)
112
- return { error: "You must be signed in to publish a product." };
113
- const { data: a, error: c } = await t.from("products").update({
114
- status: "active",
115
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
116
- }).eq("id", e).select("slug").single();
117
- return c || !a ? { error: c?.message || "Could not publish the product." } : (s("/cms/products"), s(`/cms/products/${e}/edit`), a.slug && s(`/product/${a.slug}`), {});
118
- }
119
- async function M(r) {
120
- const e = n(), t = r.name.trim(), o = d(r.slug?.trim() || r.name);
121
- if (!t || !o)
122
- return { success: !1, error: "Attribute name is required." };
123
- const { error: a } = await e.from("product_attributes").insert({
124
- name: t,
125
- slug: o
126
- });
127
- return a ? { success: !1, error: a.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
128
- }
129
- async function B(r) {
130
- const e = n(), { error: t } = await e.from("product_attributes").delete().eq("id", r);
131
- return t ? { success: !1, error: t.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
132
- }
133
- async function R(r) {
134
- const e = n(), t = r.value.trim(), o = d(r.slug?.trim() || r.value);
135
- if (!t || !o)
136
- return { success: !1, error: "Term value is required." };
137
- const { data: a } = await e.from("product_attribute_terms").select("sort_order").eq("attribute_id", r.attributeId).order("sort_order", { ascending: !1 }).limit(1), c = typeof a?.[0]?.sort_order == "number" ? a[0].sort_order + 1 : 0, { error: u } = await e.from("product_attribute_terms").insert({
138
- attribute_id: r.attributeId,
139
- value: t,
140
- slug: o,
141
- sort_order: c
142
- });
143
- return u ? { success: !1, error: u.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
144
- }
145
- async function G(r) {
146
- const e = n();
147
- for (const [t, o] of r.orderedTermIds.entries()) {
148
- const { error: a } = await e.from("product_attribute_terms").update({
149
- sort_order: t,
150
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
151
- }).eq("id", o).eq("attribute_id", r.attributeId);
152
- if (a)
153
- return { success: !1, error: a.message };
154
- }
155
- return s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 };
156
- }
157
- async function L(r) {
158
- const e = n(), { error: t } = await e.from("product_attributes").update({
159
- name_translations: r.nameTranslations,
160
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
161
- }).eq("id", r.attributeId);
162
- if (t)
163
- return { success: !1, error: t.message };
164
- for (const o of r.termTranslations) {
165
- const { error: a } = await e.from("product_attribute_terms").update({
166
- value_translations: o.valueTranslations,
167
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
168
- }).eq("id", o.termId).eq("attribute_id", r.attributeId);
169
- if (a)
170
- return { success: !1, error: a.message };
171
- }
172
- return s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 };
173
- }
174
- async function V(r) {
175
- const e = n(), { error: t } = await e.from("product_attribute_terms").delete().eq("id", r);
176
- return t ? { success: !1, error: t.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
177
- }
178
- async function Y(r) {
179
- const e = n(), t = r.name.trim(), o = d(r.slug?.trim() || r.name);
180
- if (!t || !o)
181
- return { success: !1, error: "Category name is required." };
182
- const { data: a, error: c } = await e.from("categories").insert({
183
- name: t,
184
- slug: o,
185
- description: r.description?.trim() || null,
186
- name_translations: r.nameTranslations || {},
187
- description_translations: r.descriptionTranslations || {}
188
- }).select().single();
189
- return c ? { success: !1, error: c.message } : (s("/cms/products/categories"), s("/cms/products/new"), s("/cms/products"), { success: !0, category: a });
190
- }
191
- async function j(r, e) {
192
- const t = n(), o = e.name.trim(), a = d(e.slug?.trim() || e.name);
193
- if (!o || !a)
194
- return { success: !1, error: "Category name is required." };
195
- const { error: c } = await t.from("categories").update({
196
- name: o,
197
- slug: a,
198
- description: e.description?.trim() || null,
199
- name_translations: e.nameTranslations || {},
200
- description_translations: e.descriptionTranslations || {}
201
- }).eq("id", r);
202
- return c ? { success: !1, error: c.message } : (s("/cms/products/categories"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
203
- }
204
- async function H(r) {
205
- const e = n(), { error: t } = await e.from("categories").delete().eq("id", r);
206
- return t ? { success: !1, error: t.message } : (s("/cms/products/categories"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
207
- }
208
- async function J(r, e) {
209
- const t = n();
210
- try {
211
- return await A(t, r, e), s("/cms/products"), s(`/cms/products/${r}/edit`), { success: !0 };
212
- } catch (o) {
213
- return { success: !1, error: o.message };
214
- }
215
- }
216
- export {
217
- O as bulkDeleteProductsAction,
218
- z as bulkDraftProductsAction,
219
- Y as createCategoryAction,
220
- F as createProductAction,
221
- M as createProductAttributeAction,
222
- R as createProductAttributeTermAction,
223
- H as deleteCategoryAction,
224
- $ as deleteProductAction,
225
- B as deleteProductAttributeAction,
226
- V as deleteProductAttributeTermAction,
227
- U as publishProductAction,
228
- G as reorderProductAttributeTermsAction,
229
- J as syncProductCategoriesAction,
230
- j as updateCategoryAction,
231
- k as updateProductAction,
232
- L as updateProductAttributeTranslationsAction
233
- };
1
+ "use server";
2
+ import { normalizeCurrencyRecord as e } from "../../../currency.es.js";
3
+ import { createProduct as t, deleteProduct as n, syncCategoriesForTranslationGroup as r } from "../../../product-actions.es.js";
4
+ import { sanitizeProductFormValuesForStoreManagedCurrencies as i } from "./product-price-sync.es.js";
5
+ import { syncProductSaleCouponToFreemius as a } from "../../../freemius-coupons.es.js";
6
+ import { createClient as o, getServiceRoleSupabaseClient as s } from "@nextblock-cms/db/server";
7
+ import { redirect as c } from "next/navigation";
8
+ import { revalidatePath as l } from "next/cache";
9
+ //#region src/lib/pages/cms/products/server-actions.ts
10
+ function u(e) {
11
+ return e.toLowerCase().trim().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
12
+ }
13
+ async function d(n) {
14
+ let r = o(), { data: u } = await r.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active", !0).order("code", { ascending: !0 }), d = i(n, (u || []).map((t) => e(t))), f = await t(r, d);
15
+ if (d.payment_provider === "freemius" && f?.id) try {
16
+ await a({
17
+ productId: f.id,
18
+ client: s()
19
+ });
20
+ } catch (e) {
21
+ console.error("Failed to sync Freemius sale coupon on create:", e);
22
+ }
23
+ l("/cms/products"), c("/cms/products");
24
+ }
25
+ async function f(e, t, n, r) {
26
+ let i = {
27
+ author_id: n,
28
+ meta: r,
29
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
30
+ }, a = async () => {
31
+ let { error: n } = await e.from("product_drafts").update(i).eq("product_id", t);
32
+ if (n) throw Error(`Failed to save product draft: ${n.message}`);
33
+ }, { data: o, error: s } = await e.from("product_drafts").select("id").eq("product_id", t).maybeSingle();
34
+ if (s) throw Error(`Failed to read product draft: ${s.message}`);
35
+ if (o) {
36
+ await a();
37
+ return;
38
+ }
39
+ let { data: c, error: l } = await e.from("blocks").select("id, page_id, post_id, product_id, language_id, block_type, content, order, created_at, updated_at").eq("product_id", t).order("order", { ascending: !0 });
40
+ if (l) throw Error(`Failed to read product blocks: ${l.message}`);
41
+ let { error: u } = await e.from("product_drafts").insert({
42
+ ...i,
43
+ blocks: c ?? [],
44
+ product_id: t
45
+ });
46
+ if (u) {
47
+ if (u.code === "23505") {
48
+ await a();
49
+ return;
50
+ }
51
+ throw Error(`Failed to save product draft: ${u.message}`);
52
+ }
53
+ }
54
+ async function p(t, n) {
55
+ let r = o(), { data: { user: a } } = await r.auth.getUser();
56
+ if (!a) throw Error("User not authenticated.");
57
+ let { data: s } = await r.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active", !0).order("code", { ascending: !0 }), c = i(n, (s || []).map((t) => e(t)));
58
+ return await f(r, t, a.id, c), { success: !0 };
59
+ }
60
+ async function m(e) {
61
+ let t = o();
62
+ await n(t, e), l("/cms/products");
63
+ }
64
+ function h(e) {
65
+ return Array.from(new Set(e.map((e) => e.trim()).filter(Boolean)));
66
+ }
67
+ async function g(e) {
68
+ let t = h(e);
69
+ if (t.length === 0) return {
70
+ success: !1,
71
+ error: "Select at least one product."
72
+ };
73
+ let { error: n } = await o().from("products").delete().in("id", t);
74
+ return n ? {
75
+ success: !1,
76
+ error: n.message
77
+ } : (l("/cms/products"), {
78
+ success: !0,
79
+ count: t.length
80
+ });
81
+ }
82
+ async function _(e) {
83
+ let t = h(e);
84
+ if (t.length === 0) return {
85
+ success: !1,
86
+ error: "Select at least one product."
87
+ };
88
+ let { error: n } = await o().from("products").update({
89
+ status: "draft",
90
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
91
+ }).in("id", t);
92
+ return n ? {
93
+ success: !1,
94
+ error: n.message
95
+ } : (l("/cms/products"), {
96
+ success: !0,
97
+ count: t.length
98
+ });
99
+ }
100
+ async function v(e) {
101
+ let t = String(e || "").trim();
102
+ if (!t) return { error: "Missing product id." };
103
+ let n = o(), { data: { user: r } } = await n.auth.getUser();
104
+ if (!r) return { error: "You must be signed in to publish a product." };
105
+ let { data: i, error: a } = await n.from("products").update({
106
+ status: "active",
107
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
108
+ }).eq("id", t).select("slug").single();
109
+ return a || !i ? { error: a?.message || "Could not publish the product." } : (l("/cms/products"), l(`/cms/products/${t}/edit`), i.slug && l(`/product/${i.slug}`), {});
110
+ }
111
+ async function y(e) {
112
+ let t = s(), n = e.name.trim(), r = u(e.slug?.trim() || e.name);
113
+ if (!n || !r) return {
114
+ success: !1,
115
+ error: "Attribute name is required."
116
+ };
117
+ let { error: i } = await t.from("product_attributes").insert({
118
+ name: n,
119
+ slug: r
120
+ });
121
+ return i ? {
122
+ success: !1,
123
+ error: i.message
124
+ } : (l("/cms/products/attributes"), l("/cms/products/new"), l("/cms/products"), { success: !0 });
125
+ }
126
+ async function b(e) {
127
+ let { error: t } = await s().from("product_attributes").delete().eq("id", e);
128
+ return t ? {
129
+ success: !1,
130
+ error: t.message
131
+ } : (l("/cms/products/attributes"), l("/cms/products/new"), l("/cms/products"), { success: !0 });
132
+ }
133
+ async function x(e) {
134
+ let t = s(), n = e.value.trim(), r = u(e.slug?.trim() || e.value);
135
+ if (!n || !r) return {
136
+ success: !1,
137
+ error: "Term value is required."
138
+ };
139
+ let { data: i } = await t.from("product_attribute_terms").select("sort_order").eq("attribute_id", e.attributeId).order("sort_order", { ascending: !1 }).limit(1), a = typeof i?.[0]?.sort_order == "number" ? i[0].sort_order + 1 : 0, { error: o } = await t.from("product_attribute_terms").insert({
140
+ attribute_id: e.attributeId,
141
+ value: n,
142
+ slug: r,
143
+ sort_order: a
144
+ });
145
+ return o ? {
146
+ success: !1,
147
+ error: o.message
148
+ } : (l("/cms/products/attributes"), l("/cms/products/new"), l("/cms/products"), { success: !0 });
149
+ }
150
+ async function S(e) {
151
+ let t = s();
152
+ for (let [n, r] of e.orderedTermIds.entries()) {
153
+ let { error: i } = await t.from("product_attribute_terms").update({
154
+ sort_order: n,
155
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
156
+ }).eq("id", r).eq("attribute_id", e.attributeId);
157
+ if (i) return {
158
+ success: !1,
159
+ error: i.message
160
+ };
161
+ }
162
+ return l("/cms/products/attributes"), l("/cms/products/new"), l("/cms/products"), { success: !0 };
163
+ }
164
+ async function C(e) {
165
+ let t = s(), { error: n } = await t.from("product_attributes").update({
166
+ name_translations: e.nameTranslations,
167
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
168
+ }).eq("id", e.attributeId);
169
+ if (n) return {
170
+ success: !1,
171
+ error: n.message
172
+ };
173
+ for (let n of e.termTranslations) {
174
+ let { error: r } = await t.from("product_attribute_terms").update({
175
+ value_translations: n.valueTranslations,
176
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
177
+ }).eq("id", n.termId).eq("attribute_id", e.attributeId);
178
+ if (r) return {
179
+ success: !1,
180
+ error: r.message
181
+ };
182
+ }
183
+ return l("/cms/products/attributes"), l("/cms/products/new"), l("/cms/products"), { success: !0 };
184
+ }
185
+ async function w(e) {
186
+ let { error: t } = await s().from("product_attribute_terms").delete().eq("id", e);
187
+ return t ? {
188
+ success: !1,
189
+ error: t.message
190
+ } : (l("/cms/products/attributes"), l("/cms/products/new"), l("/cms/products"), { success: !0 });
191
+ }
192
+ async function T(e) {
193
+ let t = s(), n = e.name.trim(), r = u(e.slug?.trim() || e.name);
194
+ if (!n || !r) return {
195
+ success: !1,
196
+ error: "Category name is required."
197
+ };
198
+ let { data: i, error: a } = await t.from("categories").insert({
199
+ name: n,
200
+ slug: r,
201
+ description: e.description?.trim() || null,
202
+ name_translations: e.nameTranslations || {},
203
+ description_translations: e.descriptionTranslations || {}
204
+ }).select().single();
205
+ return a ? {
206
+ success: !1,
207
+ error: a.message
208
+ } : (l("/cms/products/categories"), l("/cms/products/new"), l("/cms/products"), {
209
+ success: !0,
210
+ category: i
211
+ });
212
+ }
213
+ async function E(e, t) {
214
+ let n = s(), r = t.name.trim(), i = u(t.slug?.trim() || t.name);
215
+ if (!r || !i) return {
216
+ success: !1,
217
+ error: "Category name is required."
218
+ };
219
+ let { error: a } = await n.from("categories").update({
220
+ name: r,
221
+ slug: i,
222
+ description: t.description?.trim() || null,
223
+ name_translations: t.nameTranslations || {},
224
+ description_translations: t.descriptionTranslations || {}
225
+ }).eq("id", e);
226
+ return a ? {
227
+ success: !1,
228
+ error: a.message
229
+ } : (l("/cms/products/categories"), l("/cms/products/new"), l("/cms/products"), { success: !0 });
230
+ }
231
+ async function D(e) {
232
+ let { error: t } = await s().from("categories").delete().eq("id", e);
233
+ return t ? {
234
+ success: !1,
235
+ error: t.message
236
+ } : (l("/cms/products/categories"), l("/cms/products/new"), l("/cms/products"), { success: !0 });
237
+ }
238
+ async function O(e, t) {
239
+ let n = s();
240
+ try {
241
+ return await r(n, e, t), l("/cms/products"), l(`/cms/products/${e}/edit`), { success: !0 };
242
+ } catch (e) {
243
+ return {
244
+ success: !1,
245
+ error: e.message
246
+ };
247
+ }
248
+ }
249
+ //#endregion
250
+ export { g as bulkDeleteProductsAction, _ as bulkDraftProductsAction, T as createCategoryAction, d as createProductAction, y as createProductAttributeAction, x as createProductAttributeTermAction, D as deleteCategoryAction, m as deleteProductAction, b as deleteProductAttributeAction, w as deleteProductAttributeTermAction, v as publishProductAction, S as reorderProductAttributeTermsAction, O as syncProductCategoriesAction, E as updateCategoryAction, p as updateProductAction, C as updateProductAttributeTranslationsAction };
@@ -0,0 +1,5 @@
1
+ const e=require("../../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../currency.cjs"),n=require("../../../states.cjs"),r=require("../../../inventory-settings.cjs"),i=require("./server-actions.cjs"),a=require("./components/ZoneForm.cjs"),o=require("./components/RateForm.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("lucide-react"),l=require("@nextblock-cms/utils"),u=require("react/jsx-runtime"),d=require("@nextblock-cms/db/server"),f=require("@nextblock-cms/ui");async function p({searchParams:e}){let s=(0,d.getServiceRoleSupabaseClient)(),[{data:p},m,{data:h},{data:g}]=await Promise.all([s.from(`shipping_zones`).select(`
2
+ *,
3
+ shipping_zone_locations (*),
4
+ shipping_zone_methods (*)
5
+ `).order(`priority_order`,{ascending:!0}),r.getEcommerceInventorySettings(s),s.from(`languages`).select(`code, name, is_default`).eq(`is_active`,!0).order(`name`,{ascending:!0}),s.from(`currencies`).select(`code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount`).eq(`is_active`,!0).order(`is_default`,{ascending:!1}).order(`code`,{ascending:!0})]),_=g?.find(e=>e.is_default)?.code||g?.[0]?.code||`USD`,v=(g||[]).map(e=>t.normalizeCurrencyRecord(e));return(0,u.jsx)(f.TooltipProvider,{children:(0,u.jsxs)(`div`,{className:`space-y-6`,children:[e?.success?(0,u.jsx)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-700`,children:e.success}):null,(0,u.jsx)(f.Card,{className:`overflow-hidden border-slate-200 dark:border-slate-800 shadow-sm`,children:(0,u.jsx)(f.CardContent,{className:`p-4 sm:p-5`,children:(0,u.jsxs)(`form`,{action:i.updateInventoryTrackingAction,className:`space-y-3`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,u.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,u.jsx)(`div`,{className:`p-2 bg-primary/10 rounded-lg text-primary shadow-inner shrink-0`,children:(0,u.jsx)(c.Boxes,{className:`h-4 w-4`})}),(0,u.jsxs)(`div`,{className:`min-w-0`,children:[(0,u.jsx)(f.CardTitle,{className:`text-base font-semibold leading-none`,children:`Inventory Tracking`}),(0,u.jsx)(f.CardDescription,{className:`mt-1 text-sm`,children:`Control whether checkout enforces stock counts and paid orders deduct inventory.`})]})]}),(0,u.jsx)(`div`,{className:`flex justify-end lg:justify-start shrink-0`,children:(0,u.jsx)(f.Button,{type:`submit`,size:`sm`,className:`w-full sm:w-auto`,children:`Save Inventory Settings`})})]}),(0,u.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 px-4 py-3`,children:[(0,u.jsx)(`input`,{type:`hidden`,name:`trackQuantities`,value:`false`}),(0,u.jsxs)(`label`,{htmlFor:`track-quantities`,className:`flex cursor-pointer items-start gap-3`,children:[(0,u.jsx)(`input`,{id:`track-quantities`,name:`trackQuantities`,type:`checkbox`,value:`true`,defaultChecked:m.trackQuantities,className:`mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary`}),(0,u.jsxs)(`span`,{className:`space-y-0.5`,children:[(0,u.jsx)(`span`,{className:`block text-sm font-medium text-slate-900 dark:text-slate-100`,children:`Track product quantities`}),(0,u.jsx)(`span`,{className:`block text-sm text-muted-foreground`,children:`Prevent overselling by checking stock during checkout and decrementing quantities after payment is confirmed.`})]})]})]})]})})}),(0,u.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-100`,children:`Shipping Zones`}),(0,u.jsx)(`p`,{className:`text-slate-500 dark:text-slate-400 text-sm`,children:`Manage geographical delivery areas and their associated shipping rates.`})]}),(0,u.jsx)(a.ZoneForm,{})]}),(0,u.jsx)(`div`,{className:`grid gap-6`,children:!p||p.length===0?(0,u.jsx)(f.Card,{className:`bg-slate-50/50 dark:bg-slate-900/10 border-dashed`,children:(0,u.jsxs)(f.CardContent,{className:`flex flex-col items-center justify-center py-12`,children:[(0,u.jsx)(c.Truck,{className:`h-12 w-12 text-slate-300 dark:text-slate-700 mb-4`}),(0,u.jsx)(`p`,{className:`text-slate-600 dark:text-slate-400 font-medium`,children:`No shipping zones defined yet.`}),(0,u.jsx)(`p`,{className:`text-xs text-slate-500 mb-6 text-center max-w-xs`,children:`Create a zone to start defining shipping rates for specific regions (e.g., North America, Europe).`})]})}):p.map(e=>(0,u.jsxs)(f.Card,{className:`overflow-hidden border-slate-200 dark:border-slate-800 shadow-sm hover:shadow-md transition-shadow`,children:[(0,u.jsx)(f.CardHeader,{className:`bg-slate-50/50 dark:bg-slate-900/50 border-b dark:border-slate-800 py-4`,children:(0,u.jsxs)(`div`,{className:`flex justify-between items-start md:items-center`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,u.jsx)(`div`,{className:`p-2 bg-primary/10 rounded-lg text-primary shadow-inner`,children:(0,u.jsx)(c.Globe,{className:`h-5 w-5`})}),(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(f.CardTitle,{className:`text-lg font-bold`,children:e.name}),(0,u.jsxs)(f.Badge,{variant:`outline`,className:`text-[10px] uppercase font-bold py-0 h-4 border-slate-200 bg-white/50 dark:bg-black/20`,children:[`Prio: `,e.priority_order]})]}),(0,u.jsxs)(f.CardDescription,{className:`text-xs`,children:[e.shipping_zone_locations?.length||0,` regions covered`]})]})]}),(0,u.jsxs)(`div`,{className:`flex gap-1`,children:[(0,u.jsx)(a.ZoneForm,{mode:`edit`,initialData:{id:e.id,name:e.name,priority_order:e.priority_order,locations:e.shipping_zone_locations?.map(e=>({country_code:e.country_code,state_code:e.state_code}))||[]}}),(0,u.jsx)(`form`,{action:async()=>{"use server";await i.deleteShippingZone(e.id)},children:(0,u.jsx)(f.Button,{type:`submit`,variant:`ghost`,size:`icon`,className:`h-8 w-8 text-slate-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,u.jsx)(c.Trash2,{className:`h-4 w-4`})})})]})]})}),(0,u.jsx)(f.CardContent,{className:`p-0`,children:(0,u.jsxs)(`div`,{className:`grid md:grid-cols-2 divide-y md:divide-y-0 md:divide-x divide-slate-100 dark:divide-slate-800`,children:[(0,u.jsxs)(`div`,{className:`p-6`,children:[(0,u.jsxs)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest text-slate-500 mb-4 flex items-center gap-1.5`,children:[(0,u.jsx)(c.Globe,{className:`h-3 w-3`}),` Target Regions`]}),(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.shipping_zone_locations?.length>0?e.shipping_zone_locations.map(e=>(0,u.jsxs)(f.Badge,{variant:`secondary`,className:`bg-slate-100 dark:bg-slate-800/80 text-slate-700 dark:text-slate-300 hover:bg-slate-200 border-none px-2 py-0.5 text-[11px] font-medium`,children:[e.country_code,e.state_code?(0,u.jsxs)(`span`,{className:`text-slate-400 ml-1`,children:[`(`,n.resolveSubdivisionName(e.country_code,e.state_code),`)`]}):``]},e.id)):(0,u.jsx)(`p`,{className:`text-sm text-slate-400 italic`,children:`No specific locations assigned.`})})]}),(0,u.jsxs)(`div`,{className:`p-6`,children:[(0,u.jsxs)(`div`,{className:`flex justify-between items-center mb-4`,children:[(0,u.jsxs)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest text-slate-500 flex items-center gap-1.5`,children:[(0,u.jsx)(c.Truck,{className:`h-3 w-3`}),` Shipping Methods`]}),(0,u.jsx)(o.RateForm,{zoneId:e.id,zoneName:e.name,languages:h||[],currencies:v,defaultCurrencyCode:_})]}),(0,u.jsx)(`div`,{className:`space-y-2`,children:e.shipping_zone_methods?.length>0?e.shipping_zone_methods.map(t=>(0,u.jsxs)(`div`,{className:`flex justify-between items-center group p-2 hover:bg-slate-50/80 dark:hover:bg-slate-800/30 rounded-lg transition-all border border-transparent hover:border-slate-100 dark:hover:border-slate-800`,children:[(0,u.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(`p`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100 truncate`,children:t.name}),(0,u.jsx)(f.Badge,{variant:`outline`,className:`h-4 px-1 text-[9px]`,children:t.currency_pricing_mode===`manual`?`Manual FX`:`Auto FX`}),(t.min_order_amount||0)>0&&(0,u.jsxs)(f.Tooltip,{children:[(0,u.jsx)(f.TooltipTrigger,{asChild:!0,children:(0,u.jsxs)(f.Badge,{variant:`outline`,className:`h-4 px-1 text-[9px] bg-emerald-50 text-emerald-700 dark:bg-emerald-900/20 dark:text-emerald-400 border-emerald-100 dark:border-emerald-900/50`,children:[(0,u.jsx)(c.Info,{className:`h-2 w-2 mr-0.5`}),(0,l.formatPrice)(t.min_order_amount,t.cost_currency?.toUpperCase()||_)]})}),(0,u.jsxs)(f.TooltipContent,{children:[`Available for orders over `,(0,l.formatPrice)(t.min_order_amount,t.cost_currency?.toUpperCase()||_)]})]})]}),(0,u.jsx)(`p`,{className:`text-[10px] text-slate-500 uppercase tracking-tighter mix-blend-multiply dark:mix-blend-normal`,children:t.method_type.replace(`_`,` `)})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,u.jsx)(`p`,{className:`text-sm font-black text-primary px-2`,children:t.method_type===`free_shipping`?`FREE`:(0,l.formatPrice)(t.cost_amount,t.cost_currency?.toUpperCase()||_)}),(0,u.jsxs)(`div`,{className:`flex opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,u.jsx)(o.RateForm,{zoneId:e.id,zoneName:e.name,languages:h||[],currencies:v,defaultCurrencyCode:_,mode:`edit`,initialData:t}),(0,u.jsx)(`form`,{action:async()=>{"use server";await i.deleteShippingRate(t.id)},children:(0,u.jsx)(f.Button,{type:`submit`,variant:`ghost`,size:`icon`,className:`h-7 w-7 text-slate-400 hover:text-red-500`,children:(0,u.jsx)(c.Trash2,{className:`h-3 w-3`})})})]})]})]},t.id)):(0,u.jsx)(`p`,{className:`text-xs text-slate-400 italic`,children:`No methods defined for this zone.`})})]})]})})]},e.id))})]})})}exports.ShippingPage=p;