@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
@@ -0,0 +1,44 @@
1
+ "use server";const e=require("../../../product-actions.cjs"),t=require("../../../providers/freemius.cjs");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
+ id,
3
+ name,
4
+ name_translations,
5
+ slug,
6
+ product_attribute_terms (
7
+ id,
8
+ attribute_id,
9
+ value,
10
+ slug,
11
+ sort_order,
12
+ value_translations
13
+ )
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
+ id,
16
+ name,
17
+ title,
18
+ freemius_pricing (
19
+ id,
20
+ license_quota,
21
+ api_monthly_price,
22
+ api_annual_price,
23
+ api_lifetime_price,
24
+ override_monthly_price,
25
+ override_annual_price,
26
+ override_lifetime_price,
27
+ is_active
28
+ )
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
+ id,
31
+ name,
32
+ title,
33
+ freemius_pricing (
34
+ id,
35
+ license_quota,
36
+ api_monthly_price,
37
+ api_annual_price,
38
+ api_lifetime_price,
39
+ override_monthly_price,
40
+ override_annual_price,
41
+ override_lifetime_price,
42
+ is_active
43
+ )
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;
@@ -1,175 +1,134 @@
1
- 'use server';
2
- import { createClient as o, getServiceRoleSupabaseClient as d } from "@nextblock-cms/db/server";
3
- import { getProduct as l, getProducts as _, copyProductFromLanguage as m } from "../../../product-actions.es.js";
4
- import { syncSingleFreemiusProduct as p, syncFreemiusProductsToSupabase as g } from "../../../providers/freemius.es.js";
5
- import { revalidatePath as c } from "next/cache";
6
- async function v(r) {
7
- const t = o(), { data: a, count: e, error: s } = await await _(t, { ...r, status: "all" });
8
- if (s) throw new Error(s.message);
9
- return { data: a, count: e };
1
+ "use server";
2
+ import { copyProductFromLanguage as e, getProduct as t, getProducts as n } from "../../../product-actions.es.js";
3
+ import { syncFreemiusProductsToSupabase as r, syncSingleFreemiusProduct as i } from "../../../providers/freemius.es.js";
4
+ import { createClient as a, getServiceRoleSupabaseClient as o } from "@nextblock-cms/db/server";
5
+ import { revalidatePath as s } from "next/cache";
6
+ //#region src/lib/pages/cms/products/actions.ts
7
+ async function c(e) {
8
+ let t = a(), { data: r, count: i, error: o } = await await n(t, {
9
+ ...e,
10
+ status: "all"
11
+ });
12
+ if (o) throw Error(o.message);
13
+ return {
14
+ data: r,
15
+ count: i
16
+ };
10
17
  }
11
- async function P(r) {
12
- const t = o(), { data: a, error: e } = await l(t, r);
13
- if (e) throw new Error(e.message);
14
- return a;
18
+ async function l(e) {
19
+ let n = a(), { data: r, error: i } = await t(n, e);
20
+ if (i) throw Error(i.message);
21
+ return r;
15
22
  }
16
- async function E() {
17
- try {
18
- const r = await g();
19
- return c("/cms/products", "page"), { success: !0, data: r };
20
- } catch (r) {
21
- return { error: r.message || "Failed to sync with Freemius" };
22
- }
23
+ async function u() {
24
+ try {
25
+ let e = await r();
26
+ return s("/cms/products", "page"), {
27
+ success: !0,
28
+ data: e
29
+ };
30
+ } catch (e) {
31
+ return { error: e.message || "Failed to sync with Freemius" };
32
+ }
23
33
  }
24
- async function F(r) {
25
- try {
26
- const t = await p(r);
27
- return c("/cms/products", "page"), c("/cms/products/[id]/edit", "page"), { success: !0, data: t };
28
- } catch (t) {
29
- return { error: t.message || "Failed to sync product with Freemius" };
30
- }
34
+ async function d(e) {
35
+ try {
36
+ let t = await i(e);
37
+ return s("/cms/products", "page"), s("/cms/products/[id]/edit", "page"), {
38
+ success: !0,
39
+ data: t
40
+ };
41
+ } catch (e) {
42
+ return { error: e.message || "Failed to sync product with Freemius" };
43
+ }
31
44
  }
32
- async function S(r, t) {
33
- try {
34
- const a = o();
35
- return await m(a, r, t), c("/cms/products"), c(`/cms/products/${r}/edit`), { success: !0 };
36
- } catch (a) {
37
- return { success: !1, error: a.message || "Failed to copy product content" };
38
- }
45
+ async function f(t, n) {
46
+ try {
47
+ let r = a();
48
+ return await e(r, t, n), s("/cms/products"), s(`/cms/products/${t}/edit`), { success: !0 };
49
+ } catch (e) {
50
+ return {
51
+ success: !1,
52
+ error: e.message || "Failed to copy product content"
53
+ };
54
+ }
39
55
  }
40
- async function q(r) {
41
- const t = o(), { data: a, error: e } = await t.from("products").select("id, title, language_id, slug").eq("translation_group_id", r);
42
- if (e) throw new Error(e.message);
43
- return a;
56
+ async function p(e) {
57
+ let { data: t, error: n } = await a().from("products").select("id, title, language_id, slug").eq("translation_group_id", e);
58
+ if (n) throw Error(n.message);
59
+ return t;
44
60
  }
45
- async function C() {
46
- const r = d(), { data: t, error: a } = await r.from("product_attributes").select(`
47
- id,
48
- name,
49
- name_translations,
50
- slug,
51
- product_attribute_terms (
52
- id,
53
- attribute_id,
54
- value,
55
- slug,
56
- sort_order,
57
- value_translations
58
- )
59
- `);
60
- if (a)
61
- throw new Error(a.message);
62
- return (t || []).map((e) => ({
63
- ...e,
64
- product_attribute_terms: (e.product_attribute_terms || []).sort(
65
- (s, u) => (s.sort_order ?? Number.MAX_SAFE_INTEGER) - (u.sort_order ?? Number.MAX_SAFE_INTEGER) || s.value.localeCompare(u.value)
66
- )
67
- })).sort((e, s) => e.name.localeCompare(s.name));
61
+ async function m() {
62
+ let { data: e, error: t } = await o().from("product_attributes").select("\n id,\n name,\n name_translations,\n slug,\n product_attribute_terms (\n id,\n attribute_id,\n value,\n slug,\n sort_order,\n value_translations\n )\n ");
63
+ if (t) throw Error(t.message);
64
+ return (e || []).map((e) => ({
65
+ ...e,
66
+ 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))
67
+ })).sort((e, t) => e.name.localeCompare(t.name));
68
68
  }
69
- async function A(r) {
70
- const t = o(), { data: a, error: e } = await t.from("freemius_plans").select(`
71
- id,
72
- name,
73
- title,
74
- freemius_pricing (
75
- id,
76
- license_quota,
77
- api_monthly_price,
78
- api_annual_price,
79
- api_lifetime_price,
80
- override_monthly_price,
81
- override_annual_price,
82
- override_lifetime_price,
83
- is_active
84
- )
85
- `).eq("product_id", r);
86
- if (e) throw new Error(e.message);
87
- return a;
69
+ async function h(e) {
70
+ let { data: t, error: n } = await a().from("freemius_plans").select("\n id,\n name,\n title,\n freemius_pricing (\n id,\n license_quota,\n api_monthly_price,\n api_annual_price,\n api_lifetime_price,\n override_monthly_price,\n override_annual_price,\n override_lifetime_price,\n is_active\n )\n ").eq("product_id", e);
71
+ if (n) throw Error(n.message);
72
+ return t;
88
73
  }
89
- async function N(r, t) {
90
- const a = o(), { error: e } = await a.from("freemius_pricing").update({
91
- ...t,
92
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
93
- }).eq("id", r);
94
- return e ? { success: !1, error: e.message } : (c("/cms/products"), { success: !0 });
74
+ async function g(e, t) {
75
+ let { error: n } = await a().from("freemius_pricing").update({
76
+ ...t,
77
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
78
+ }).eq("id", e);
79
+ return n ? {
80
+ success: !1,
81
+ error: n.message
82
+ } : (s("/cms/products"), { success: !0 });
95
83
  }
96
- async function T(r) {
97
- const t = o(), { data: a } = await t.from("products").select("translation_group_id").eq("id", r).maybeSingle();
98
- let e = [r];
99
- if (a?.translation_group_id) {
100
- const { data: n } = await t.from("products").select("id").eq("translation_group_id", a.translation_group_id);
101
- n && n.length > 0 && (e = n.map((i) => i.id));
102
- }
103
- const { data: s, error: u } = await t.from("freemius_plans").select(`
104
- id,
105
- name,
106
- title,
107
- freemius_pricing (
108
- id,
109
- license_quota,
110
- api_monthly_price,
111
- api_annual_price,
112
- api_lifetime_price,
113
- override_monthly_price,
114
- override_annual_price,
115
- override_lifetime_price,
116
- is_active
117
- )
118
- `).in("product_id", e);
119
- if (u) throw new Error(u.message);
120
- return (s || []).map((n) => ({
121
- id: n.id,
122
- name: n.name,
123
- title: n.title,
124
- pricing: (n.freemius_pricing || []).filter((i) => i.is_active !== !1).map((i) => ({
125
- id: i.id,
126
- license_quota: i.license_quota,
127
- monthly_price: i.override_monthly_price ?? i.api_monthly_price,
128
- annual_price: i.override_annual_price ?? i.api_annual_price,
129
- lifetime_price: i.override_lifetime_price ?? i.api_lifetime_price,
130
- is_active: i.is_active
131
- }))
132
- }));
84
+ async function _(e) {
85
+ let t = a(), { data: n } = await t.from("products").select("translation_group_id").eq("id", e).maybeSingle(), r = [e];
86
+ if (n?.translation_group_id) {
87
+ let { data: e } = await t.from("products").select("id").eq("translation_group_id", n.translation_group_id);
88
+ e && e.length > 0 && (r = e.map((e) => e.id));
89
+ }
90
+ let { data: i, error: o } = await t.from("freemius_plans").select("\n id,\n name,\n title,\n freemius_pricing (\n id,\n license_quota,\n api_monthly_price,\n api_annual_price,\n api_lifetime_price,\n override_monthly_price,\n override_annual_price,\n override_lifetime_price,\n is_active\n )\n ").in("product_id", r);
91
+ if (o) throw Error(o.message);
92
+ return (i || []).map((e) => ({
93
+ id: e.id,
94
+ name: e.name,
95
+ title: e.title,
96
+ pricing: (e.freemius_pricing || []).filter((e) => e.is_active !== !1).map((e) => ({
97
+ id: e.id,
98
+ license_quota: e.license_quota,
99
+ monthly_price: e.override_monthly_price ?? e.api_monthly_price,
100
+ annual_price: e.override_annual_price ?? e.api_annual_price,
101
+ lifetime_price: e.override_lifetime_price ?? e.api_lifetime_price,
102
+ is_active: e.is_active
103
+ }))
104
+ }));
133
105
  }
134
- async function B() {
135
- const r = o(), { data: t, error: a } = await r.from("categories").select("id, name, slug, description, created_at, name_translations, description_translations, product_categories(count)").order("name", { ascending: !0 });
136
- if (a) throw new Error(a.message);
137
- return (t || []).map((e) => {
138
- const s = e.product_categories?.[0]?.count ?? e.product_categories?.count ?? 0;
139
- return {
140
- id: e.id,
141
- name: e.name,
142
- slug: e.slug,
143
- description: e.description ?? "",
144
- created_at: e.created_at,
145
- productCount: Number(s),
146
- name_translations: e.name_translations || {},
147
- description_translations: e.description_translations || {}
148
- };
149
- });
106
+ async function v() {
107
+ let { data: e, error: t } = await a().from("categories").select("id, name, slug, description, created_at, name_translations, description_translations, product_categories(count)").order("name", { ascending: !0 });
108
+ if (t) throw Error(t.message);
109
+ return (e || []).map((e) => {
110
+ let t = e.product_categories?.[0]?.count ?? e.product_categories?.count ?? 0;
111
+ return {
112
+ id: e.id,
113
+ name: e.name,
114
+ slug: e.slug,
115
+ description: e.description ?? "",
116
+ created_at: e.created_at,
117
+ productCount: Number(t),
118
+ name_translations: e.name_translations || {},
119
+ description_translations: e.description_translations || {}
120
+ };
121
+ });
150
122
  }
151
- async function G(r) {
152
- const t = o(), { data: a, error: e } = await t.from("categories").select("id, name, slug, description, created_at").eq("slug", r).maybeSingle();
153
- if (e) throw new Error(e.message);
154
- return a;
123
+ async function y(e) {
124
+ let { data: t, error: n } = await a().from("categories").select("id, name, slug, description, created_at").eq("slug", e).maybeSingle();
125
+ if (n) throw Error(n.message);
126
+ return t;
155
127
  }
156
- async function I(r) {
157
- const t = o(), { data: a, error: e } = await t.from("product_categories").select("category:categories(id, name, slug, description, name_translations, description_translations, created_at)").eq("product_id", r);
158
- if (e) throw new Error(e.message);
159
- return (a || []).map((s) => s.category).filter(Boolean);
128
+ async function b(e) {
129
+ let { data: t, error: n } = await a().from("product_categories").select("category:categories(id, name, slug, description, name_translations, description_translations, created_at)").eq("product_id", e);
130
+ if (n) throw Error(n.message);
131
+ return (t || []).map((e) => e.category).filter(Boolean);
160
132
  }
161
- export {
162
- S as copyProductFromLanguageAction,
163
- B as getCategoriesWithCount,
164
- G as getCategoryBySlug,
165
- A as getFreemiusPricingByProductId,
166
- C as getGlobalProductAttributes,
167
- P as getProduct,
168
- I as getProductCategories,
169
- q as getProductTranslations,
170
- v as getProducts,
171
- T as getPublicFreemiusPricing,
172
- E as triggerFreemiusSync,
173
- F as triggerSingleProductSync,
174
- N as updateFreemiusOverride
175
- };
133
+ //#endregion
134
+ export { f as copyProductFromLanguageAction, v as getCategoriesWithCount, y as getCategoryBySlug, h as getFreemiusPricingByProductId, m as getGlobalProductAttributes, l as getProduct, b as getProductCategories, p as getProductTranslations, c as getProducts, _ as getPublicFreemiusPricing, u as triggerFreemiusSync, d as triggerSingleProductSync, g as updateFreemiusOverride };
@@ -0,0 +1 @@
1
+ const e=require("../../../../../_virtual/_rolldown/runtime.cjs"),t=require("../actions.cjs"),n=require("../server-actions.cjs"),r=require("./components/AttributeManager.cjs");let i=require("next/link");i=e.__toESM(i,1);let a=require("lucide-react"),o=require("react/jsx-runtime"),s=require("@nextblock-cms/db/server"),c=require("@nextblock-cms/ui");async function l(){let[e,l]=await Promise.all([t.getGlobalProductAttributes(),(0,s.getActiveLanguagesServerSide)()]),u=(e||[]).map(e=>({id:e.id,name:e.name,name_translations:e.name_translations||{},slug:e.slug,terms:(e.product_attribute_terms||[]).map(e=>({...e,value_translations:e.value_translations||{}}))}));return(0,o.jsxs)(`div`,{className:`space-y-8 w-full max-w-[1200px] mx-auto px-6 py-8`,children:[(0,o.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,o.jsx)(c.Button,{variant:`outline`,size:`icon`,asChild:!0,children:(0,o.jsx)(i.default,{href:`/cms/products`,children:(0,o.jsx)(a.ArrowLeft,{className:`h-4 w-4`})})}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Global Attribute Management`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Define reusable attributes and terms for variation-based physical products.`})]})]})}),(0,o.jsx)(r.AttributeManager,{attributes:u,createAttributeAction:n.createProductAttributeAction,deleteAttributeAction:n.deleteProductAttributeAction,createTermAction:n.createProductAttributeTermAction,deleteTermAction:n.deleteProductAttributeTermAction,reorderTermsAction:n.reorderProductAttributeTermsAction,updateTranslationsAction:n.updateProductAttributeTranslationsAction,languages:l})]})}exports.AttributeManagementPage=l;
@@ -1 +1 @@
1
- export declare function AttributeManagementPage(): Promise<import("react").JSX.Element>;
1
+ export declare function AttributeManagementPage(): Promise<import('react').JSX.Element>;
@@ -1,48 +1,56 @@
1
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import s from "next/link";
3
- import { ArrowLeft as c } from "lucide-react";
4
- import { Button as l } from "@nextblock-cms/ui";
5
- import { getActiveLanguagesServerSide as m } from "@nextblock-cms/db/server";
6
- import { getGlobalProductAttributes as u } from "../actions.es.js";
7
- import { updateProductAttributeTranslationsAction as d, reorderProductAttributeTermsAction as A, deleteProductAttributeTermAction as p, createProductAttributeTermAction as f, deleteProductAttributeAction as b, createProductAttributeAction as g } from "../server-actions.es.js";
8
- import { AttributeManager as x } from "./components/AttributeManager.es.js";
9
- async function j() {
10
- const [i, o] = await Promise.all([
11
- u(),
12
- m()
13
- ]), n = (i || []).map((e) => ({
14
- id: e.id,
15
- name: e.name,
16
- name_translations: e.name_translations || {},
17
- slug: e.slug,
18
- terms: (e.product_attribute_terms || []).map((a) => ({
19
- ...a,
20
- value_translations: a.value_translations || {}
21
- }))
22
- }));
23
- return /* @__PURE__ */ r("div", { className: "space-y-8 w-full max-w-[1200px] mx-auto px-6 py-8", children: [
24
- /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center justify-between gap-4", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
25
- /* @__PURE__ */ t(l, { variant: "outline", size: "icon", asChild: !0, children: /* @__PURE__ */ t(s, { href: "/cms/products", children: /* @__PURE__ */ t(c, { className: "h-4 w-4" }) }) }),
26
- /* @__PURE__ */ r("div", { children: [
27
- /* @__PURE__ */ t("h1", { className: "text-2xl font-bold", children: "Global Attribute Management" }),
28
- /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "Define reusable attributes and terms for variation-based physical products." })
29
- ] })
30
- ] }) }),
31
- /* @__PURE__ */ t(
32
- x,
33
- {
34
- attributes: n,
35
- createAttributeAction: g,
36
- deleteAttributeAction: b,
37
- createTermAction: f,
38
- deleteTermAction: p,
39
- reorderTermsAction: A,
40
- updateTranslationsAction: d,
41
- languages: o
42
- }
43
- )
44
- ] });
1
+ import { getGlobalProductAttributes as e } from "../actions.es.js";
2
+ import { createProductAttributeAction as t, createProductAttributeTermAction as n, deleteProductAttributeAction as r, deleteProductAttributeTermAction as i, reorderProductAttributeTermsAction as a, updateProductAttributeTranslationsAction as o } from "../server-actions.es.js";
3
+ import { AttributeManager as s } from "./components/AttributeManager.es.js";
4
+ import c from "next/link";
5
+ import { ArrowLeft as l } from "lucide-react";
6
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
7
+ import { getActiveLanguagesServerSide as f } from "@nextblock-cms/db/server";
8
+ import { Button as p } from "@nextblock-cms/ui";
9
+ //#region src/lib/pages/cms/products/attributes/AttributeManagementPage.tsx
10
+ async function m() {
11
+ let [m, h] = await Promise.all([e(), f()]), g = (m || []).map((e) => ({
12
+ id: e.id,
13
+ name: e.name,
14
+ name_translations: e.name_translations || {},
15
+ slug: e.slug,
16
+ terms: (e.product_attribute_terms || []).map((e) => ({
17
+ ...e,
18
+ value_translations: e.value_translations || {}
19
+ }))
20
+ }));
21
+ return /* @__PURE__ */ d("div", {
22
+ className: "space-y-8 w-full max-w-[1200px] mx-auto px-6 py-8",
23
+ children: [/* @__PURE__ */ u("div", {
24
+ className: "flex flex-wrap items-center justify-between gap-4",
25
+ children: /* @__PURE__ */ d("div", {
26
+ className: "flex items-center gap-3",
27
+ children: [/* @__PURE__ */ u(p, {
28
+ variant: "outline",
29
+ size: "icon",
30
+ asChild: !0,
31
+ children: /* @__PURE__ */ u(c, {
32
+ href: "/cms/products",
33
+ children: /* @__PURE__ */ u(l, { className: "h-4 w-4" })
34
+ })
35
+ }), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("h1", {
36
+ className: "text-2xl font-bold",
37
+ children: "Global Attribute Management"
38
+ }), /* @__PURE__ */ u("p", {
39
+ className: "text-sm text-muted-foreground",
40
+ children: "Define reusable attributes and terms for variation-based physical products."
41
+ })] })]
42
+ })
43
+ }), /* @__PURE__ */ u(s, {
44
+ attributes: g,
45
+ createAttributeAction: t,
46
+ deleteAttributeAction: r,
47
+ createTermAction: n,
48
+ deleteTermAction: i,
49
+ reorderTermsAction: a,
50
+ updateTranslationsAction: o,
51
+ languages: h
52
+ })]
53
+ });
45
54
  }
