@nextblock-cms/ecom 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),I=require("@nextblock-cms/ui/badge"),K=require("@nextblock-cms/ui/button"),R=require("@nextblock-cms/ui/input"),$=require("@nextblock-cms/ui/label"),w=require("lucide-react"),z=require("@nextblock-cms/utils"),P=require("../use-price-formatter.cjs.js"),F=require("../coupons.cjs.js"),q=require("../use-cart.cjs.js"),T=require("../server-actions/coupon-actions.cjs.js");function V({items:c,currencyCode:i,onQuoteChange:l,compact:d=!1}){const x=q.useCart(e=>e.appliedCoupon),p=q.useCart(e=>e.setAppliedCoupon),s=q.useCart(e=>e.removeCoupon),{t:N}=z.useTranslations(),S=P.usePriceFormatter(),[h,A]=r.useState(""),[a,m]=r.useState(null),[b,u]=r.useState(""),[j,k]=r.useState(!1),f=r.useRef(null),_=r.useMemo(()=>c.map(e=>`${e.product_id}:${e.variant_id||"base"}:${e.quantity}`).sort().join("|"),[c]),n=r.useCallback((e,C)=>{const v=N(e);return v===e?C:v},[N]),y=r.useCallback(e=>`${F.normalizeCouponCode(e)}:${i}:${_}`,[_,i]),g=r.useCallback(async(e,C)=>{const v=F.normalizeCouponCode(e);if(!v){u(n("ecommerce.coupon_code_required","Enter a coupon code."));return}k(!0),u("");try{const t=await T.getCouponQuoteAction({code:v,items:c,currencyCode:i});if(!t.success){m(null),l?.(null),s?.(),u(t.errorKey?n(t.errorKey,t.error):t.error);return}f.current=y(t.quote.code),m(t.quote),l?.(t.quote),C?.silent||(p?.({code:t.quote.code,couponId:t.quote.couponId}),A("")),C?.silent||u("")}catch(t){console.error("Failed to validate coupon:",t),f.current=null,m(null),l?.(null),u(n("ecommerce.coupon_validation_failed","Failed to validate coupon."))}finally{k(!1)}},[s,i,y,c,l,p,n]);if(r.useEffect(()=>{if(!p||!s)return;if(!x||c.length===0){f.current=null,m(null),l?.(null);return}const e=y(x.code);f.current!==e&&(f.current=e,g(x.code,{silent:!0}))},[x?.code,g,s,y,c.length,l,p]),!p||!s)return null;const E=()=>{s(),m(null),l?.(null),u("")};return o.jsxs("div",{className:d?"space-y-2":"rounded-lg border bg-muted/10 p-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs($.Label,{htmlFor:d?"coupon-code-compact":"coupon-code",className:"flex items-center gap-2 text-sm font-medium",children:[o.jsx(w.Tag,{className:"h-4 w-4"}),n("ecommerce.coupon","Coupon")]}),a?o.jsxs(I.Badge,{variant:"secondary",className:"gap-1",children:[a.code,o.jsx("button",{type:"button",onClick:E,"aria-label":n("ecommerce.remove_coupon","Remove coupon {code}").replace("{code}",a.code),className:"-mr-1 inline-flex h-6 w-6 items-center justify-center rounded-full focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",children:o.jsx(w.X,{className:"h-3 w-3"})})]}):null]}),a?o.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[o.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:a.name}),o.jsx("span",{className:"shrink-0 font-medium tabular-nums text-emerald-600 dark:text-emerald-400",children:S(-a.discountTotal,i)})]}):o.jsxs("div",{className:"flex gap-2",children:[o.jsx(R.Input,{id:d?"coupon-code-compact":"coupon-code",name:"coupon",autoComplete:"off",autoCapitalize:"characters",spellCheck:!1,"aria-invalid":b?!0:void 0,"aria-describedby":b?d?"coupon-error-compact":"coupon-error":void 0,value:h,onChange:e=>A(e.target.value),placeholder:n("ecommerce.coupon_placeholder","SAVE10…"),className:"uppercase",onKeyDown:e=>{e.key==="Enter"&&!j&&(e.preventDefault(),g(h))}}),o.jsx(K.Button,{type:"button",variant:"outline",disabled:j||c.length===0,onClick:()=>{g(h)},children:j?n("ecommerce.applying","Applying…"):n("ecommerce.apply","Apply")})]}),b?o.jsx("p",{id:d?"coupon-error-compact":"coupon-error",role:"alert",className:"text-xs text-destructive",children:b}):null]})}exports.CouponForm=V;
1
+ "use client";const e=require("../use-cart.cjs.js"),t=require("../use-price-formatter.cjs.js"),n=require("../coupons.cjs.js"),r=require("../server-actions/coupon-actions.cjs.js");let i=require("@nextblock-cms/ui/badge"),a=require("@nextblock-cms/ui/button"),o=require("react"),s=require("lucide-react"),c=require("@nextblock-cms/utils"),l=require("react/jsx-runtime"),u=require("@nextblock-cms/ui/input"),d=require("@nextblock-cms/ui/label");function f({items:f,currencyCode:p,onQuoteChange:m,compact:h=!1}){let g=e.useCart(e=>e.appliedCoupon),_=e.useCart(e=>e.setAppliedCoupon),v=e.useCart(e=>e.removeCoupon),{t:y}=(0,c.useTranslations)(),b=t.usePriceFormatter(),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(null),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),k=(0,o.useRef)(null),A=(0,o.useMemo)(()=>f.map(e=>`${e.product_id}:${e.variant_id||`base`}:${e.quantity}`).sort().join(`|`),[f]),j=(0,o.useCallback)((e,t)=>{let n=y(e);return n===e?t:n},[y]),M=(0,o.useCallback)(e=>`${n.normalizeCouponCode(e)}:${p}:${A}`,[A,p]),N=(0,o.useCallback)(async(e,t)=>{let i=n.normalizeCouponCode(e);if(!i){E(j(`ecommerce.coupon_code_required`,`Enter a coupon code.`));return}O(!0),E(``);try{let e=await r.getCouponQuoteAction({code:i,items:f,currencyCode:p});if(!e.success){w(null),m?.(null),v?.(),E(e.errorKey?j(e.errorKey,e.error):e.error);return}k.current=M(e.quote.code),w(e.quote),m?.(e.quote),t?.silent||(_?.({code:e.quote.code,couponId:e.quote.couponId}),S(``)),t?.silent||E(``)}catch(e){console.error(`Failed to validate coupon:`,e),k.current=null,w(null),m?.(null),E(j(`ecommerce.coupon_validation_failed`,`Failed to validate coupon.`))}finally{O(!1)}},[v,p,M,f,m,_,j]);return(0,o.useEffect)(()=>{if(!_||!v)return;if(!g||f.length===0){k.current=null,w(null),m?.(null);return}let e=M(g.code);k.current!==e&&(k.current=e,N(g.code,{silent:!0}))},[g?.code,N,v,M,f.length,m,_]),!_||!v?null:(0,l.jsxs)(`div`,{className:h?`space-y-2`:`rounded-lg border bg-muted/10 p-4 space-y-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,l.jsxs)(d.Label,{htmlFor:h?`coupon-code-compact`:`coupon-code`,className:`flex items-center gap-2 text-sm font-medium`,children:[(0,l.jsx)(s.Tag,{className:`h-4 w-4`}),j(`ecommerce.coupon`,`Coupon`)]}),C?(0,l.jsxs)(i.Badge,{variant:`secondary`,className:`gap-1`,children:[C.code,(0,l.jsx)(`button`,{type:`button`,onClick:()=>{v(),w(null),m?.(null),E(``)},"aria-label":j(`ecommerce.remove_coupon`,`Remove coupon {code}`).replace(`{code}`,C.code),className:`-mr-1 inline-flex h-6 w-6 items-center justify-center rounded-full focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring`,children:(0,l.jsx)(s.X,{className:`h-3 w-3`})})]}):null]}),C?(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,l.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:C.name}),(0,l.jsx)(`span`,{className:`shrink-0 font-medium tabular-nums text-emerald-600 dark:text-emerald-400`,children:b(-C.discountTotal,p)})]}):(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(u.Input,{id:h?`coupon-code-compact`:`coupon-code`,name:`coupon`,autoComplete:`off`,autoCapitalize:`characters`,spellCheck:!1,"aria-invalid":T?!0:void 0,"aria-describedby":T?h?`coupon-error-compact`:`coupon-error`:void 0,value:x,onChange:e=>S(e.target.value),placeholder:j(`ecommerce.coupon_placeholder`,`SAVE10…`),className:`uppercase`,onKeyDown:e=>{e.key===`Enter`&&!D&&(e.preventDefault(),N(x))}}),(0,l.jsx)(a.Button,{type:`button`,variant:`outline`,disabled:D||f.length===0,onClick:()=>void N(x),children:D?j(`ecommerce.applying`,`Applying…`):j(`ecommerce.apply`,`Apply`)})]}),T?(0,l.jsx)(`p`,{id:h?`coupon-error-compact`:`coupon-error`,role:`alert`,className:`text-xs text-destructive`,children:T}):null]})}exports.CouponForm=f;
@@ -5,4 +5,4 @@ export declare function CouponForm({ items, currencyCode, onQuoteChange, compact
5
5
  currencyCode: string;
6
6
  onQuoteChange?: (quote: CouponQuote | null) => void;
7
7
  compact?: boolean;
8
- }): import("react").JSX.Element | null;
8
+ }): import('react').JSX.Element | null;
@@ -1,149 +1,137 @@
1
- 'use client';
2
- import { jsxs as u, jsx as t } from "react/jsx-runtime";
3
- import { useState as C, useRef as $, useMemo as z, useCallback as q, useEffect as R } from "react";
4
- import { Badge as S } from "@nextblock-cms/ui/badge";
5
- import { Button as T } from "@nextblock-cms/ui/button";
6
- import { Input as V } from "@nextblock-cms/ui/input";
7
- import { Label as B } from "@nextblock-cms/ui/label";
8
- import { Tag as D, X as P } from "lucide-react";
9
- import { useTranslations as L } from "@nextblock-cms/utils";
10
- import { usePriceFormatter as M } from "../use-price-formatter.es.js";
11
- import { normalizeCouponCode as F } from "../coupons.es.js";
12
- import { useCart as w } from "../use-cart.es.js";
13
- import { getCouponQuoteAction as O } from "../server-actions/coupon-actions.es.js";
14
- function te({
15
- items: n,
16
- currencyCode: s,
17
- onQuoteChange: l,
18
- compact: p = !1
19
- }) {
20
- const y = w((e) => e.appliedCoupon), d = w((e) => e.setAppliedCoupon), c = w((e) => e.removeCoupon), { t: _ } = L(), I = M(), [N, k] = C(""), [a, m] = C(null), [h, i] = C(""), [A, j] = C(!1), f = $(null), E = z(
21
- () => n.map((e) => `${e.product_id}:${e.variant_id || "base"}:${e.quantity}`).sort().join("|"),
22
- [n]
23
- ), r = q((e, x) => {
24
- const v = _(e);
25
- return v === e ? x : v;
26
- }, [_]), b = q(
27
- (e) => `${F(e)}:${s}:${E}`,
28
- [E, s]
29
- ), g = q(async (e, x) => {
30
- const v = F(e);
31
- if (!v) {
32
- i(r("ecommerce.coupon_code_required", "Enter a coupon code."));
33
- return;
34
- }
35
- j(!0), i("");
36
- try {
37
- const o = await O({
38
- code: v,
39
- items: n,
40
- currencyCode: s
41
- });
42
- if (!o.success) {
43
- m(null), l?.(null), c?.(), i(o.errorKey ? r(o.errorKey, o.error) : o.error);
44
- return;
45
- }
46
- f.current = b(o.quote.code), m(o.quote), l?.(o.quote), x?.silent || (d?.({
47
- code: o.quote.code,
48
- couponId: o.quote.couponId
49
- }), k("")), x?.silent || i("");
50
- } catch (o) {
51
- console.error("Failed to validate coupon:", o), f.current = null, m(null), l?.(null), i(
52
- r("ecommerce.coupon_validation_failed", "Failed to validate coupon.")
53
- );
54
- } finally {
55
- j(!1);
56
- }
57
- }, [
58
- c,
59
- s,
60
- b,
61
- n,
62
- l,
63
- d,
64
- r
65
- ]);
66
- if (R(() => {
67
- if (!d || !c)
68
- return;
69
- if (!y || n.length === 0) {
70
- f.current = null, m(null), l?.(null);
71
- return;
72
- }
73
- const e = b(y.code);
74
- f.current !== e && (f.current = e, g(y.code, { silent: !0 }));
75
- }, [
76
- y?.code,
77
- g,
78
- c,
79
- b,
80
- n.length,
81
- l,
82
- d
83
- ]), !d || !c)
84
- return null;
85
- const K = () => {
86
- c(), m(null), l?.(null), i("");
87
- };
88
- return /* @__PURE__ */ u("div", { className: p ? "space-y-2" : "rounded-lg border bg-muted/10 p-4 space-y-3", children: [
89
- /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-3", children: [
90
- /* @__PURE__ */ u(B, { htmlFor: p ? "coupon-code-compact" : "coupon-code", className: "flex items-center gap-2 text-sm font-medium", children: [
91
- /* @__PURE__ */ t(D, { className: "h-4 w-4" }),
92
- r("ecommerce.coupon", "Coupon")
93
- ] }),
94
- a ? /* @__PURE__ */ u(S, { variant: "secondary", className: "gap-1", children: [
95
- a.code,
96
- /* @__PURE__ */ t(
97
- "button",
98
- {
99
- type: "button",
100
- onClick: K,
101
- "aria-label": r("ecommerce.remove_coupon", "Remove coupon {code}").replace("{code}", a.code),
102
- className: "-mr-1 inline-flex h-6 w-6 items-center justify-center rounded-full focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
103
- children: /* @__PURE__ */ t(P, { className: "h-3 w-3" })
104
- }
105
- )
106
- ] }) : null
107
- ] }),
108
- a ? /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-3 text-sm", children: [
109
- /* @__PURE__ */ t("span", { className: "min-w-0 truncate text-muted-foreground", children: a.name }),
110
- /* @__PURE__ */ t("span", { className: "shrink-0 font-medium tabular-nums text-emerald-600 dark:text-emerald-400", children: I(-a.discountTotal, s) })
111
- ] }) : /* @__PURE__ */ u("div", { className: "flex gap-2", children: [
112
- /* @__PURE__ */ t(
113
- V,
114
- {
115
- id: p ? "coupon-code-compact" : "coupon-code",
116
- name: "coupon",
117
- autoComplete: "off",
118
- autoCapitalize: "characters",
119
- spellCheck: !1,
120
- "aria-invalid": h ? !0 : void 0,
121
- "aria-describedby": h ? p ? "coupon-error-compact" : "coupon-error" : void 0,
122
- value: N,
123
- onChange: (e) => k(e.target.value),
124
- placeholder: r("ecommerce.coupon_placeholder", "SAVE10…"),
125
- className: "uppercase",
126
- onKeyDown: (e) => {
127
- e.key === "Enter" && !A && (e.preventDefault(), g(N));
128
- }
129
- }
130
- ),
131
- /* @__PURE__ */ t(
132
- T,
133
- {
134
- type: "button",
135
- variant: "outline",
136
- disabled: A || n.length === 0,
137
- onClick: () => {
138
- g(N);
139
- },
140
- children: A ? r("ecommerce.applying", "Applying…") : r("ecommerce.apply", "Apply")
141
- }
142
- )
143
- ] }),
144
- h ? /* @__PURE__ */ t("p", { id: p ? "coupon-error-compact" : "coupon-error", role: "alert", className: "text-xs text-destructive", children: h }) : null
145
- ] });
1
+ "use client";
2
+ import { useCart as e } from "../use-cart.es.js";
3
+ import { usePriceFormatter as t } from "../use-price-formatter.es.js";
4
+ import { normalizeCouponCode as n } from "../coupons.es.js";
5
+ import { getCouponQuoteAction as r } from "../server-actions/coupon-actions.es.js";
6
+ import { Badge as i } from "@nextblock-cms/ui/badge";
7
+ import { Button as a } from "@nextblock-cms/ui/button";
8
+ import { useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
9
+ import { Tag as d, X as f } from "lucide-react";
10
+ import { useTranslations as p } from "@nextblock-cms/utils";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import { Input as g } from "@nextblock-cms/ui/input";
13
+ import { Label as _ } from "@nextblock-cms/ui/label";
14
+ //#region libs/ecommerce/src/lib/components/CouponForm.tsx
15
+ function v({ items: v, currencyCode: y, onQuoteChange: b, compact: x = !1 }) {
16
+ let S = e((e) => e.appliedCoupon), C = e((e) => e.setAppliedCoupon), w = e((e) => e.removeCoupon), { t: T } = p(), E = t(), [D, O] = u(""), [k, A] = u(null), [j, M] = u(""), [N, P] = u(!1), F = l(null), I = c(() => v.map((e) => `${e.product_id}:${e.variant_id || "base"}:${e.quantity}`).sort().join("|"), [v]), L = o((e, t) => {
17
+ let n = T(e);
18
+ return n === e ? t : n;
19
+ }, [T]), R = o((e) => `${n(e)}:${y}:${I}`, [I, y]), z = o(async (e, t) => {
20
+ let i = n(e);
21
+ if (!i) {
22
+ M(L("ecommerce.coupon_code_required", "Enter a coupon code."));
23
+ return;
24
+ }
25
+ P(!0), M("");
26
+ try {
27
+ let e = await r({
28
+ code: i,
29
+ items: v,
30
+ currencyCode: y
31
+ });
32
+ if (!e.success) {
33
+ A(null), b?.(null), w?.(), M(e.errorKey ? L(e.errorKey, e.error) : e.error);
34
+ return;
35
+ }
36
+ F.current = R(e.quote.code), A(e.quote), b?.(e.quote), t?.silent || (C?.({
37
+ code: e.quote.code,
38
+ couponId: e.quote.couponId
39
+ }), O("")), t?.silent || M("");
40
+ } catch (e) {
41
+ console.error("Failed to validate coupon:", e), F.current = null, A(null), b?.(null), M(L("ecommerce.coupon_validation_failed", "Failed to validate coupon."));
42
+ } finally {
43
+ P(!1);
44
+ }
45
+ }, [
46
+ w,
47
+ y,
48
+ R,
49
+ v,
50
+ b,
51
+ C,
52
+ L
53
+ ]);
54
+ return s(() => {
55
+ if (!C || !w) return;
56
+ if (!S || v.length === 0) {
57
+ F.current = null, A(null), b?.(null);
58
+ return;
59
+ }
60
+ let e = R(S.code);
61
+ F.current !== e && (F.current = e, z(S.code, { silent: !0 }));
62
+ }, [
63
+ S?.code,
64
+ z,
65
+ w,
66
+ R,
67
+ v.length,
68
+ b,
69
+ C
70
+ ]), !C || !w ? null : /* @__PURE__ */ h("div", {
71
+ className: x ? "space-y-2" : "rounded-lg border bg-muted/10 p-4 space-y-3",
72
+ children: [
73
+ /* @__PURE__ */ h("div", {
74
+ className: "flex items-center justify-between gap-3",
75
+ children: [/* @__PURE__ */ h(_, {
76
+ htmlFor: x ? "coupon-code-compact" : "coupon-code",
77
+ className: "flex items-center gap-2 text-sm font-medium",
78
+ children: [/* @__PURE__ */ m(d, { className: "h-4 w-4" }), L("ecommerce.coupon", "Coupon")]
79
+ }), k ? /* @__PURE__ */ h(i, {
80
+ variant: "secondary",
81
+ className: "gap-1",
82
+ children: [k.code, /* @__PURE__ */ m("button", {
83
+ type: "button",
84
+ onClick: () => {
85
+ w(), A(null), b?.(null), M("");
86
+ },
87
+ "aria-label": L("ecommerce.remove_coupon", "Remove coupon {code}").replace("{code}", k.code),
88
+ className: "-mr-1 inline-flex h-6 w-6 items-center justify-center rounded-full focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
89
+ children: /* @__PURE__ */ m(f, { className: "h-3 w-3" })
90
+ })]
91
+ }) : null]
92
+ }),
93
+ k ? /* @__PURE__ */ h("div", {
94
+ className: "flex items-center justify-between gap-3 text-sm",
95
+ children: [/* @__PURE__ */ m("span", {
96
+ className: "min-w-0 truncate text-muted-foreground",
97
+ children: k.name
98
+ }), /* @__PURE__ */ m("span", {
99
+ className: "shrink-0 font-medium tabular-nums text-emerald-600 dark:text-emerald-400",
100
+ children: E(-k.discountTotal, y)
101
+ })]
102
+ }) : /* @__PURE__ */ h("div", {
103
+ className: "flex gap-2",
104
+ children: [/* @__PURE__ */ m(g, {
105
+ id: x ? "coupon-code-compact" : "coupon-code",
106
+ name: "coupon",
107
+ autoComplete: "off",
108
+ autoCapitalize: "characters",
109
+ spellCheck: !1,
110
+ "aria-invalid": j ? !0 : void 0,
111
+ "aria-describedby": j ? x ? "coupon-error-compact" : "coupon-error" : void 0,
112
+ value: D,
113
+ onChange: (e) => O(e.target.value),
114
+ placeholder: L("ecommerce.coupon_placeholder", "SAVE10…"),
115
+ className: "uppercase",
116
+ onKeyDown: (e) => {
117
+ e.key === "Enter" && !N && (e.preventDefault(), z(D));
118
+ }
119
+ }), /* @__PURE__ */ m(a, {
120
+ type: "button",
121
+ variant: "outline",
122
+ disabled: N || v.length === 0,
123
+ onClick: () => void z(D),
124
+ children: N ? L("ecommerce.applying", "Applying…") : L("ecommerce.apply", "Apply")
125
+ })]
126
+ }),
127
+ j ? /* @__PURE__ */ m("p", {
128
+ id: x ? "coupon-error-compact" : "coupon-error",
129
+ role: "alert",
130
+ className: "text-xs text-destructive",
131
+ children: j
132
+ }) : null
133
+ ]
134
+ });
146
135
  }
147
- export {
148
- te as CouponForm
149
- };
136
+ //#endregion
137
+ export { v as CouponForm };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("@nextblock-cms/ui/select"),o=require("@nextblock-cms/utils"),i=require("../CurrencyProvider.cjs.js");function a(){const{activeCurrencyCode:t,currencies:n,setActiveCurrencyCode:u}=i.useCurrency(),{t:l}=o.useTranslations(),s=l("ecommerce.currency")==="ecommerce.currency"?"Currency":l("ecommerce.currency");return n.length<=1?null:e.jsxs(r.Select,{value:t,onValueChange:u,children:[e.jsx(r.SelectTrigger,{"aria-label":s,className:"h-9 w-[88px] text-xs font-semibold",children:e.jsx(r.SelectValue,{placeholder:t})}),e.jsx(r.SelectContent,{children:n.map(c=>e.jsx(r.SelectItem,{value:c.code,children:c.code},c.code))})]})}exports.CurrencySwitcher=a;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../CurrencyProvider.cjs.js");let t=require("@nextblock-cms/utils"),n=require("react/jsx-runtime"),r=require("@nextblock-cms/ui/select");function i(){let{activeCurrencyCode:i,currencies:a,setActiveCurrencyCode:o}=e.useCurrency(),{t:s}=(0,t.useTranslations)(),c=s(`ecommerce.currency`)===`ecommerce.currency`?`Currency`:s(`ecommerce.currency`);return a.length<=1?null:(0,n.jsxs)(r.Select,{value:i,onValueChange:o,children:[(0,n.jsx)(r.SelectTrigger,{"aria-label":c,className:`h-9 w-[88px] text-xs font-semibold`,children:(0,n.jsx)(r.SelectValue,{placeholder:i})}),(0,n.jsx)(r.SelectContent,{children:a.map(e=>(0,n.jsx)(r.SelectItem,{value:e.code,children:e.code},e.code))})]})}exports.CurrencySwitcher=i;
@@ -1 +1 @@
1
- export declare function CurrencySwitcher(): import("react").JSX.Element | null;
1
+ export declare function CurrencySwitcher(): import('react').JSX.Element | null;
@@ -1,19 +1,23 @@
1
- 'use client';
2
- import { jsxs as i, jsx as e } from "react/jsx-runtime";
3
- import { Select as m, SelectTrigger as u, SelectValue as a, SelectContent as s, SelectItem as d } from "@nextblock-cms/ui/select";
4
- import { useTranslations as h } from "@nextblock-cms/utils";
5
- import { useCurrency as C } from "../CurrencyProvider.es.js";
6
- function S() {
7
- const {
8
- activeCurrencyCode: c,
9
- currencies: t,
10
- setActiveCurrencyCode: o
11
- } = C(), { t: n } = h(), l = n("ecommerce.currency") === "ecommerce.currency" ? "Currency" : n("ecommerce.currency");
12
- return t.length <= 1 ? null : /* @__PURE__ */ i(m, { value: c, onValueChange: o, children: [
13
- /* @__PURE__ */ e(u, { "aria-label": l, className: "h-9 w-[88px] text-xs font-semibold", children: /* @__PURE__ */ e(a, { placeholder: c }) }),
14
- /* @__PURE__ */ e(s, { children: t.map((r) => /* @__PURE__ */ e(d, { value: r.code, children: r.code }, r.code)) })
15
- ] });
1
+ "use client";
2
+ import { useCurrency as e } from "../CurrencyProvider.es.js";
3
+ import { useTranslations as t } from "@nextblock-cms/utils";
4
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
+ import { Select as i, SelectContent as a, SelectItem as o, SelectTrigger as s, SelectValue as c } from "@nextblock-cms/ui/select";
6
+ //#region libs/ecommerce/src/lib/components/CurrencySwitcher.tsx
7
+ function l() {
8
+ let { activeCurrencyCode: l, currencies: u, setActiveCurrencyCode: d } = e(), { t: f } = t(), p = f("ecommerce.currency") === "ecommerce.currency" ? "Currency" : f("ecommerce.currency");
9
+ return u.length <= 1 ? null : /* @__PURE__ */ r(i, {
10
+ value: l,
11
+ onValueChange: d,
12
+ children: [/* @__PURE__ */ n(s, {
13
+ "aria-label": p,
14
+ className: "h-9 w-[88px] text-xs font-semibold",
15
+ children: /* @__PURE__ */ n(c, { placeholder: l })
16
+ }), /* @__PURE__ */ n(a, { children: u.map((e) => /* @__PURE__ */ n(o, {
17
+ value: e.code,
18
+ children: e.code
19
+ }, e.code)) })]
20
+ });
16
21
  }
17
- export {
18
- S as CurrencySwitcher
19
- };
22
+ //#endregion
23
+ export { l as CurrencySwitcher };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),z=require("react-hook-form"),M=require("./AccountNavigationMenu.cjs.js"),w=require("@nextblock-cms/ui/avatar"),W=require("@nextblock-cms/ui/button"),i=require("@nextblock-cms/ui/card"),H=require("@nextblock-cms/ui/checkbox"),n=require("@nextblock-cms/ui/input"),a=require("@nextblock-cms/ui/label"),d=require("@nextblock-cms/ui/select"),O=require("@nextblock-cms/ui/separator"),G=require("../server-actions/customer-actions.cjs.js"),f=require("../customer.cjs.js"),J=require("@nextblock-cms/db"),y=require("lucide-react"),R=require("@nextblock-cms/utils"),T=require("../countries.cjs.js");function K(s){return s?s.startsWith("http")?s:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${s}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${s}`:s:null}function $(s){return{company_name:s?.company_name||"",recipient_name:s?.recipient_name||"",line1:s?.line1||"",line2:s?.line2||"",city:s?.city||"",state:s?.state||"",postal_code:s?.postal_code||"",country_code:T.normalizeCountryCode(s?.country_code)||"CA"}}function q({prefix:s,title:_,register:c}){const{t}=R.useTranslations(),v=t("company_name")==="company_name"?"Company name":t("company_name");return e.jsxs("div",{className:"space-y-4 rounded-xl border p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:_}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("profile_address_defaults_help")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-company_name`,children:v}),e.jsx(n.Input,{id:`${s}-company_name`,...c(`${s}.company_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-recipient_name`,children:t("full_name")}),e.jsx(n.Input,{id:`${s}-recipient_name`,...c(`${s}.recipient_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-country_code`,children:t("country")}),e.jsx("select",{id:`${s}-country_code`,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",...c(`${s}.country_code`),children:T.countries.map(o=>e.jsx("option",{value:o.code,children:o.name},o.code))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-line1`,children:t("address_line_1")}),e.jsx(n.Input,{id:`${s}-line1`,...c(`${s}.line1`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-line2`,children:t("address_line_2")}),e.jsx(n.Input,{id:`${s}-line2`,...c(`${s}.line2`)})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-city`,children:t("city")}),e.jsx(n.Input,{id:`${s}-city`,...c(`${s}.city`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-state`,children:t("state_province")}),e.jsx(n.Input,{id:`${s}-state`,...c(`${s}.state`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-postal_code`,children:t("postal_zip_code")}),e.jsx(n.Input,{id:`${s}-postal_code`,...c(`${s}.postal_code`)})]})]})]})}function Q({initialData:s,MediaPickerComponent:_,isAdmin:c,email:t,accountLinks:v,onAction:o,initialSuccessMessage:x,lockRole:A,lockRoleReason:B}){const{t:l}=R.useTranslations(),[F,L]=b.useState(!1),[N,C]=b.useState(x?{type:"success",text:x}:null),P=s?.use_billing_for_shipping??(!s?.shipping_address||f.addressesMatch(s?.billing_address,s?.shipping_address)),{register:m,handleSubmit:k,setValue:g,getValues:S,watch:u,reset:I}=z.useForm({defaultValues:{full_name:s?.full_name||"",avatar_url:s?.avatar_url||"",website:s?.website||"",phone:s?.phone||"",role:s?.role,use_billing_for_shipping:P,billing_address:$(s?.billing_address),shipping_address:$(s?.shipping_address)}});b.useEffect(()=>{s&&I({full_name:s.full_name||"",avatar_url:s.avatar_url||"",website:s.website||"",phone:s.phone||"",role:s.role,use_billing_for_shipping:s.use_billing_for_shipping??(!s.shipping_address||f.addressesMatch(s.billing_address,s.shipping_address)),billing_address:$(s.billing_address),shipping_address:$(s.shipping_address)})},[s,I]),b.useEffect(()=>{x&&C({type:"success",text:x})},[x]),b.useEffect(()=>{const r=J.createClient();(async()=>{const{data:{user:j}}=await r.auth.getUser();j&&!S("full_name")&&j.user_metadata?.full_name&&g("full_name",j.user_metadata.full_name)})()},[S,g]);const V=r=>{const p=K(r?.object_key??r?.file_path);p&&g("avatar_url",p)},X=async r=>{L(!0),C(null);const p=f.normalizeCustomerAddress(r.billing_address)??f.emptyCustomerAddress(),j=r.use_billing_for_shipping?p:f.normalizeCustomerAddress(r.shipping_address);try{const h={...r,billing_address:p,shipping_address:j};if(o){const U=await o(h);if(U?.error)throw new Error(U.error)}else await G.updateProfile(h);C({type:"success",text:l("profile_updated_success")})}catch(h){if(h.message==="NEXT_REDIRECT"||h.message?.includes("NEXT_REDIRECT"))return;console.error(h),C({type:"error",text:l("profile_update_failed")})}finally{L(!1)}},E=u("use_billing_for_shipping");return e.jsxs("div",{className:"grid gap-6 md:grid-cols-12 max-w-5xl mx-auto",children:[e.jsxs(i.Card,{className:"md:col-span-4 h-fit",children:[e.jsx(i.CardHeader,{children:e.jsx(i.CardTitle,{className:"text-xl",children:l("public_profile")})}),e.jsxs(i.CardContent,{className:"flex flex-col items-center text-center space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs(w.Avatar,{className:"h-32 w-32 border-4 border-muted",children:[e.jsx(w.AvatarImage,{src:u("avatar_url")||void 0,alt:u("full_name")||"",className:"object-cover"}),e.jsx(w.AvatarFallback,{className:"text-4xl bg-secondary",children:u("full_name")?.charAt(0)?.toUpperCase()||e.jsx(y.User,{className:"h-12 w-12"})})]}),_&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100 transition-opacity bg-black/40 rounded-full cursor-pointer",children:e.jsx(_,{triggerLabel:e.jsxs(e.Fragment,{children:[e.jsx(y.Upload,{className:"h-6 w-6 text-white"}),e.jsx("span",{className:"sr-only",children:l("profile_change_avatar")==="profile_change_avatar"?"Change profile picture":l("profile_change_avatar")})]}),triggerVariant:"ghost",title:l("customer_profile"),onSelect:V,accept:r=>r.file_type.startsWith("image/"),hideTrigger:!1})})]}),!_&&e.jsxs("div",{className:"w-full",children:[e.jsx(a.Label,{htmlFor:"avatar_url",className:"sr-only",children:l("avatar_url")}),e.jsx(n.Input,{id:"avatar_url",type:"url",autoComplete:"off",...m("avatar_url"),placeholder:"https://…",className:"mt-2"})]}),e.jsxs("div",{className:"w-full space-y-1 text-left mt-4",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:l("identity")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-semibold text-lg",children:u("full_name")||l("full_name")})})]}),v?.length?e.jsx(M.AccountNavigationMenu,{links:v,className:"mt-2 text-left"}):null]})]}),e.jsx(i.Card,{className:"md:col-span-8",children:e.jsxs("form",{onSubmit:k(X),children:[e.jsx(i.CardHeader,{children:e.jsx(i.CardTitle,{children:l("details")})}),e.jsxs(i.CardContent,{className:"space-y-6",children:[t&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"email",children:[l("email")==="email"?"Email":l("email")," (",l("read_only")==="read_only"?"read-only":l("read_only"),")"]}),e.jsx(n.Input,{id:"email",value:t,readOnly:!0,disabled:!0,className:"bg-muted/50"})]}),e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:l("profile_basic_info_help")}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"full_name",className:"flex items-center gap-2",children:[e.jsx(y.User,{className:"h-4 w-4"})," ",l("full_name")]}),e.jsx(n.Input,{id:"full_name",autoComplete:"name",...m("full_name")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"phone",className:"flex items-center gap-2",children:[e.jsx(y.Phone,{className:"h-4 w-4"})," ",l("phone_number")]}),e.jsx(n.Input,{id:"phone",type:"tel",inputMode:"tel",autoComplete:"tel",...m("phone")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"website",className:"flex items-center gap-2",children:[e.jsx(y.Globe,{className:"h-4 w-4"})," ",l("website")]}),e.jsx(n.Input,{id:"website",type:"url",autoComplete:"url",...m("website"),placeholder:"https://example.com"})]}),e.jsx(O.Separator,{className:"my-2"}),e.jsx(q,{prefix:"billing_address",title:l("billing_address"),register:m}),e.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-4",children:[e.jsx(H.Checkbox,{id:"use_billing_for_shipping",checked:!!E,onCheckedChange:r=>g("use_billing_for_shipping",!!r,{shouldDirty:!0})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{htmlFor:"use_billing_for_shipping",className:"cursor-pointer",children:l("use_billing_for_shipping")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("profile_use_billing_for_shipping_help")})]})]}),!E&&e.jsx(q,{prefix:"shipping_address",title:l("shipping_address"),register:m}),N&&e.jsx("div",{role:N.type==="error"?"alert":"status",className:`mt-4 rounded-xl border p-4 text-sm ${N.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-red-200 bg-red-50 text-red-700"}`,children:N.text}),c&&e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Admin Settings"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(a.Label,{htmlFor:"role",children:"Role"}),e.jsxs(d.Select,{value:u("role")||"USER",onValueChange:r=>g("role",r),disabled:A,children:[e.jsx(d.SelectTrigger,{children:e.jsx(d.SelectValue,{placeholder:"Select role"})}),e.jsxs(d.SelectContent,{children:[e.jsx(d.SelectItem,{value:"USER",children:"User"}),e.jsx(d.SelectItem,{value:"WRITER",children:"Writer"}),e.jsx(d.SelectItem,{value:"ADMIN",children:"Admin"})]})]}),A&&e.jsx("p",{className:"text-xs text-muted-foreground",children:B||"This is the only Admin account, so its role can't be changed. Promote another user to Admin first."})]})]})]}),e.jsx(i.CardFooter,{className:"flex justify-end",children:e.jsx(W.Button,{type:"submit",disabled:F,size:"lg",children:l(F?"saving":"save_changes")})})]})})]})}exports.CustomerProfileForm=Q;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs.js"),t=require("../countries.cjs.js"),n=require("../customer.cjs.js"),r=require("./AccountNavigationMenu.cjs.js"),i=require("../server-actions/customer-actions.cjs.js");let a=require("@nextblock-cms/ui/button"),o=require("react");o=e.__toESM(o,1);let s=require("lucide-react"),c=require("@nextblock-cms/utils"),l=require("react/jsx-runtime"),u=require("@nextblock-cms/ui/input"),d=require("@nextblock-cms/ui/label"),f=require("@nextblock-cms/ui/card"),p=require("@nextblock-cms/ui/checkbox"),m=require("@nextblock-cms/ui/separator"),h=require("@nextblock-cms/ui/select"),g=require("react-hook-form"),_=require("@nextblock-cms/ui/avatar"),v=require("@nextblock-cms/db");function y(e){return e?e.startsWith(`http`)?e:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}`:e:null}function b(e){return{company_name:e?.company_name||``,recipient_name:e?.recipient_name||``,line1:e?.line1||``,line2:e?.line2||``,city:e?.city||``,state:e?.state||``,postal_code:e?.postal_code||``,country_code:t.normalizeCountryCode(e?.country_code)||`CA`}}function x({prefix:e,title:n,register:r}){let{t:i}=(0,c.useTranslations)(),a=i(`company_name`)===`company_name`?`Company name`:i(`company_name`);return(0,l.jsxs)(`div`,{className:`space-y-4 rounded-xl border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{className:`text-lg font-medium`,children:n}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`profile_address_defaults_help`)})]}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-company_name`,children:a}),(0,l.jsx)(u.Input,{id:`${e}-company_name`,...r(`${e}.company_name`)})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-recipient_name`,children:i(`full_name`)}),(0,l.jsx)(u.Input,{id:`${e}-recipient_name`,...r(`${e}.recipient_name`)})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-country_code`,children:i(`country`)}),(0,l.jsx)(`select`,{id:`${e}-country_code`,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,...r(`${e}.country_code`),children:t.countries.map(e=>(0,l.jsx)(`option`,{value:e.code,children:e.name},e.code))})]})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-line1`,children:i(`address_line_1`)}),(0,l.jsx)(u.Input,{id:`${e}-line1`,...r(`${e}.line1`)})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-line2`,children:i(`address_line_2`)}),(0,l.jsx)(u.Input,{id:`${e}-line2`,...r(`${e}.line2`)})]}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-city`,children:i(`city`)}),(0,l.jsx)(u.Input,{id:`${e}-city`,...r(`${e}.city`)})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-state`,children:i(`state_province`)}),(0,l.jsx)(u.Input,{id:`${e}-state`,...r(`${e}.state`)})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`${e}-postal_code`,children:i(`postal_zip_code`)}),(0,l.jsx)(u.Input,{id:`${e}-postal_code`,...r(`${e}.postal_code`)})]})]})]})}function S({initialData:e,MediaPickerComponent:t,isAdmin:S,email:C,accountLinks:w,onAction:T,initialSuccessMessage:E,lockRole:D,lockRoleReason:O}){let{t:k}=(0,c.useTranslations)(),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(E?{type:`success`,text:E}:null),P=e?.use_billing_for_shipping??(!e?.shipping_address||n.addressesMatch(e?.billing_address,e?.shipping_address)),{register:F,handleSubmit:I,setValue:L,getValues:R,watch:z,reset:B}=(0,g.useForm)({defaultValues:{full_name:e?.full_name||``,avatar_url:e?.avatar_url||``,website:e?.website||``,phone:e?.phone||``,role:e?.role,use_billing_for_shipping:P,billing_address:b(e?.billing_address),shipping_address:b(e?.shipping_address)}});o.default.useEffect(()=>{e&&B({full_name:e.full_name||``,avatar_url:e.avatar_url||``,website:e.website||``,phone:e.phone||``,role:e.role,use_billing_for_shipping:e.use_billing_for_shipping??(!e.shipping_address||n.addressesMatch(e.billing_address,e.shipping_address)),billing_address:b(e.billing_address),shipping_address:b(e.shipping_address)})},[e,B]),o.default.useEffect(()=>{E&&N({type:`success`,text:E})},[E]),o.default.useEffect(()=>{let e=(0,v.createClient)();(async()=>{let{data:{user:t}}=await e.auth.getUser();t&&!R(`full_name`)&&t.user_metadata?.full_name&&L(`full_name`,t.user_metadata.full_name)})()},[R,L]);let V=e=>{let t=y(e?.object_key??e?.file_path);t&&L(`avatar_url`,t)},H=async e=>{j(!0),N(null);let t=n.normalizeCustomerAddress(e.billing_address)??n.emptyCustomerAddress(),r=e.use_billing_for_shipping?t:n.normalizeCustomerAddress(e.shipping_address);try{let n={...e,billing_address:t,shipping_address:r};if(T){let e=await T(n);if(e?.error)throw Error(e.error)}else await i.updateProfile(n);N({type:`success`,text:k(`profile_updated_success`)})}catch(e){if(e.message===`NEXT_REDIRECT`||e.message?.includes(`NEXT_REDIRECT`))return;console.error(e),N({type:`error`,text:k(`profile_update_failed`)})}finally{j(!1)}},U=z(`use_billing_for_shipping`);return(0,l.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-12 max-w-5xl mx-auto`,children:[(0,l.jsxs)(f.Card,{className:`md:col-span-4 h-fit`,children:[(0,l.jsx)(f.CardHeader,{children:(0,l.jsx)(f.CardTitle,{className:`text-xl`,children:k(`public_profile`)})}),(0,l.jsxs)(f.CardContent,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,l.jsxs)(`div`,{className:`relative group`,children:[(0,l.jsxs)(_.Avatar,{className:`h-32 w-32 border-4 border-muted`,children:[(0,l.jsx)(_.AvatarImage,{src:z(`avatar_url`)||void 0,alt:z(`full_name`)||``,className:`object-cover`}),(0,l.jsx)(_.AvatarFallback,{className:`text-4xl bg-secondary`,children:z(`full_name`)?.charAt(0)?.toUpperCase()||(0,l.jsx)(s.User,{className:`h-12 w-12`})})]}),t&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100 transition-opacity bg-black/40 rounded-full cursor-pointer`,children:(0,l.jsx)(t,{triggerLabel:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Upload,{className:`h-6 w-6 text-white`}),(0,l.jsx)(`span`,{className:`sr-only`,children:k(`profile_change_avatar`)===`profile_change_avatar`?`Change profile picture`:k(`profile_change_avatar`)})]}),triggerVariant:`ghost`,title:k(`customer_profile`),onSelect:V,accept:e=>e.file_type.startsWith(`image/`),hideTrigger:!1})})]}),!t&&(0,l.jsxs)(`div`,{className:`w-full`,children:[(0,l.jsx)(d.Label,{htmlFor:`avatar_url`,className:`sr-only`,children:k(`avatar_url`)}),(0,l.jsx)(u.Input,{id:`avatar_url`,type:`url`,autoComplete:`off`,...F(`avatar_url`),placeholder:`https://…`,className:`mt-2`})]}),(0,l.jsxs)(`div`,{className:`w-full space-y-1 text-left mt-4`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:k(`identity`)}),(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,l.jsx)(`span`,{className:`font-semibold text-lg`,children:z(`full_name`)||k(`full_name`)})})]}),w?.length?(0,l.jsx)(r.AccountNavigationMenu,{links:w,className:`mt-2 text-left`}):null]})]}),(0,l.jsx)(f.Card,{className:`md:col-span-8`,children:(0,l.jsxs)(`form`,{onSubmit:I(H),children:[(0,l.jsx)(f.CardHeader,{children:(0,l.jsx)(f.CardTitle,{children:k(`details`)})}),(0,l.jsxs)(f.CardContent,{className:`space-y-6`,children:[C&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(d.Label,{htmlFor:`email`,children:[k(`email`)===`email`?`Email`:k(`email`),` (`,k(`read_only`)===`read_only`?`read-only`:k(`read_only`),`)`]}),(0,l.jsx)(u.Input,{id:`email`,value:C,readOnly:!0,disabled:!0,className:`bg-muted/50`})]}),(0,l.jsx)(`div`,{className:`rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground`,children:k(`profile_basic_info_help`)}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(d.Label,{htmlFor:`full_name`,className:`flex items-center gap-2`,children:[(0,l.jsx)(s.User,{className:`h-4 w-4`}),` `,k(`full_name`)]}),(0,l.jsx)(u.Input,{id:`full_name`,autoComplete:`name`,...F(`full_name`)})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(d.Label,{htmlFor:`phone`,className:`flex items-center gap-2`,children:[(0,l.jsx)(s.Phone,{className:`h-4 w-4`}),` `,k(`phone_number`)]}),(0,l.jsx)(u.Input,{id:`phone`,type:`tel`,inputMode:`tel`,autoComplete:`tel`,...F(`phone`)})]})]}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(d.Label,{htmlFor:`website`,className:`flex items-center gap-2`,children:[(0,l.jsx)(s.Globe,{className:`h-4 w-4`}),` `,k(`website`)]}),(0,l.jsx)(u.Input,{id:`website`,type:`url`,autoComplete:`url`,...F(`website`),placeholder:`https://example.com`})]}),(0,l.jsx)(m.Separator,{className:`my-2`}),(0,l.jsx)(x,{prefix:`billing_address`,title:k(`billing_address`),register:F}),(0,l.jsxs)(`div`,{className:`flex items-center space-x-3 rounded-lg border p-4`,children:[(0,l.jsx)(p.Checkbox,{id:`use_billing_for_shipping`,checked:!!U,onCheckedChange:e=>L(`use_billing_for_shipping`,!!e,{shouldDirty:!0})}),(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(d.Label,{htmlFor:`use_billing_for_shipping`,className:`cursor-pointer`,children:k(`use_billing_for_shipping`)}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k(`profile_use_billing_for_shipping_help`)})]})]}),!U&&(0,l.jsx)(x,{prefix:`shipping_address`,title:k(`shipping_address`),register:F}),M&&(0,l.jsx)(`div`,{role:M.type===`error`?`alert`:`status`,className:`mt-4 rounded-xl border p-4 text-sm ${M.type===`success`?`border-emerald-200 bg-emerald-50 text-emerald-700`:`border-red-200 bg-red-50 text-red-700`}`,children:M.text}),S&&(0,l.jsxs)(`div`,{className:`border-t pt-4 mt-4`,children:[(0,l.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Admin Settings`}),(0,l.jsxs)(`div`,{className:`grid gap-2`,children:[(0,l.jsx)(d.Label,{htmlFor:`role`,children:`Role`}),(0,l.jsxs)(h.Select,{value:z(`role`)||`USER`,onValueChange:e=>L(`role`,e),disabled:D,children:[(0,l.jsx)(h.SelectTrigger,{children:(0,l.jsx)(h.SelectValue,{placeholder:`Select role`})}),(0,l.jsxs)(h.SelectContent,{children:[(0,l.jsx)(h.SelectItem,{value:`USER`,children:`User`}),(0,l.jsx)(h.SelectItem,{value:`WRITER`,children:`Writer`}),(0,l.jsx)(h.SelectItem,{value:`ADMIN`,children:`Admin`})]})]}),D&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:O||`This is the only Admin account, so its role can't be changed. Promote another user to Admin first.`})]})]})]}),(0,l.jsx)(f.CardFooter,{className:`flex justify-end`,children:(0,l.jsx)(a.Button,{type:`submit`,disabled:A,size:`lg`,children:k(A?`saving`:`save_changes`)})})]})})]})}exports.CustomerProfileForm=S;