@nextblock-cms/ecom 0.20.3 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +43 -0
  2. package/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/index.cjs +1 -0
  4. package/index.es.js +38 -146
  5. package/lib/CurrencyProvider.cjs +1 -0
  6. package/lib/CurrencyProvider.d.ts +1 -1
  7. package/lib/CurrencyProvider.es.js +85 -95
  8. package/lib/PaymentReadinessProvider.cjs +1 -0
  9. package/lib/PaymentReadinessProvider.d.ts +1 -1
  10. package/lib/PaymentReadinessProvider.es.js +24 -27
  11. package/lib/cart-store.cjs +1 -0
  12. package/lib/cart-store.es.js +109 -121
  13. package/lib/components/AccountNavigationMenu.cjs +1 -0
  14. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  15. package/lib/components/AccountNavigationMenu.es.js +36 -50
  16. package/lib/components/AddToCartButton.cjs +1 -0
  17. package/lib/components/AddToCartButton.d.ts +1 -1
  18. package/lib/components/AddToCartButton.es.js +94 -89
  19. package/lib/components/Cart.cjs +1 -0
  20. package/lib/components/Cart.d.ts +1 -1
  21. package/lib/components/Cart.es.js +261 -180
  22. package/lib/components/CartDrawer.cjs +1 -0
  23. package/lib/components/CartDrawer.d.ts +1 -1
  24. package/lib/components/CartDrawer.es.js +218 -148
  25. package/lib/components/CartIcon.cjs +1 -0
  26. package/lib/components/CartIcon.d.ts +1 -1
  27. package/lib/components/CartIcon.es.js +33 -35
  28. package/lib/components/Checkout.cjs +1 -0
  29. package/lib/components/Checkout.d.ts +1 -1
  30. package/lib/components/Checkout.es.js +1092 -1108
  31. package/lib/components/CouponForm.cjs +1 -0
  32. package/lib/components/CouponForm.d.ts +1 -1
  33. package/lib/components/CouponForm.es.js +136 -148
  34. package/lib/components/CurrencySwitcher.cjs +1 -0
  35. package/lib/components/CurrencySwitcher.d.ts +1 -1
  36. package/lib/components/CurrencySwitcher.es.js +22 -18
  37. package/lib/components/CustomerProfileForm.cjs +1 -0
  38. package/lib/components/CustomerProfileForm.es.js +454 -313
  39. package/lib/components/FeaturedProduct.cjs +1 -0
  40. package/lib/components/FeaturedProduct.d.ts +1 -1
  41. package/lib/components/FeaturedProduct.es.js +98 -83
  42. package/lib/components/FreemiusLicensePanel.cjs +1 -0
  43. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  44. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  45. package/lib/components/InvoiceDocument.cjs +1 -0
  46. package/lib/components/InvoiceDocument.es.js +256 -192
  47. package/lib/components/InvoiceViewerShell.cjs +29 -0
  48. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  49. package/lib/components/InvoiceViewerShell.es.js +75 -106
  50. package/lib/components/ProductCard.cjs +1 -0
  51. package/lib/components/ProductCard.d.ts +1 -1
  52. package/lib/components/ProductCard.es.js +186 -171
  53. package/lib/components/ProductDetailsLayout.cjs +1 -0
  54. package/lib/components/ProductDetailsLayout.es.js +405 -404
  55. package/lib/components/ProductGallery.cjs +1 -0
  56. package/lib/components/ProductGallery.d.ts +1 -1
  57. package/lib/components/ProductGallery.es.js +51 -54
  58. package/lib/components/ProductGrid.cjs +1 -0
  59. package/lib/components/ProductGrid.d.ts +1 -1
  60. package/lib/components/ProductGrid.es.js +23 -25
  61. package/lib/components/ShippingEstimator.cjs +1 -0
  62. package/lib/components/ShippingEstimator.d.ts +1 -1
  63. package/lib/components/ShippingEstimator.es.js +158 -153
  64. package/lib/components/ShortDescription.cjs +1 -0
  65. package/lib/components/ShortDescription.es.js +17 -17
  66. package/lib/components/SimpleTiptapRenderer.cjs +1 -0
  67. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  68. package/lib/components/SubscriptionSelector.cjs +1 -0
  69. package/lib/components/SubscriptionSelector.es.js +159 -154
  70. package/lib/countries.cjs +1 -0
  71. package/lib/countries.es.js +232 -75
  72. package/lib/coupon-server.cjs +1 -0
  73. package/lib/coupon-server.es.js +180 -224
  74. package/lib/coupons.cjs +1 -0
  75. package/lib/coupons.es.js +12 -14
  76. package/lib/currency-constants.cjs +1 -0
  77. package/lib/currency-constants.es.js +4 -4
  78. package/lib/currency-rest-client.cjs +1 -0
  79. package/lib/currency-rest-client.es.js +15 -22
  80. package/lib/currency-store.cjs +1 -0
  81. package/lib/currency-store.es.js +20 -27
  82. package/lib/currency-sync.cjs +1 -0
  83. package/lib/currency-sync.es.js +124 -170
  84. package/lib/currency.cjs +1 -0
  85. package/lib/currency.es.js +242 -310
  86. package/lib/customer-addresses.cjs +1 -0
  87. package/lib/customer-addresses.es.js +80 -109
  88. package/lib/customer-orders.cjs +1 -0
  89. package/lib/customer-orders.es.js +31 -43
  90. package/lib/customer.cjs +1 -0
  91. package/lib/customer.es.js +43 -52
  92. package/lib/export-helpers.cjs +1 -0
  93. package/lib/export-helpers.es.js +53 -52
  94. package/lib/factory.cjs +1 -0
  95. package/lib/factory.es.js +10 -7
  96. package/lib/freemius-coupons.cjs +1 -0
  97. package/lib/freemius-coupons.es.js +245 -262
  98. package/lib/freemius-license-claim.cjs +1 -0
  99. package/lib/freemius-license-claim.es.js +87 -71
  100. package/lib/freemius-license.cjs +1 -0
  101. package/lib/freemius-license.es.js +32 -39
  102. package/lib/freemius-order-sync.cjs +1 -0
  103. package/lib/freemius-order-sync.es.js +226 -290
  104. package/lib/freemius-trial-provision.cjs +1 -0
  105. package/lib/freemius-trial-provision.es.js +136 -130
  106. package/lib/inventory-settings.cjs +1 -0
  107. package/lib/inventory-settings.es.js +69 -77
  108. package/lib/invoice-server.cjs +33 -0
  109. package/lib/invoice-server.es.js +94 -141
  110. package/lib/invoice-ui.cjs +1 -0
  111. package/lib/invoice-ui.es.js +50 -66
  112. package/lib/invoice.cjs +1 -0
  113. package/lib/invoice.es.js +85 -94
  114. package/lib/order-inventory.cjs +61 -0
  115. package/lib/order-inventory.es.js +67 -79
  116. package/lib/order-tax-details.cjs +1 -0
  117. package/lib/order-tax-details.es.js +142 -153
  118. package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
  119. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  120. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  121. package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
  122. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  123. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  124. package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
  125. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  126. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  127. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
  128. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  129. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  130. package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
  131. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  132. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  133. package/lib/pages/cms/coupons/actions.cjs +1 -0
  134. package/lib/pages/cms/coupons/actions.es.js +112 -115
  135. package/lib/pages/cms/coupons/index.cjs +1 -0
  136. package/lib/pages/cms/coupons/index.es.js +3 -0
  137. package/lib/pages/cms/coupons/product-options.cjs +1 -0
  138. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  139. package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
  140. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  141. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
  143. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  144. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  145. package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
  146. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  147. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  148. package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
  149. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  150. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  151. package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
  152. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  153. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  154. package/lib/pages/cms/orders/actions.cjs +7 -0
  155. package/lib/pages/cms/orders/actions.es.js +53 -69
  156. package/lib/pages/cms/orders/export-actions.cjs +1 -0
  157. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  158. package/lib/pages/cms/orders/index.cjs +1 -0
  159. package/lib/pages/cms/orders/index.es.js +6 -0
  160. package/lib/pages/cms/orders/server-actions.cjs +1 -0
  161. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  162. package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
  163. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  164. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  165. package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
  166. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  167. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  168. package/lib/pages/cms/payments/actions.cjs +1 -0
  169. package/lib/pages/cms/payments/actions.es.js +38 -48
  170. package/lib/pages/cms/payments/index.cjs +1 -0
  171. package/lib/pages/cms/payments/index.es.js +3 -0
  172. package/lib/pages/cms/payments/queries.cjs +1 -0
  173. package/lib/pages/cms/payments/queries.es.js +38 -48
  174. package/lib/pages/cms/products/ProductsPage.cjs +1 -0
  175. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  176. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  177. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
  178. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  179. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
  180. package/lib/pages/cms/products/actions.cjs +44 -0
  181. package/lib/pages/cms/products/actions.es.js +121 -162
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  184. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  187. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  190. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  191. package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
  192. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
  194. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  197. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  198. package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
  199. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  200. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  203. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  204. package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
  205. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  206. package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
  207. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  208. package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
  209. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  210. package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
  211. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  212. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  213. package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
  214. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  215. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  218. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  221. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  222. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
  224. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  225. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  226. package/lib/pages/cms/products/index.cjs +1 -0
  227. package/lib/pages/cms/products/index.es.js +8 -0
  228. package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
  229. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  230. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  233. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  234. package/lib/pages/cms/products/inventory/actions.cjs +3 -0
  235. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  236. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
  237. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  238. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  239. package/lib/pages/cms/products/product-price-sync.cjs +1 -0
  240. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  241. package/lib/pages/cms/products/server-actions.cjs +1 -0
  242. package/lib/pages/cms/products/server-actions.es.js +250 -233
  243. package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
  244. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  245. package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
  246. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  247. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  248. package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
  249. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  250. package/lib/pages/cms/shipping/index.cjs +1 -0
  251. package/lib/pages/cms/shipping/index.es.js +3 -0
  252. package/lib/pages/cms/shipping/server-actions.cjs +1 -0
  253. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  254. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
  255. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  256. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  257. package/lib/pages/cms/taxes/actions.cjs +1 -0
  258. package/lib/pages/cms/taxes/actions.es.js +41 -53
  259. package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
  260. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  261. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  262. package/lib/pages/cms/taxes/index.cjs +1 -0
  263. package/lib/pages/cms/taxes/index.es.js +3 -0
  264. package/lib/payment-config.cjs +1 -0
  265. package/lib/payment-config.es.js +110 -126
  266. package/lib/product-actions.cjs +238 -0
  267. package/lib/product-actions.es.js +289 -544
  268. package/lib/product-context.cjs +1 -0
  269. package/lib/product-context.es.js +13 -15
  270. package/lib/product-schema.cjs +1 -0
  271. package/lib/product-schema.es.js +99 -134
  272. package/lib/providers/freemius.cjs +1 -0
  273. package/lib/providers/freemius.es.js +446 -530
  274. package/lib/providers/stripe.cjs +1 -0
  275. package/lib/providers/stripe.es.js +417 -477
  276. package/lib/server-actions/coupon-actions.cjs +1 -0
  277. package/lib/server-actions/coupon-actions.es.js +22 -22
  278. package/lib/server-actions/customer-actions.cjs +1 -0
  279. package/lib/server-actions/customer-actions.es.js +26 -28
  280. package/lib/server-actions/product-actions.cjs +1 -0
  281. package/lib/server-actions/product-actions.es.js +9 -15
  282. package/lib/server-actions/shipping-actions.cjs +1 -0
  283. package/lib/server-actions/shipping-actions.es.js +27 -24
  284. package/lib/server-actions/tax-actions.cjs +1 -0
  285. package/lib/server-actions/tax-actions.es.js +33 -39
  286. package/lib/shared-inventory.cjs +15 -0
  287. package/lib/shared-inventory.es.js +111 -160
  288. package/lib/shipping/resolver.cjs +7 -0
  289. package/lib/shipping/resolver.es.js +44 -61
  290. package/lib/shipping-rate-currency.cjs +1 -0
  291. package/lib/shipping-rate-currency.es.js +52 -67
  292. package/lib/states.cjs +1 -0
  293. package/lib/states.es.js +333 -154
  294. package/lib/stripe/checkout.cjs +1 -0
  295. package/lib/stripe/checkout.es.js +125 -181
  296. package/lib/stripe/client.cjs +1 -0
  297. package/lib/stripe/client.es.js +14 -19
  298. package/lib/stripe/order-sync.cjs +1 -0
  299. package/lib/stripe/order-sync.es.js +106 -126
  300. package/lib/stripe/webhooks.cjs +1 -0
  301. package/lib/stripe/webhooks.es.js +37 -31
  302. package/lib/tax-calculation.cjs +1 -0
  303. package/lib/tax-calculation.es.js +84 -98
  304. package/lib/trials.cjs +1 -0
  305. package/lib/trials.es.js +24 -30
  306. package/lib/types.cjs +1 -0
  307. package/lib/types.es.js +21 -27
  308. package/lib/use-cart.cjs +1 -0
  309. package/lib/use-cart.es.js +38 -40
  310. package/lib/use-price-formatter.cjs +1 -0
  311. package/lib/use-price-formatter.es.js +10 -11
  312. package/lib/variation-utils.cjs +1 -0
  313. package/lib/variation-utils.es.js +199 -261
  314. package/lib/zod-config.cjs +1 -0
  315. package/lib/zod-config.es.js +5 -6
  316. package/package.json +22 -21
  317. package/server.cjs +1 -0
  318. package/server.es.js +56 -211
  319. package/index.cjs.js +0 -1
  320. package/lib/CurrencyProvider.cjs.js +0 -1
  321. package/lib/PaymentReadinessProvider.cjs.js +0 -1
  322. package/lib/cart-store.cjs.js +0 -1
  323. package/lib/components/AccountNavigationMenu.cjs.js +0 -1
  324. package/lib/components/AddToCartButton.cjs.js +0 -1
  325. package/lib/components/Cart.cjs.js +0 -1
  326. package/lib/components/CartDrawer.cjs.js +0 -1
  327. package/lib/components/CartIcon.cjs.js +0 -1
  328. package/lib/components/Checkout.cjs.js +0 -1
  329. package/lib/components/CouponForm.cjs.js +0 -1
  330. package/lib/components/CurrencySwitcher.cjs.js +0 -1
  331. package/lib/components/CustomerProfileForm.cjs.js +0 -1
  332. package/lib/components/FeaturedProduct.cjs.js +0 -1
  333. package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
  334. package/lib/components/InvoiceDocument.cjs.js +0 -1
  335. package/lib/components/InvoiceViewerShell.cjs.js +0 -29
  336. package/lib/components/ProductCard.cjs.js +0 -1
  337. package/lib/components/ProductDetailsLayout.cjs.js +0 -1
  338. package/lib/components/ProductGallery.cjs.js +0 -1
  339. package/lib/components/ProductGrid.cjs.js +0 -1
  340. package/lib/components/ShippingEstimator.cjs.js +0 -1
  341. package/lib/components/ShortDescription.cjs.js +0 -1
  342. package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
  343. package/lib/components/SubscriptionSelector.cjs.js +0 -1
  344. package/lib/countries.cjs.js +0 -1
  345. package/lib/coupon-server.cjs.js +0 -1
  346. package/lib/coupons.cjs.js +0 -1
  347. package/lib/currency-constants.cjs.js +0 -1
  348. package/lib/currency-rest-client.cjs.js +0 -1
  349. package/lib/currency-store.cjs.js +0 -1
  350. package/lib/currency-sync.cjs.js +0 -1
  351. package/lib/currency.cjs.js +0 -1
  352. package/lib/customer-addresses.cjs.js +0 -1
  353. package/lib/customer-orders.cjs.js +0 -1
  354. package/lib/customer.cjs.js +0 -1
  355. package/lib/export-helpers.cjs.js +0 -1
  356. package/lib/factory.cjs.js +0 -1
  357. package/lib/freemius-coupons.cjs.js +0 -1
  358. package/lib/freemius-license-claim.cjs.js +0 -1
  359. package/lib/freemius-license.cjs.js +0 -1
  360. package/lib/freemius-order-sync.cjs.js +0 -1
  361. package/lib/freemius-trial-provision.cjs.js +0 -1
  362. package/lib/inventory-settings.cjs.js +0 -1
  363. package/lib/invoice-server.cjs.js +0 -33
  364. package/lib/invoice-ui.cjs.js +0 -1
  365. package/lib/invoice.cjs.js +0 -1
  366. package/lib/order-inventory.cjs.js +0 -61
  367. package/lib/order-tax-details.cjs.js +0 -1
  368. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
  369. package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
  370. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
  371. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
  372. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
  373. package/lib/pages/cms/coupons/actions.cjs.js +0 -1
  374. package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
  375. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
  376. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
  377. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
  378. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
  379. package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
  380. package/lib/pages/cms/orders/actions.cjs.js +0 -7
  381. package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
  382. package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
  383. package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
  384. package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
  385. package/lib/pages/cms/payments/actions.cjs.js +0 -1
  386. package/lib/pages/cms/payments/queries.cjs.js +0 -1
  387. package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
  388. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
  389. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
  390. package/lib/pages/cms/products/actions.cjs.js +0 -44
  391. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
  392. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
  393. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
  394. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
  395. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
  396. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
  397. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
  398. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
  399. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
  400. package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
  401. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
  402. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
  403. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
  404. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
  405. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
  406. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
  407. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
  408. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
  409. package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
  410. package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
  411. package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
  412. package/lib/pages/cms/products/server-actions.cjs.js +0 -1
  413. package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
  414. package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
  415. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
  416. package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
  417. package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
  418. package/lib/pages/cms/taxes/actions.cjs.js +0 -1
  419. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
  420. package/lib/payment-config.cjs.js +0 -1
  421. package/lib/product-actions.cjs.js +0 -238
  422. package/lib/product-context.cjs.js +0 -1
  423. package/lib/product-schema.cjs.js +0 -1
  424. package/lib/providers/freemius.cjs.js +0 -5
  425. package/lib/providers/stripe.cjs.js +0 -1
  426. package/lib/server-actions/coupon-actions.cjs.js +0 -1
  427. package/lib/server-actions/customer-actions.cjs.js +0 -1
  428. package/lib/server-actions/product-actions.cjs.js +0 -1
  429. package/lib/server-actions/shipping-actions.cjs.js +0 -1
  430. package/lib/server-actions/tax-actions.cjs.js +0 -1
  431. package/lib/shared-inventory.cjs.js +0 -15
  432. package/lib/shipping/resolver.cjs.js +0 -7
  433. package/lib/shipping-rate-currency.cjs.js +0 -1
  434. package/lib/states.cjs.js +0 -1
  435. package/lib/stripe/checkout.cjs.js +0 -1
  436. package/lib/stripe/client.cjs.js +0 -1
  437. package/lib/stripe/order-sync.cjs.js +0 -1
  438. package/lib/stripe/webhooks.cjs.js +0 -1
  439. package/lib/tax-calculation.cjs.js +0 -1
  440. package/lib/trials.cjs.js +0 -1
  441. package/lib/types.cjs.js +0 -1
  442. package/lib/use-cart.cjs.js +0 -1
  443. package/lib/use-price-formatter.cjs.js +0 -1
  444. package/lib/variation-utils.cjs.js +0 -1
  445. package/lib/zod-config.cjs.js +0 -1
  446. package/server.cjs.js +0 -1
