@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,156 +1,139 @@
1
- import { jsxs as s, jsx as o } from "react/jsx-runtime";
2
- import { ProductForm as B } from "../../components/ProductForm.es.js";
3
- import { getProduct as E, getFreemiusPricingByProductId as F, getGlobalProductAttributes as S } from "../../actions.es.js";
4
- import { FreemiusPricingDashboard as C } from "../../components/FreemiusPricingDashboard.es.js";
5
- import { DeleteProductButton as O } from "../../components/DeleteProductButton.es.js";
6
- import { notFound as q } from "next/navigation";
7
- import { ArrowLeft as I, ExternalLink as L } from "lucide-react";
8
- import m from "next/link";
9
- import { Button as _ } from "@nextblock-cms/ui";
10
- import { mapRawVariantRelations as z } from "../../../../../variation-utils.es.js";
11
- import { deleteProductAction as T, updateProductAction as V } from "../../server-actions.es.js";
12
- import { getEnabledPaymentProviders as G, getStoreConfigStatus as M } from "../../../payments/queries.es.js";
13
- import { getServiceRoleSupabaseClient as U } from "@nextblock-cms/db/server";
14
- import { minorUnitAmountToMajor as d } from "@nextblock-cms/utils";
15
- import { normalizeCurrencyRecord as $ } from "../../../../../currency.es.js";
16
- async function de({
17
- params: f,
18
- mediaPickerNode: g,
19
- availableLanguagesProp: n,
20
- languageSwitcherNode: b,
21
- copyContentNode: h,
22
- translationCtaNode: x
23
- }) {
24
- const { id: P } = await f, e = await E(P);
25
- e || q();
26
- const c = e.product_type === "digital" || e.payment_provider === "freemius", [v, y, l, w, A] = await Promise.all([
27
- G(),
28
- M(),
29
- c && e.freemius_product_id ? F(e.id) : Promise.resolve(null),
30
- S(),
31
- U().from("currencies").select(
32
- "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"
33
- ).eq("is_active", !0).order("code", { ascending: !0 }).then((t) => t.data || [])
34
- ]), N = (A || []).map(
35
- (t) => $(t)
36
- ), j = n.find((t) => t.id === e.language_id)?.code, { attributes: k, variants: D } = z(
37
- e.product_variants || [],
38
- j
39
- ), R = (w || []).map((t) => ({
40
- id: t.id,
41
- name: t.name,
42
- name_translations: t.name_translations || {},
43
- slug: t.slug,
44
- terms: (t.product_attribute_terms || []).map((r) => ({
45
- ...r,
46
- value_translations: r.value_translations || {}
47
- }))
48
- })), u = O, p = C;
49
- return /* @__PURE__ */ s("div", { className: "space-y-8 w-full max-w-[1400px] mx-auto px-6 py-8", children: [
50
- /* @__PURE__ */ s("div", { className: "flex justify-between items-center flex-wrap gap-4 w-full", children: [
51
- /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
52
- /* @__PURE__ */ o(
53
- _,
54
- {
55
- variant: "outline",
56
- size: "icon",
57
- "aria-label": "Back to products",
58
- asChild: !0,
59
- children: /* @__PURE__ */ o(m, { href: "/cms/products", children: /* @__PURE__ */ o(I, { className: "h-4 w-4" }) })
60
- }
61
- ),
62
- /* @__PURE__ */ s("div", { children: [
63
- /* @__PURE__ */ o("h1", { className: "text-2xl font-bold", children: "Edit Product" }),
64
- /* @__PURE__ */ o("p", { className: "text-sm text-muted-foreground truncate max-w-md", title: e.title, children: e.title })
65
- ] })
66
- ] }),
67
- /* @__PURE__ */ s("div", { className: "flex items-center gap-3 flex-wrap", children: [
68
- b,
69
- h,
70
- x,
71
- u ? /* @__PURE__ */ o(
72
- u,
73
- {
74
- productName: e.title,
75
- redirectTo: "/cms/products",
76
- className: "border-red-200 hover:bg-red-50 hover:text-red-700",
77
- deleteAction: T.bind(null, e.id)
78
- }
79
- ) : null,
80
- e.slug && e.status === "active" && /* @__PURE__ */ o(_, { variant: "outline", asChild: !0, children: /* @__PURE__ */ s(m, { href: `/product/${e.slug}`, target: "_blank", children: [
81
- /* @__PURE__ */ o(L, { className: "w-4 h-4 mr-2" }),
82
- "View"
83
- ] }) })
84
- ] })
85
- ] }),
86
- /* @__PURE__ */ o(
87
- B,
88
- {
89
- initialData: {
90
- id: e.id,
91
- title: e.title,
92
- slug: e.slug,
93
- sku: e.sku,
94
- upc: e.upc ?? void 0,
95
- stock: e.stock || 0,
96
- price: e.price || 0,
97
- prices: Object.entries(e.prices || {}).reduce(
98
- (t, [r, i]) => (t[r] = d(i, r), t),
99
- {}
100
- ),
101
- is_taxable: typeof e.is_taxable == "boolean" ? e.is_taxable : !0,
102
- product_type: e.product_type,
103
- payment_provider: e.payment_provider,
104
- status: e.status,
105
- short_description: e.short_description ?? void 0,
106
- description_json: e.description_json,
107
- sale_price: typeof e.sale_price == "number" ? e.sale_price : void 0,
108
- sale_prices: Object.entries(e.sale_prices || {}).reduce((t, [r, i]) => (t[r] = typeof i == "number" ? d(i, r) : null, t), {}),
109
- freemius_plan_id: e.freemius_plan_id ?? void 0,
110
- freemius_product_id: e.freemius_product_id ?? void 0,
111
- trial_period_days: e.trial_period_days ?? 0,
112
- trial_requires_payment_method: e.trial_requires_payment_method ?? !1,
113
- language_id: e.language_id,
114
- translation_group_id: e.translation_group_id,
115
- product_media: e.product_media,
116
- variation_attributes: k.map((t) => ({
117
- attribute_id: t.id,
118
- term_ids: t.terms.map((r) => r.id)
119
- })),
120
- variants: D.map((t) => ({
121
- ...t,
122
- upc: t.upc ?? null,
123
- price: t.price / 100,
124
- prices: Object.entries(t.prices || {}).reduce(
125
- (r, [i, a]) => (r[i] = d(a, i), r),
126
- {}
127
- ),
128
- sale_price: typeof t.sale_price == "number" ? t.sale_price / 100 : null,
129
- sale_prices: Object.entries(t.sale_prices || {}).reduce((r, [i, a]) => (r[i] = typeof a == "number" ? d(a, i) : null, r), {}),
130
- main_media_id: t.main_media_id ?? null,
131
- main_image_url: t.image_url ?? null
132
- }))
133
- },
134
- isEdit: !0,
135
- mediaPickerNode: g,
136
- availableLanguagesProp: n,
137
- globalAttributesProp: R,
138
- currenciesProp: N,
139
- enabledProviders: v,
140
- configStatus: y,
141
- updateAction: V.bind(null, e.id),
142
- freemiusDashboardNode: c && e.freemius_product_id && l && p ? /* @__PURE__ */ o(
143
- p,
144
- {
145
- productId: e.id,
146
- freemiusProductId: e.freemius_product_id,
147
- plans: l
148
- }
149
- ) : void 0
150
- }
151
- )
152
- ] });
1
+ import { normalizeCurrencyRecord as e } from "../../../../../currency.es.js";
2
+ import { mapRawVariantRelations as t } from "../../../../../variation-utils.es.js";
3
+ import { getFreemiusPricingByProductId as n, getGlobalProductAttributes as r, getProduct as i } from "../../actions.es.js";
4
+ import { deleteProductAction as a, updateProductAction as o } from "../../server-actions.es.js";
5
+ import { ProductForm as s } from "../../components/ProductForm.es.js";
6
+ import { getEnabledPaymentProviders as c, getStoreConfigStatus as l } from "../../../payments/queries.es.js";
7
+ import { DeleteProductButton as u } from "../../components/DeleteProductButton.es.js";
8
+ import { FreemiusPricingDashboard as d } from "../../components/FreemiusPricingDashboard.es.js";
9
+ import f from "next/link";
10
+ import { ArrowLeft as p, ExternalLink as m } from "lucide-react";
11
+ import { minorUnitAmountToMajor as h } from "@nextblock-cms/utils";
12
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
13
+ import { getServiceRoleSupabaseClient as v } from "@nextblock-cms/db/server";
14
+ import { notFound as y } from "next/navigation";
15
+ import { Button as b } from "@nextblock-cms/ui";
16
+ //#region libs/ecommerce/src/lib/pages/cms/products/[id]/edit/EditProductPage.tsx
17
+ async function x({ params: x, mediaPickerNode: S, availableLanguagesProp: C, languageSwitcherNode: w, copyContentNode: T, translationCtaNode: E }) {
18
+ let { id: D } = await x, O = await i(D);
19
+ O || y();
20
+ let k = O.product_type === "digital" || O.payment_provider === "freemius", [A, j, M, N, P] = await Promise.all([
21
+ c(),
22
+ l(),
23
+ k && O.freemius_product_id ? n(O.id) : Promise.resolve(null),
24
+ r(),
25
+ v().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 }).then((e) => e.data || [])
26
+ ]), F = (P || []).map((t) => e(t)), I = C.find((e) => e.id === O.language_id)?.code, { attributes: L, variants: R } = t(O.product_variants || [], I), z = (N || []).map((e) => ({
27
+ id: e.id,
28
+ name: e.name,
29
+ name_translations: e.name_translations || {},
30
+ slug: e.slug,
31
+ terms: (e.product_attribute_terms || []).map((e) => ({
32
+ ...e,
33
+ value_translations: e.value_translations || {}
34
+ }))
35
+ })), B = u, V = d;
36
+ return /* @__PURE__ */ _("div", {
37
+ className: "space-y-8 w-full max-w-[1400px] mx-auto px-6 py-8",
38
+ children: [/* @__PURE__ */ _("div", {
39
+ className: "flex justify-between items-center flex-wrap gap-4 w-full",
40
+ children: [/* @__PURE__ */ _("div", {
41
+ className: "flex items-center gap-3",
42
+ children: [/* @__PURE__ */ g(b, {
43
+ variant: "outline",
44
+ size: "icon",
45
+ "aria-label": "Back to products",
46
+ asChild: !0,
47
+ children: /* @__PURE__ */ g(f, {
48
+ href: "/cms/products",
49
+ children: /* @__PURE__ */ g(p, { className: "h-4 w-4" })
50
+ })
51
+ }), /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("h1", {
52
+ className: "text-2xl font-bold",
53
+ children: "Edit Product"
54
+ }), /* @__PURE__ */ g("p", {
55
+ className: "text-sm text-muted-foreground truncate max-w-md",
56
+ title: O.title,
57
+ children: O.title
58
+ })] })]
59
+ }), /* @__PURE__ */ _("div", {
60
+ className: "flex items-center gap-3 flex-wrap",
61
+ children: [
62
+ w,
63
+ T,
64
+ E,
65
+ B ? /* @__PURE__ */ g(B, {
66
+ productName: O.title,
67
+ redirectTo: "/cms/products",
68
+ className: "border-red-200 hover:bg-red-50 hover:text-red-700",
69
+ deleteAction: a.bind(null, O.id)
70
+ }) : null,
71
+ O.slug && O.status === "active" && /* @__PURE__ */ g(b, {
72
+ variant: "outline",
73
+ asChild: !0,
74
+ children: /* @__PURE__ */ _(f, {
75
+ href: `/product/${O.slug}`,
76
+ target: "_blank",
77
+ children: [/* @__PURE__ */ g(m, { className: "w-4 h-4 mr-2" }), "View"]
78
+ })
79
+ })
80
+ ]
81
+ })]
82
+ }), /* @__PURE__ */ g(s, {
83
+ initialData: {
84
+ id: O.id,
85
+ title: O.title,
86
+ slug: O.slug,
87
+ sku: O.sku,
88
+ upc: O.upc ?? void 0,
89
+ stock: O.stock || 0,
90
+ price: O.price || 0,
91
+ prices: Object.entries(O.prices || {}).reduce((e, [t, n]) => (e[t] = h(n, t), e), {}),
92
+ is_taxable: typeof O.is_taxable != "boolean" || O.is_taxable,
93
+ product_type: O.product_type,
94
+ payment_provider: O.payment_provider,
95
+ status: O.status,
96
+ short_description: O.short_description ?? void 0,
97
+ description_json: O.description_json,
98
+ sale_price: typeof O.sale_price == "number" ? O.sale_price : void 0,
99
+ sale_prices: Object.entries(O.sale_prices || {}).reduce((e, [t, n]) => (e[t] = typeof n == "number" ? h(n, t) : null, e), {}),
100
+ freemius_plan_id: O.freemius_plan_id ?? void 0,
101
+ freemius_product_id: O.freemius_product_id ?? void 0,
102
+ trial_period_days: O.trial_period_days ?? 0,
103
+ trial_requires_payment_method: O.trial_requires_payment_method ?? !1,
104
+ language_id: O.language_id,
105
+ translation_group_id: O.translation_group_id,
106
+ product_media: O.product_media,
107
+ variation_attributes: L.map((e) => ({
108
+ attribute_id: e.id,
109
+ term_ids: e.terms.map((e) => e.id)
110
+ })),
111
+ variants: R.map((e) => ({
112
+ ...e,
113
+ upc: e.upc ?? null,
114
+ price: e.price / 100,
115
+ prices: Object.entries(e.prices || {}).reduce((e, [t, n]) => (e[t] = h(n, t), e), {}),
116
+ sale_price: typeof e.sale_price == "number" ? e.sale_price / 100 : null,
117
+ sale_prices: Object.entries(e.sale_prices || {}).reduce((e, [t, n]) => (e[t] = typeof n == "number" ? h(n, t) : null, e), {}),
118
+ main_media_id: e.main_media_id ?? null,
119
+ main_image_url: e.image_url ?? null
120
+ }))
121
+ },
122
+ isEdit: !0,
123
+ mediaPickerNode: S,
124
+ availableLanguagesProp: C,
125
+ globalAttributesProp: z,
126
+ currenciesProp: F,
127
+ enabledProviders: A,
128
+ configStatus: j,
129
+ updateAction: o.bind(null, O.id),
130
+ freemiusDashboardNode: k && O.freemius_product_id && M && V ? /* @__PURE__ */ g(V, {
131
+ productId: O.id,
132
+ freemiusProductId: O.freemius_product_id,
133
+ plans: M
134
+ }) : void 0
135
+ })]
136
+ });
153
137
  }