46
- export {
47
- j as AttributeManagementPage
48
- };
55
+ //#endregion
56
+ export { m as AttributeManagementPage };
@@ -0,0 +1 @@
1
+ "use client";let e=require("react"),t=require("lucide-react"),n=require("react/jsx-runtime"),r=require("next/navigation"),i=require("@nextblock-cms/ui");function a({attributes:a,languages:o,createAttributeAction:s,deleteAttributeAction:c,createTermAction:l,deleteTermAction:u,reorderTermsAction:d,updateTranslationsAction:f}){let p=(0,r.useRouter)(),[m,h]=(0,e.useState)(``),[g,_]=(0,e.useState)(null),[v,y]=(0,e.useState)(null),[b,x]=(0,e.useState)(null),[S,C]=(0,e.useState)(null),[w,T]=(0,e.useState)({}),[E,D]=(0,e.useState)(()=>a.reduce((e,t)=>(e[t.id]=t.name_translations||{},e),{})),[O,k]=(0,e.useState)(()=>a.reduce((e,t)=>{for(let n of t.terms)e[n.id]=n.value_translations||{};return e},{})),A=o.filter(e=>!e.is_default),j=async e=>{e.preventDefault();let t=await s({name:m});if(!t.success){alert(t.error||`Failed to create attribute.`);return}h(``),p.refresh()},M=async(e,t)=>{e.preventDefault(),_(t);let n=await l({attributeId:t,value:w[t]||``});if(_(null),!n.success){alert(n.error||`Failed to create term.`);return}T(e=>({...e,[t]:``})),p.refresh()},N=async e=>{if(!window.confirm(`Delete this attribute and all of its terms?`))return;let t=await c(e);if(!t.success){alert(t.error||`Failed to delete attribute.`);return}p.refresh()},P=async e=>{y(e);let t=await u(e);if(y(null),!t.success){alert(t.error||`Failed to delete term.`);return}p.refresh()},F=async(e,t,n)=>{let r=e.terms.findIndex(e=>e.id===t),i=r+n;if(r===-1||i<0||i>=e.terms.length)return;let a=[...e.terms],[o]=a.splice(r,1);a.splice(i,0,o),x(e.id);let s=await d({attributeId:e.id,orderedTermIds:a.map(e=>e.id)});if(x(null),!s.success){alert(s.error||`Failed to reorder terms.`);return}p.refresh()},I=async e=>{C(e.id);let t=await f({attributeId:e.id,nameTranslations:E[e.id]||{},termTranslations:e.terms.map(e=>({termId:e.id,valueTranslations:O[e.id]||{}}))});if(C(null),!t.success){alert(t.error||`Failed to save translations.`);return}p.refresh()};return(0,n.jsxs)(`div`,{className:`space-y-6`,children:[(0,n.jsx)(`form`,{onSubmit:j,className:`rounded-lg border bg-card p-6 shadow-sm`,children:(0,n.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,n.jsxs)(`div`,{className:`flex-1 min-w-[220px] space-y-2`,children:[(0,n.jsx)(i.Label,{htmlFor:`attribute-name`,children:`New Attribute`}),(0,n.jsx)(i.Input,{id:`attribute-name`,value:m,onChange:e=>h(e.target.value),placeholder:`Material, Size, Color...`})]}),(0,n.jsxs)(i.Button,{type:`submit`,disabled:!m.trim(),children:[(0,n.jsx)(t.Plus,{className:`mr-2 h-4 w-4`}),`Create Attribute`]})]})}),a.length===0?(0,n.jsx)(`div`,{className:`rounded-lg border border-dashed p-6 text-sm text-muted-foreground`,children:`No global attributes have been created yet.`}):(0,n.jsx)(`div`,{className:`grid gap-6`,children:a.map(e=>(0,n.jsxs)(`div`,{className:`rounded-lg border bg-card p-6 shadow-sm`,children:[(0,n.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.name}),(0,n.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.slug})]}),(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>N(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,n.jsx)(t.Trash2,{className:`h-4 w-4`})})]}),(0,n.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.terms.map((r,a)=>(0,n.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border bg-muted/20 px-3 py-2`,children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(i.Badge,{variant:`secondary`,className:`py-1.5`,children:r.value}),(0,n.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Position `,a+1]})]}),(0,n.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>F(e,r.id,-1),disabled:a===0||b===e.id,children:(0,n.jsx)(t.ChevronUp,{className:`h-4 w-4`})}),(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>F(e,r.id,1),disabled:a===e.terms.length-1||b===e.id,children:(0,n.jsx)(t.ChevronDown,{className:`h-4 w-4`})}),(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>P(r.id),className:`h-8 w-8 text-muted-foreground hover:text-destructive`,disabled:v===r.id,children:(0,n.jsx)(t.Trash2,{className:`h-4 w-4`})})]})]},r.id))}),(0,n.jsxs)(`form`,{onSubmit:t=>M(t,e.id),className:`mt-6 flex flex-wrap items-end gap-3`,children:[(0,n.jsxs)(`div`,{className:`flex-1 min-w-[220px] space-y-2`,children:[(0,n.jsx)(i.Label,{htmlFor:`term-input-${e.id}`,children:`Add Term`}),(0,n.jsx)(i.Input,{id:`term-input-${e.id}`,value:w[e.id]||``,onChange:t=>T(n=>({...n,[e.id]:t.target.value})),placeholder:`Add a term for ${e.name}`})]}),(0,n.jsxs)(i.Button,{type:`submit`,variant:`outline`,disabled:!w[e.id]?.trim()||g===e.id,children:[(0,n.jsx)(t.Plus,{className:`mr-2 h-4 w-4`}),g===e.id?`Saving...`:`Add Term`]})]}),A.length>0&&(0,n.jsxs)(`div`,{className:`mt-6 border-t pt-6 space-y-4`,children:[(0,n.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h3`,{className:`font-medium`,children:`Translations`}),(0,n.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Translate the attribute label and each term for every active site language.`})]}),(0,n.jsx)(i.Button,{type:`button`,variant:`outline`,onClick:()=>I(e),disabled:S===e.id,children:S===e.id?`Saving...`:`Save Translations`})]}),(0,n.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:A.map(t=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsxs)(i.Label,{htmlFor:`attribute-translation-${e.id}-${t.code}`,children:[`Attribute Name (`,t.name,`)`]}),(0,n.jsx)(i.Input,{id:`attribute-translation-${e.id}-${t.code}`,value:E[e.id]?.[t.code]||``,onChange:n=>D(r=>({...r,[e.id]:{...r[e.id]||{},[t.code]:n.target.value}})),placeholder:e.name})]},`${e.id}-${t.code}`))}),(0,n.jsx)(`div`,{className:`space-y-3`,children:e.terms.map(e=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`p`,{className:`font-medium`,children:e.value}),(0,n.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Translate this term for each language.`})]}),(0,n.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:A.map(t=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(i.Label,{htmlFor:`term-translation-${e.id}-${t.code}`,children:t.name}),(0,n.jsx)(i.Input,{id:`term-translation-${e.id}-${t.code}`,value:O[e.id]?.[t.code]||``,onChange:n=>k(r=>({...r,[e.id]:{...r[e.id]||{},[t.code]:n.target.value}})),placeholder:e.value})]},`${e.id}-${t.code}`))})]},`translations-${e.id}`))})]})]},e.id))})]})}exports.AttributeManager=a;
@@ -46,5 +46,5 @@ interface AttributeManagerProps {
46
46
  error?: string;
47
47
  }>;
48
48
  }
49
- export declare function AttributeManager({ attributes, languages, createAttributeAction, deleteAttributeAction, createTermAction, deleteTermAction, reorderTermsAction, updateTranslationsAction, }: AttributeManagerProps): import("react").JSX.Element;
49
+ export declare function AttributeManager({ attributes, languages, createAttributeAction, deleteAttributeAction, createTermAction, deleteTermAction, reorderTermsAction, updateTranslationsAction, }: AttributeManagerProps): import('react').JSX.Element;
50
50
  export {};