@@ -1,104 +1,172 @@
1
- import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
- import i from "next/link";
3
- import { getOrders as h } from "./actions.es.js";
4
- import { ExportReportsDialog as g } from "./ExportReportsDialog.es.js";
5
- const m = (s, r = "usd") => new Intl.NumberFormat("en-US", {
6
- style: "currency",
7
- currency: r
8
- }).format(s / 100);
9
- async function N({
10
- searchParams: s
11
- }) {
12
- const r = await s, l = Number(r.page) || 1, d = r.status || "all", { data: n, totalPages: c } = await h(l, d);
13
- return /* @__PURE__ */ a("div", { className: "p-6 space-y-6", children: [
14
- /* @__PURE__ */ a("div", { className: "flex justify-between items-center", children: [
15
- /* @__PURE__ */ e("h1", { className: "text-2xl font-bold tracking-tight", children: "Orders" }),
16
- /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
17
- /* @__PURE__ */ e(g, {}),
18
- /* @__PURE__ */ e(i, { href: `/cms/orders?page=${l}&status=${d}`, className: "px-3 py-2 text-sm font-medium border rounded hover:bg-gray-50 dark:hover:bg-slate-800", children: "Refresh" })
19
- ] })
20
- ] }),
21
- /* @__PURE__ */ e("div", { className: "flex gap-2 border-b pb-4", children: ["all", "paid", "trial", "pending", "failed"].map((t) => /* @__PURE__ */ e(
22
- i,
23
- {
24
- href: `/cms/orders?page=1&status=${t}`,
25
- className: `px-3 py-1 rounded-full text-sm font-medium capitalize ${d === t ? "bg-black text-white dark:bg-white dark:text-black" : "bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-slate-800 dark:text-gray-300 dark:hover:bg-slate-700"}`,
26
- children: t
27
- },
28
- t
29
- )) }),
30
- /* @__PURE__ */ e("div", { className: "border rounded-lg overflow-hidden dark:border-slate-800", children: /* @__PURE__ */ a("table", { className: "w-full text-sm text-left align-middle", children: [
31
- /* @__PURE__ */ e("thead", { className: "bg-gray-50 text-gray-500 font-medium border-b dark:bg-slate-900 dark:text-slate-400 dark:border-slate-800", children: /* @__PURE__ */ a("tr", { children: [
32
- /* @__PURE__ */ e("th", { className: "px-4 py-3", children: "ID" }),
33
- /* @__PURE__ */ e("th", { className: "px-4 py-3", children: "Customer" }),
34
- /* @__PURE__ */ e("th", { className: "px-4 py-3", children: "Status" }),
35
- /* @__PURE__ */ e("th", { className: "px-4 py-3", children: "Provider" }),
36
- /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right", children: "Amount" }),
37
- /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right", children: "Date" }),
38
- /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right", children: "Actions" })
39
- ] }) }),
40
- /* @__PURE__ */ e("tbody", { className: "divide-y dark:divide-slate-800", children: n.length === 0 ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 7, className: "px-4 py-8 text-center text-gray-500", children: "No orders found." }) }) : n.map((t) => {
41
- const o = t.customer_details, p = o?.name || o?.email || t.customer?.full_name || "Guest Customer";
42
- return /* @__PURE__ */ a("tr", { className: "hover:bg-gray-50 dark:hover:bg-slate-800/50", children: [
43
- /* @__PURE__ */ a("td", { className: "px-4 py-3 font-mono text-gray-500", children: [
44
- t.id.slice(0, 8),
45
- "..."
46
- ] }),
47
- /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium", children: p }),
48
- /* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ e(x, { status: t.status }) }),
49
- /* @__PURE__ */ e("td", { className: "px-4 py-3 capitalize text-gray-600 dark:text-gray-400", children: t.provider === "freemius" ? "Freemius" : "Stripe" }),
50
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: /* @__PURE__ */ a("div", { className: "flex flex-col items-end", children: [
51
- /* @__PURE__ */ e("span", { children: m(t.total, t.currency || "usd") }),
52
- t.discount_total ? /* @__PURE__ */ a("span", { className: "text-[10px] text-emerald-600", children: [
53
- t.coupon_code,
54
- " -",
55
- m(t.discount_total, t.currency || "usd")
56
- ] }) : null
57
- ] }) }),
58
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right text-gray-500 whitespace-nowrap", children: new Date(t.created_at || "").toLocaleDateString() }),
59
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: /* @__PURE__ */ e(
60
- i,
61
- {
62
- href: `/cms/orders/${t.id}`,
63
- className: "text-blue-600 hover:underline dark:text-blue-400",
64
- children: "View"
65
- }
66
- ) })
67
- ] }, t.id);
68
- }) })
69
- ] }) }),
70
- /* @__PURE__ */ a("div", { className: "flex justify-between items-center pt-4", children: [
71
- /* @__PURE__ */ a("div", { className: "text-sm text-gray-500", children: [
72
- "Page ",
73
- l,
74
- " of ",
75
- c
76
- ] }),
77
- /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
78
- /* @__PURE__ */ e(
79
- i,
80
- {
81
- href: `/cms/orders?page=${Math.max(1, l - 1)}&status=${d}`,
82
- className: `px-3 py-1 border rounded text-sm ${l <= 1 ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
83
- children: "Previous"
84
- }
85
- ),
86
- /* @__PURE__ */ e(
87
- i,
88
- {
89
- href: `/cms/orders?page=${Math.min(c, l + 1)}&status=${d}`,
90
- className: `px-3 py-1 border rounded text-sm ${l >= c ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
91
- children: "Next"
92
- }
93
- )
94
- ] })
95
- ] })
96
- ] });
1
+ import { getOrders as e } from "./actions.es.js";
2
+ import { ExportReportsDialog as t } from "./ExportReportsDialog.es.js";
3
+ import n from "next/link";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ //#region src/lib/pages/cms/orders/OrdersPage.tsx
6
+ var a = (e, t = "usd") => new Intl.NumberFormat("en-US", {
7
+ style: "currency",
8
+ currency: t
9
+ }).format(e / 100);
10
+ async function o({ searchParams: o }) {
11
+ let c = await o, l = Number(c.page) || 1, u = c.status || "all", { data: d, totalPages: f } = await e(l, u);
12
+ return /* @__PURE__ */ i("div", {
13
+ className: "p-6 space-y-6",
14
+ children: [
15
+ /* @__PURE__ */ i("div", {
16
+ className: "flex justify-between items-center",
17
+ children: [/* @__PURE__ */ r("h1", {
18
+ className: "text-2xl font-bold tracking-tight",
19
+ children: "Orders"
20
+ }), /* @__PURE__ */ i("div", {
21
+ className: "flex items-center gap-2",
22
+ children: [/* @__PURE__ */ r(t, {}), /* @__PURE__ */ r(n, {
23
+ href: `/cms/orders?page=${l}&status=${u}`,
24
+ className: "px-3 py-2 text-sm font-medium border rounded hover:bg-gray-50 dark:hover:bg-slate-800",
25
+ children: "Refresh"
26
+ })]
27
+ })]
28
+ }),
29
+ /* @__PURE__ */ r("div", {
30
+ className: "flex gap-2 border-b pb-4",
31
+ children: [
32
+ "all",
33
+ "paid",
34
+ "trial",
35
+ "pending",
36
+ "failed"
37
+ ].map((e) => /* @__PURE__ */ r(n, {
38
+ href: `/cms/orders?page=1&status=${e}`,
39
+ className: `px-3 py-1 rounded-full text-sm font-medium capitalize ${u === e ? "bg-black text-white dark:bg-white dark:text-black" : "bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-slate-800 dark:text-gray-300 dark:hover:bg-slate-700"}`,
40
+ children: e
41
+ }, e))
42
+ }),
43
+ /* @__PURE__ */ r("div", {
44
+ className: "border rounded-lg overflow-hidden dark:border-slate-800",
45
+ children: /* @__PURE__ */ i("table", {
46
+ className: "w-full text-sm text-left align-middle",
47
+ children: [/* @__PURE__ */ r("thead", {
48
+ className: "bg-gray-50 text-gray-500 font-medium border-b dark:bg-slate-900 dark:text-slate-400 dark:border-slate-800",
49
+ children: /* @__PURE__ */ i("tr", { children: [
50
+ /* @__PURE__ */ r("th", {
51
+ className: "px-4 py-3",
52
+ children: "ID"
53
+ }),
54
+ /* @__PURE__ */ r("th", {
55
+ className: "px-4 py-3",
56
+ children: "Customer"
57
+ }),
58
+ /* @__PURE__ */ r("th", {
59
+ className: "px-4 py-3",
60
+ children: "Status"
61
+ }),
62
+ /* @__PURE__ */ r("th", {
63
+ className: "px-4 py-3",
64
+ children: "Provider"
65
+ }),
66
+ /* @__PURE__ */ r("th", {
67
+ className: "px-4 py-3 text-right",
68
+ children: "Amount"
69
+ }),
70
+ /* @__PURE__ */ r("th", {
71
+ className: "px-4 py-3 text-right",
72
+ children: "Date"
73
+ }),
74
+ /* @__PURE__ */ r("th", {
75
+ className: "px-4 py-3 text-right",
76
+ children: "Actions"
77
+ })
78
+ ] })
79
+ }), /* @__PURE__ */ r("tbody", {
80
+ className: "divide-y dark:divide-slate-800",
81
+ children: d.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", {
82
+ colSpan: 7,
83
+ className: "px-4 py-8 text-center text-gray-500",
84
+ children: "No orders found."
85
+ }) }) : d.map((e) => {
86
+ let t = e.customer_details, o = t?.name || t?.email || e.customer?.full_name || "Guest Customer";
87
+ return /* @__PURE__ */ i("tr", {
88
+ className: "hover:bg-gray-50 dark:hover:bg-slate-800/50",
89
+ children: [
90
+ /* @__PURE__ */ i("td", {
91
+ className: "px-4 py-3 font-mono text-gray-500",
92
+ children: [e.id.slice(0, 8), "..."]
93
+ }),
94
+ /* @__PURE__ */ r("td", {
95
+ className: "px-4 py-3 font-medium",
96
+ children: o
97
+ }),
98
+ /* @__PURE__ */ r("td", {
99
+ className: "px-4 py-3",
100
+ children: /* @__PURE__ */ r(s, { status: e.status })
101
+ }),
102
+ /* @__PURE__ */ r("td", {
103
+ className: "px-4 py-3 capitalize text-gray-600 dark:text-gray-400",
104
+ children: e.provider === "freemius" ? "Freemius" : "Stripe"
105
+ }),
106
+ /* @__PURE__ */ r("td", {
107
+ className: "px-4 py-3 text-right",
108
+ children: /* @__PURE__ */ i("div", {
109
+ className: "flex flex-col items-end",
110
+ children: [/* @__PURE__ */ r("span", { children: a(e.total, e.currency || "usd") }), e.discount_total ? /* @__PURE__ */ i("span", {
111
+ className: "text-[10px] text-emerald-600",
112
+ children: [
113
+ e.coupon_code,
114
+ " -",
115
+ a(e.discount_total, e.currency || "usd")
116
+ ]
117
+ }) : null]
118
+ })
119
+ }),
120
+ /* @__PURE__ */ r("td", {
121
+ className: "px-4 py-3 text-right text-gray-500 whitespace-nowrap",
122
+ children: new Date(e.created_at || "").toLocaleDateString()
123
+ }),
124
+ /* @__PURE__ */ r("td", {
125
+ className: "px-4 py-3 text-right",
126
+ children: /* @__PURE__ */ r(n, {
127
+ href: `/cms/orders/${e.id}`,
128
+ className: "text-blue-600 hover:underline dark:text-blue-400",
129
+ children: "View"
130
+ })
131
+ })
132
+ ]
133
+ }, e.id);
134
+ })
135
+ })]
136
+ })
137
+ }),
138
+ /* @__PURE__ */ i("div", {
139
+ className: "flex justify-between items-center pt-4",
140
+ children: [/* @__PURE__ */ i("div", {
141
+ className: "text-sm text-gray-500",
142
+ children: [
143
+ "Page ",
144
+ l,
145
+ " of ",
146
+ f
147
+ ]
148
+ }), /* @__PURE__ */ i("div", {
149
+ className: "flex gap-2",
150
+ children: [/* @__PURE__ */ r(n, {
151
+ href: `/cms/orders?page=${Math.max(1, l - 1)}&status=${u}`,
152
+ className: `px-3 py-1 border rounded text-sm ${l <= 1 ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
153
+ children: "Previous"
154
+ }), /* @__PURE__ */ r(n, {
155
+ href: `/cms/orders?page=${Math.min(f, l + 1)}&status=${u}`,
156
+ className: `px-3 py-1 border rounded text-sm ${l >= f ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
157
+ children: "Next"
158
+ })]
159
+ })]
160
+ })
161
+ ]
162
+ });
97
163
  }