154
- export {
155
- de as EditProductPage
156
- };
138
+ //#endregion
139
+ export { x as EditProductPage };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@nextblock-cms/db/server"),d=require("../../../product-actions.cjs.js"),l=require("../../../providers/freemius.cjs.js"),c=require("next/cache");async function _(t){const r=o.createClient(),{data:a,count:e,error:i}=await await d.getProducts(r,{...t,status:"all"});if(i)throw new Error(i.message);return{data:a,count:e}}async function m(t){const r=o.createClient(),{data:a,error:e}=await d.getProduct(r,t);if(e)throw new Error(e.message);return a}async function p(){try{const t=await l.syncFreemiusProductsToSupabase();return c.revalidatePath("/cms/products","page"),{success:!0,data:t}}catch(t){return{error:t.message||"Failed to sync with Freemius"}}}async function g(t){try{const r=await l.syncSingleFreemiusProduct(t);return c.revalidatePath("/cms/products","page"),c.revalidatePath("/cms/products/[id]/edit","page"),{success:!0,data:r}}catch(r){return{error:r.message||"Failed to sync product with Freemius"}}}async function f(t,r){try{const a=o.createClient();return await d.copyProductFromLanguage(a,t,r),c.revalidatePath("/cms/products"),c.revalidatePath(`/cms/products/${t}/edit`),{success:!0}}catch(a){return{success:!1,error:a.message||"Failed to copy product content"}}}async function y(t){const r=o.createClient(),{data:a,error:e}=await r.from("products").select("id, title, language_id, slug").eq("translation_group_id",t);if(e)throw new Error(e.message);return a}async function w(){const t=o.getServiceRoleSupabaseClient(),{data:r,error:a}=await t.from("product_attributes").select(`
1
+ "use server";const e=require("../../../product-actions.cjs.js"),t=require("../../../providers/freemius.cjs.js");let n=require("@nextblock-cms/db/server"),r=require("next/cache");async function i(t){let r=(0,n.createClient)(),{data:i,count:a,error:o}=await await e.getProducts(r,{...t,status:`all`});if(o)throw Error(o.message);return{data:i,count:a}}async function a(t){let r=(0,n.createClient)(),{data:i,error:a}=await e.getProduct(r,t);if(a)throw Error(a.message);return i}async function o(){try{let e=await t.syncFreemiusProductsToSupabase();return(0,r.revalidatePath)(`/cms/products`,`page`),{success:!0,data:e}}catch(e){return{error:e.message||`Failed to sync with Freemius`}}}async function s(e){try{let n=await t.syncSingleFreemiusProduct(e);return(0,r.revalidatePath)(`/cms/products`,`page`),(0,r.revalidatePath)(`/cms/products/[id]/edit`,`page`),{success:!0,data:n}}catch(e){return{error:e.message||`Failed to sync product with Freemius`}}}async function c(t,i){try{let a=(0,n.createClient)();return await e.copyProductFromLanguage(a,t,i),(0,r.revalidatePath)(`/cms/products`),(0,r.revalidatePath)(`/cms/products/${t}/edit`),{success:!0}}catch(e){return{success:!1,error:e.message||`Failed to copy product content`}}}async function l(e){let{data:t,error:r}=await(0,n.createClient)().from(`products`).select(`id, title, language_id, slug`).eq(`translation_group_id`,e);if(r)throw Error(r.message);return t}async function u(){let{data:e,error:t}=await(0,n.getServiceRoleSupabaseClient)().from(`product_attributes`).select(`
2
2
  id,
3
3
  name,
4
4
  name_translations,
@@ -11,7 +11,7 @@
11
11
  sort_order,
12
12
  value_translations
13
13
  )
14
- `);if(a)throw new Error(a.message);return(r||[]).map(e=>({...e,product_attribute_terms:(e.product_attribute_terms||[]).sort((i,u)=>(i.sort_order??Number.MAX_SAFE_INTEGER)-(u.sort_order??Number.MAX_SAFE_INTEGER)||i.value.localeCompare(u.value))})).sort((e,i)=>e.name.localeCompare(i.name))}async function P(t){const r=o.createClient(),{data:a,error:e}=await r.from("freemius_plans").select(`
14
+ `);if(t)throw Error(t.message);return(e||[]).map(e=>({...e,product_attribute_terms:(e.product_attribute_terms||[]).sort((e,t)=>(e.sort_order??2**53-1)-(t.sort_order??2**53-1)||e.value.localeCompare(t.value))})).sort((e,t)=>e.name.localeCompare(t.name))}async function d(e){let{data:t,error:r}=await(0,n.createClient)().from(`freemius_plans`).select(`
15
15
  id,
16
16
  name,
17
17
  title,
@@ -26,7 +26,7 @@
26
26
  override_lifetime_price,
27
27
  is_active
28
28
  )
29
- `).eq("product_id",t);if(e)throw new Error(e.message);return a}async function h(t,r){const a=o.createClient(),{error:e}=await a.from("freemius_pricing").update({...r,updated_at:new Date().toISOString()}).eq("id",t);return e?{success:!1,error:e.message}:(c.revalidatePath("/cms/products"),{success:!0})}async function v(t){const r=o.createClient(),{data:a}=await r.from("products").select("translation_group_id").eq("id",t).maybeSingle();let e=[t];if(a?.translation_group_id){const{data:n}=await r.from("products").select("id").eq("translation_group_id",a.translation_group_id);n&&n.length>0&&(e=n.map(s=>s.id))}const{data:i,error:u}=await r.from("freemius_plans").select(`
29
+ `).eq(`product_id`,e);if(r)throw Error(r.message);return t}async function f(e,t){let{error:i}=await(0,n.createClient)().from(`freemius_pricing`).update({...t,updated_at:new Date().toISOString()}).eq(`id`,e);return i?{success:!1,error:i.message}:((0,r.revalidatePath)(`/cms/products`),{success:!0})}async function p(e){let t=(0,n.createClient)(),{data:r}=await t.from(`products`).select(`translation_group_id`).eq(`id`,e).maybeSingle(),i=[e];if(r?.translation_group_id){let{data:e}=await t.from(`products`).select(`id`).eq(`translation_group_id`,r.translation_group_id);e&&e.length>0&&(i=e.map(e=>e.id))}let{data:a,error:o}=await t.from(`freemius_plans`).select(`
30
30
  id,
31
31
  name,
32
32
  title,
@@ -41,4 +41,4 @@
41
41
  override_lifetime_price,
42
42
  is_active
43
43
  )
44
- `).in("product_id",e);if(u)throw new Error(u.message);return(i||[]).map(n=>({id:n.id,name:n.name,title:n.title,pricing:(n.freemius_pricing||[]).filter(s=>s.is_active!==!1).map(s=>({id:s.id,license_quota:s.license_quota,monthly_price:s.override_monthly_price??s.api_monthly_price,annual_price:s.override_annual_price??s.api_annual_price,lifetime_price:s.override_lifetime_price??s.api_lifetime_price,is_active:s.is_active}))}))}async function b(){const t=o.createClient(),{data:r,error:a}=await t.from("categories").select("id, name, slug, description, created_at, name_translations, description_translations, product_categories(count)").order("name",{ascending:!0});if(a)throw new Error(a.message);return(r||[]).map(e=>{const i=e.product_categories?.[0]?.count??e.product_categories?.count??0;return{id:e.id,name:e.name,slug:e.slug,description:e.description??"",created_at:e.created_at,productCount:Number(i),name_translations:e.name_translations||{},description_translations:e.description_translations||{}}})}async function C(t){const r=o.createClient(),{data:a,error:e}=await r.from("categories").select("id, name, slug, description, created_at").eq("slug",t).maybeSingle();if(e)throw new Error(e.message);return a}async function F(t){const r=o.createClient(),{data:a,error:e}=await r.from("product_categories").select("category:categories(id, name, slug, description, name_translations, description_translations, created_at)").eq("product_id",t);if(e)throw new Error(e.message);return(a||[]).map(i=>i.category).filter(Boolean)}exports.copyProductFromLanguageAction=f;exports.getCategoriesWithCount=b;exports.getCategoryBySlug=C;exports.getFreemiusPricingByProductId=P;exports.getGlobalProductAttributes=w;exports.getProduct=m;exports.getProductCategories=F;exports.getProductTranslations=y;exports.getProducts=_;exports.getPublicFreemiusPricing=v;exports.triggerFreemiusSync=p;exports.triggerSingleProductSync=g;exports.updateFreemiusOverride=h;
44
+ `).in(`product_id`,i);if(o)throw Error(o.message);return(a||[]).map(e=>({id:e.id,name:e.name,title:e.title,pricing:(e.freemius_pricing||[]).filter(e=>e.is_active!==!1).map(e=>({id:e.id,license_quota:e.license_quota,monthly_price:e.override_monthly_price??e.api_monthly_price,annual_price:e.override_annual_price??e.api_annual_price,lifetime_price:e.override_lifetime_price??e.api_lifetime_price,is_active:e.is_active}))}))}async function m(){let{data:e,error:t}=await(0,n.createClient)().from(`categories`).select(`id, name, slug, description, created_at, name_translations, description_translations, product_categories(count)`).order(`name`,{ascending:!0});if(t)throw Error(t.message);return(e||[]).map(e=>{let t=e.product_categories?.[0]?.count??e.product_categories?.count??0;return{id:e.id,name:e.name,slug:e.slug,description:e.description??``,created_at:e.created_at,productCount:Number(t),name_translations:e.name_translations||{},description_translations:e.description_translations||{}}})}async function h(e){let{data:t,error:r}=await(0,n.createClient)().from(`categories`).select(`id, name, slug, description, created_at`).eq(`slug`,e).maybeSingle();if(r)throw Error(r.message);return t}async function g(e){let{data:t,error:r}=await(0,n.createClient)().from(`product_categories`).select(`category:categories(id, name, slug, description, name_translations, description_translations, created_at)`).eq(`product_id`,e);if(r)throw Error(r.message);return(t||[]).map(e=>e.category).filter(Boolean)}exports.copyProductFromLanguageAction=c,exports.getCategoriesWithCount=m,exports.getCategoryBySlug=h,exports.getFreemiusPricingByProductId=d,exports.getGlobalProductAttributes=u,exports.getProduct=a,exports.getProductCategories=g,exports.getProductTranslations=l,exports.getProducts=i,exports.getPublicFreemiusPricing=p,exports.triggerFreemiusSync=o,exports.triggerSingleProductSync=s,exports.updateFreemiusOverride=f;