98
- function x({ status: s }) {
99
- let r = "bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";
100
- return s === "paid" && (r = "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"), s === "trial" && (r = "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"), s === "pending" && (r = "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"), s === "failed" && (r = "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"), /* @__PURE__ */ e("span", { className: `px-2 py-0.5 rounded-full text-xs font-medium capitalize ${r}`, children: s });
164
+ function s({ status: e }) {
165
+ let t = "bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";
166
+ return e === "paid" && (t = "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"), e === "trial" && (t = "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"), e === "pending" && (t = "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"), e === "failed" && (t = "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"), /* @__PURE__ */ r("span", {
167
+ className: `px-2 py-0.5 rounded-full text-xs font-medium capitalize ${t}`,
168
+ children: e
169
+ });
101
170
  }
102
- export {
103
- N as OrdersPage
104
- };
171
+ //#endregion
172
+ export { o as OrdersPage };
@@ -0,0 +1,7 @@
1
+ "use server";let e=require("@nextblock-cms/db/server");var t=20;async function n(n=1,r,i){let a=await(0,e.createClient)(),o=(n-1)*t,s=o+t-1,c=a.from(`orders`).select(`
2
+ *,
3
+ order_items (*)
4
+ `,{count:`exact`}).order(`created_at`,{ascending:!1}).range(o,s);r&&r!==`all`&&(c=c.eq(`status`,r)),i&&(c=c.or(`id.eq.${i},user_id.eq.${i}`));let{data:l,error:u,count:d}=await c;if(u)throw console.error(`Error fetching orders:`,u),Error(`Failed to fetch orders`);let f=l||[],p=Array.from(new Set(f.map(e=>e.user_id).filter(Boolean))),m=new Map;if(p.length>0){let{data:e,error:t}=await a.from(`profiles`).select(`*`).in(`id`,p);!t&&e&&e.forEach(e=>m.set(e.id,e))}return{data:f.map(e=>({...e,customer:e.user_id?m.get(e.user_id):null})),total:d||0,totalPages:d?Math.ceil(d/t):0}}async function r(t){let n=await(0,e.createClient)(),{data:r,error:i}=await n.from(`orders`).select(`
5
+ *,
6
+ order_items (*)
7
+ `).eq(`id`,t).single();if(i||!r)return console.error(`Error fetching order ${t}:`,i),null;let a=r,o=null;if(a.user_id){let{data:e}=await n.from(`profiles`).select(`*`).eq(`id`,a.user_id).single();o=e}let s=a.order_items.map(e=>e.product_id).filter(Boolean),c=new Map;if(s.length>0){let{data:e}=await n.from(`products`).select(`id, title, slug, product_media(media(file_path))`).in(`id`,s);e&&e.forEach(e=>{let t=null;e.product_media&&e.product_media.length>0&&e.product_media[0].media&&(t=e.product_media[0].media.file_path),c.set(e.id,{title:e.title,slug:e.slug,image_url:t})})}let l=a.order_items.map(e=>({...e,product:e.product_id?c.get(e.product_id):null}));return{...a,order_items:l,customer:o}}exports.getOrderDetails=r,exports.getOrders=n;
@@ -1,71 +1,55 @@
1
- 'use server';
2
- import { createClient as g } from "@nextblock-cms/db/server";
3
- const m = 20;
4
- async function q(n = 1, i, s) {
5
- const d = await g(), t = (n - 1) * m, l = t + m - 1;
6
- let o = d.from("orders").select(
7
- `
8
- *,
9
- order_items (*)
10
- `,
11
- { count: "exact" }
12
- ).order("created_at", { ascending: !1 }).range(t, l);
13
- i && i !== "all" && (o = o.eq("status", i)), s && (o = o.or(`id.eq.${s},user_id.eq.${s}`));
14
- const { data: u, error: f, count: r } = await o;
15
- if (f)
16
- throw console.error("Error fetching orders:", f), new Error("Failed to fetch orders");
17
- const e = u || [], c = Array.from(new Set(e.map((a) => a.user_id).filter(Boolean))), p = /* @__PURE__ */ new Map();
18
- if (c.length > 0) {
19
- const { data: a, error: w } = await d.from("profiles").select("*").in("id", c);
20
- !w && a && a.forEach((_) => p.set(_.id, _));
21
- }
22
- return {
23
- data: e.map((a) => ({
24
- ...a,
25
- customer: a.user_id ? p.get(a.user_id) : null
26
- })),
27
- total: r || 0,
28
- totalPages: r ? Math.ceil(r / m) : 0
29
- };
1
+ "use server";
2
+ import { createClient as e } from "@nextblock-cms/db/server";
3
+ //#region src/lib/pages/cms/orders/actions.ts
4
+ var t = 20;
5
+ async function n(n = 1, r, i) {
6
+ let a = await e(), o = (n - 1) * t, s = o + t - 1, c = a.from("orders").select("\n *,\n order_items (*)\n ", { count: "exact" }).order("created_at", { ascending: !1 }).range(o, s);
7
+ r && r !== "all" && (c = c.eq("status", r)), i && (c = c.or(`id.eq.${i},user_id.eq.${i}`));
8
+ let { data: l, error: u, count: d } = await c;
9
+ if (u) throw console.error("Error fetching orders:", u), Error("Failed to fetch orders");
10
+ let f = l || [], p = Array.from(new Set(f.map((e) => e.user_id).filter(Boolean))), m = /* @__PURE__ */ new Map();
11
+ if (p.length > 0) {
12
+ let { data: e, error: t } = await a.from("profiles").select("*").in("id", p);
13
+ !t && e && e.forEach((e) => m.set(e.id, e));
14
+ }
15
+ return {
16
+ data: f.map((e) => ({
17
+ ...e,
18
+ customer: e.user_id ? m.get(e.user_id) : null
19
+ })),
20
+ total: d || 0,
21
+ totalPages: d ? Math.ceil(d / t) : 0
22
+ };
30
23
  }
31
- async function M(n) {
32
- const i = await g(), { data: s, error: d } = await i.from("orders").select(
33
- `
34
- *,
35
- order_items (*)
36
- `
37
- ).eq("id", n).single();
38
- if (d || !s)
39
- return console.error(`Error fetching order ${n}:`, d), null;
40
- const t = s;
41
- let l = null;
42
- if (t.user_id) {
43
- const { data: r } = await i.from("profiles").select("*").eq("id", t.user_id).single();
44
- l = r;
45
- }
46
- const o = t.order_items.map((r) => r.product_id).filter(Boolean), u = /* @__PURE__ */ new Map();
47
- if (o.length > 0) {
48
- const { data: r } = await i.from("products").select("id, title, slug, product_media(media(file_path))").in("id", o);
49
- r && r.forEach((e) => {
50
- let c = null;
51
- e.product_media && e.product_media.length > 0 && e.product_media[0].media && (c = e.product_media[0].media.file_path), u.set(e.id, {
52
- title: e.title,
53
- slug: e.slug,
54
- image_url: c
55
- });
56
- });
57
- }
58
- const f = t.order_items.map((r) => ({
59
- ...r,
60
- product: r.product_id ? u.get(r.product_id) : null
61
- }));
62
- return {
63
- ...t,
64
- order_items: f,
65
- customer: l
66
- };
24
+ async function r(t) {
25
+ let n = await e(), { data: r, error: i } = await n.from("orders").select("\n *,\n order_items (*)\n ").eq("id", t).single();
26
+ if (i || !r) return console.error(`Error fetching order ${t}:`, i), null;
27
+ let a = r, o = null;
28
+ if (a.user_id) {
29
+ let { data: e } = await n.from("profiles").select("*").eq("id", a.user_id).single();
30
+ o = e;
31
+ }
32
+ let s = a.order_items.map((e) => e.product_id).filter(Boolean), c = /* @__PURE__ */ new Map();
33
+ if (s.length > 0) {
34
+ let { data: e } = await n.from("products").select("id, title, slug, product_media(media(file_path))").in("id", s);
35
+ e && e.forEach((e) => {
36
+ let t = null;
37
+ e.product_media && e.product_media.length > 0 && e.product_media[0].media && (t = e.product_media[0].media.file_path), c.set(e.id, {
38
+ title: e.title,
39
+ slug: e.slug,
40
+ image_url: t
41
+ });
42
+ });
43
+ }
44
+ let l = a.order_items.map((e) => ({
45
+ ...e,
46
+ product: e.product_id ? c.get(e.product_id) : null
47
+ }));
48
+ return {
49
+ ...a,
50
+ order_items: l,
51
+ customer: o
52
+ };
67
53
  }
68
- export {
69
- M as getOrderDetails,
70
- q as getOrders
71
- };
54
+ //#endregion
55
+ export { r as getOrderDetails, n as getOrders };
@@ -0,0 +1 @@
1
+ "use server";let e=require("@nextblock-cms/db/server");async function t(t,n){let r=(0,e.createClient)(),i=r.from(`orders`).select(`*, order_items(*)`);if(t&&(i=i.gte(`created_at`,t)),n){let e=new Date(n);e.setHours(23,59,59,999),i=i.lte(`created_at`,e.toISOString())}let{data:a,error:o}=await i.order(`created_at`,{ascending:!0});if(o)throw console.error(`Error fetching report data:`,o),Error(`Failed to fetch report data: ${o.message}`);if(!a||a.length===0)return[];let s=Array.from(new Set(a.map(e=>e.user_id).filter(Boolean))),c=new Map;if(s.length>0){let{data:e}=await r.from(`profiles`).select(`id, full_name, email`).in(`id`,s);e&&e.forEach(e=>c.set(e.id,e))}return a.map(e=>({...e,customer:e.user_id?c.get(e.user_id):null}))}exports.fetchOrderReportData=t;
@@ -1,27 +1,24 @@
1
- 'use server';
2
- import { createClient as d } from "@nextblock-cms/db/server";
3
- async function u(a, s) {
4
- const i = d();
5
- let r = i.from("orders").select("*, order_items(*)");
6
- if (a && (r = r.gte("created_at", a)), s) {
7
- const e = new Date(s);
8
- e.setHours(23, 59, 59, 999), r = r.lte("created_at", e.toISOString());
9
- }
10
- const { data: t, error: o } = await r.order("created_at", { ascending: !0 });
11
- if (o)
12
- throw console.error("Error fetching report data:", o), new Error(`Failed to fetch report data: ${o.message}`);
13
- if (!t || t.length === 0)
14
- return [];
15
- const n = Array.from(new Set(t.map((e) => e.user_id).filter(Boolean))), c = /* @__PURE__ */ new Map();
16
- if (n.length > 0) {
17
- const { data: e } = await i.from("profiles").select("id, full_name, email").in("id", n);
18
- e && e.forEach((f) => c.set(f.id, f));
19
- }
20
- return t.map((e) => ({
21
- ...e,
22
- customer: e.user_id ? c.get(e.user_id) : null
23
- }));
1
+ "use server";
2
+ import { createClient as e } from "@nextblock-cms/db/server";
3
+ //#region src/lib/pages/cms/orders/export-actions.ts
4
+ async function t(t, n) {
5
+ let r = e(), i = r.from("orders").select("*, order_items(*)");
6
+ if (t && (i = i.gte("created_at", t)), n) {
7
+ let e = new Date(n);
8
+ e.setHours(23, 59, 59, 999), i = i.lte("created_at", e.toISOString());
9
+ }
10
+ let { data: a, error: o } = await i.order("created_at", { ascending: !0 });
11
+ if (o) throw console.error("Error fetching report data:", o), Error(`Failed to fetch report data: ${o.message}`);
12
+ if (!a || a.length === 0) return [];
13
+ let s = Array.from(new Set(a.map((e) => e.user_id).filter(Boolean))), c = /* @__PURE__ */ new Map();
14
+ if (s.length > 0) {
15
+ let { data: e } = await r.from("profiles").select("id, full_name, email").in("id", s);
16
+ e && e.forEach((e) => c.set(e.id, e));
17
+ }
18
+ return a.map((e) => ({
19
+ ...e,
20
+ customer: e.user_id ? c.get(e.user_id) : null
21
+ }));
24
22
  }
25
- export {
26
- u as fetchOrderReportData
27
- };
23
+ //#endregion
24
+ export { t as fetchOrderReportData };
@@ -0,0 +1 @@
1
+ const e=require("./actions.cjs"),t=require("./export-actions.cjs"),n=require("./ExportReportsDialog.cjs"),r=require("./OrdersPage.cjs"),i=require("./OrderDetailPage.cjs");exports.ExportReportsDialog=n.ExportReportsDialog,exports.OrderDetailPage=i.OrderDetailPage,exports.OrdersPage=r.OrdersPage,exports.fetchOrderReportData=t.fetchOrderReportData,exports.getOrderDetails=e.getOrderDetails,exports.getOrders=e.getOrders;
@@ -0,0 +1,6 @@
1
+ import { getOrderDetails as e, getOrders as t } from "./actions.es.js";
2
+ import { fetchOrderReportData as n } from "./export-actions.es.js";
3
+ import { ExportReportsDialog as r } from "./ExportReportsDialog.es.js";
4
+ import { OrdersPage as i } from "./OrdersPage.es.js";
5
+ import { OrderDetailPage as a } from "./OrderDetailPage.es.js";
6
+ export { r as ExportReportsDialog, a as OrderDetailPage, i as OrdersPage, n as fetchOrderReportData, e as getOrderDetails, t as getOrders };
@@ -0,0 +1 @@
1
+ "use server";const e=require("../../../order-inventory.cjs"),t=require("../../../invoice-server.cjs");let n=require("@nextblock-cms/db/server"),r=require("@supabase/supabase-js");var i=[`pending`,`trial`,`paid`,`shipped`,`cancelled`,`refunded`];async function a(){let e=(0,n.createClient)(),{data:{user:t},error:r}=await e.auth.getUser();if(r||!t)return{error:`Unauthorized`};let{data:i,error:a}=await e.from(`profiles`).select(`role`).eq(`id`,t.id).single();return a||!i||![`ADMIN`,`WRITER`].includes(i.role)?{error:`Forbidden`}:{supabase:e,user:t}}function o(){let e=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY,t=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL;if(!e||!t)throw Error(`Server configuration error`);return(0,r.createClient)(t,e,{auth:{autoRefreshToken:!1,persistSession:!1}})}async function s(n,r){let s=await a();if(`error`in s)return{success:!1,error:s.error};if(!i.includes(r))return{success:!1,error:`Invalid order status`};let c;try{c=o()}catch(e){return{success:!1,error:e instanceof Error?e.message:`Server configuration error`}}let{data:l,error:u}=await c.from(`orders`).update({status:r}).eq(`id`,n).select();return u?(console.error(`Order status update error:`,u),{success:!1,error:u.message}):!l||l.length===0?{success:!1,error:`Order not found or update failed.`}:(r===`paid`&&(await t.assignInvoiceMetadata({orderId:n,client:c}),await e.applyOrderInventoryDeduction(c,n)),{success:!0})}exports.updateOrderStatus=s;
@@ -1,55 +1,64 @@
1
- 'use server';
2
- import { createClient as i } from "@nextblock-cms/db/server";
3
- import { createClient as c } from "@supabase/supabase-js";
4
- import { applyOrderInventoryDeduction as u } from "../../../order-inventory.es.js";
5
- import { assignInvoiceMetadata as d } from "../../../invoice-server.es.js";
6
- const f = [
7
- "pending",
8
- "trial",
9
- "paid",
10
- "shipped",
11
- "cancelled",
12
- "refunded"
1
+ "use server";
2
+ import { applyOrderInventoryDeduction as e } from "../../../order-inventory.es.js";
3
+ import { assignInvoiceMetadata as t } from "../../../invoice-server.es.js";
4
+ import { createClient as n } from "@nextblock-cms/db/server";
5
+ import { createClient as r } from "@supabase/supabase-js";
6
+ //#region src/lib/pages/cms/orders/server-actions.ts
7
+ var i = [
8
+ "pending",
9
+ "trial",
10
+ "paid",
11
+ "shipped",
12
+ "cancelled",
13
+ "refunded"
13
14
  ];
14
- async function l() {
15
- const r = i(), { data: { user: e }, error: t } = await r.auth.getUser();
16
- if (t || !e)
17
- return { error: "Unauthorized" };
18
- const { data: s, error: a } = await r.from("profiles").select("role").eq("id", e.id).single();
19
- return a || !s || !["ADMIN", "WRITER"].includes(s.role) ? { error: "Forbidden" } : { supabase: r, user: e };
15
+ async function a() {
16
+ let e = n(), { data: { user: t }, error: r } = await e.auth.getUser();
17
+ if (r || !t) return { error: "Unauthorized" };
18
+ let { data: i, error: a } = await e.from("profiles").select("role").eq("id", t.id).single();
19
+ return a || !i || !["ADMIN", "WRITER"].includes(i.role) ? { error: "Forbidden" } : {
20
+ supabase: e,
21
+ user: t
22
+ };
20
23
  }
21
- function p() {
22
- const r = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY, e = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL;
23
- if (!r || !e)
24
- throw new Error("Server configuration error");
25
- return c(e, r, {
26
- auth: {
27
- autoRefreshToken: !1,
28
- persistSession: !1
29
- }
30
- });
24
+ function o() {
25
+ let e = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY, t = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL;
26
+ if (!e || !t) throw Error("Server configuration error");
27
+ return r(t, e, { auth: {
28
+ autoRefreshToken: !1,
29
+ persistSession: !1
30
+ } });
31
31
  }
32
- async function R(r, e) {
33
- const t = await l();
34
- if ("error" in t)
35
- return { success: !1, error: t.error };
36
- if (!f.includes(e))
37
- return { success: !1, error: "Invalid order status" };
38
- let s;
39
- try {
40
- s = p();
41
- } catch (n) {
42
- return {
43
- success: !1,
44
- error: n instanceof Error ? n.message : "Server configuration error"
45
- };
46
- }
47
- const { data: a, error: o } = await s.from("orders").update({ status: e }).eq("id", r).select();
48
- return o ? (console.error("Order status update error:", o), { success: !1, error: o.message }) : !a || a.length === 0 ? { success: !1, error: "Order not found or update failed." } : (e === "paid" && (await d({
49
- orderId: r,
50
- client: s
51
- }), await u(s, r)), { success: !0 });
32
+ async function s(n, r) {
33
+ let s = await a();
34
+ if ("error" in s) return {
35
+ success: !1,
36
+ error: s.error
37
+ };
38
+ if (!i.includes(r)) return {
39
+ success: !1,
40
+ error: "Invalid order status"
41
+ };
42
+ let c;
43
+ try {
44
+ c = o();
45
+ } catch (e) {
46
+ return {
47
+ success: !1,
48
+ error: e instanceof Error ? e.message : "Server configuration error"
49
+ };
50
+ }
51
+ let { data: l, error: u } = await c.from("orders").update({ status: r }).eq("id", n).select();
52
+ return u ? (console.error("Order status update error:", u), {
53
+ success: !1,
54
+ error: u.message
55
+ }) : !l || l.length === 0 ? {
56
+ success: !1,
57
+ error: "Order not found or update failed."
58
+ } : (r === "paid" && (await t({
59
+ orderId: n,
60
+ client: c
61
+ }), await e(c, n)), { success: !0 });
52
62
  }
53
- export {
54
- R as updateOrderStatus
55
- };
63
+ //#endregion
64
+ export { s as updateOrderStatus };