@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.
- package/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use
|
|
2
|
-
`||
|
|
3
|
-
`&&(
|
|
1
|
+
"use server";const e=require("../../../../shared-inventory.cjs.js");let t=require("@nextblock-cms/db/server"),n=require("next/cache");function r(e){let t=[],n=[],r=``,i=!1;for(let a=0;a<e.length;a+=1){let o=e[a],s=e[a+1];if(o===`"`){i&&s===`"`?(r+=`"`,a+=1):i=!i;continue}if(o===`,`&&!i){n.push(r),r=``;continue}if((o===`
|
|
2
|
+
`||o===`\r`)&&!i){o===`\r`&&s===`
|
|
3
|
+
`&&(a+=1),(r.length>0||n.length>0)&&(n.push(r),t.push(n)),n=[],r=``;continue}r+=o}return(r.length>0||n.length>0)&&(n.push(r),t.push(n)),t.filter(e=>e.some(e=>e.trim().length>0))}function i(e){return e.sku}async function a(t){try{let r=Math.max(0,Math.trunc(t.stock));return await e.setSharedInventoryQuantity({sku:t.sku,stock:r}),(0,n.revalidatePath)(`/cms/products`),(0,n.revalidatePath)(`/cms/products/inventory`),{success:!0,itemKey:i(t),stock:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to update inventory.`}}}async function o(i){try{let a=r(i);if(a.length<2)return{success:!1,error:`The CSV file is empty.`};let[o,...s]=a,c=o.map(e=>e.trim().toLowerCase()),l=c.indexOf(`sku`),u=c.indexOf(`stock`);if(l===-1||u===-1)return{success:!1,error:`The CSV format is invalid. Please import a file exported from the Inventory page.`};let d=(0,t.getServiceRoleSupabaseClient)(),f=0;for(let t of s){let n=(t[l]||``).trim(),r=Number.parseInt((t[u]||``).trim(),10);if(n){if(!Number.isFinite(r)||r<0)return{success:!1,error:`Invalid stock value for SKU "${n}".`};await e.setSharedInventoryQuantity({sku:n,stock:r},d),f+=1}}let p=await e.getInventoryItems(d);return(0,n.revalidatePath)(`/cms/products`),(0,n.revalidatePath)(`/cms/products/inventory`),{success:!0,updatedCount:f,items:p}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to import inventory CSV.`}}}exports.importInventoryCsvAction=o,exports.updateInventoryQuantityAction=a;
|
|
@@ -1,95 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { getServiceRoleSupabaseClient as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return (r.length > 0 || o.length > 0) && (o.push(r), e.push(o)), e.filter((s) => s.some((n) => n.trim().length > 0));
|
|
1
|
+
"use server";
|
|
2
|
+
import { getInventoryItems as e, setSharedInventoryQuantity as t } from "../../../../shared-inventory.es.js";
|
|
3
|
+
import { getServiceRoleSupabaseClient as n } from "@nextblock-cms/db/server";
|
|
4
|
+
import { revalidatePath as r } from "next/cache";
|
|
5
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/inventory/actions.ts
|
|
6
|
+
function i(e) {
|
|
7
|
+
let t = [], n = [], r = "", i = !1;
|
|
8
|
+
for (let a = 0; a < e.length; a += 1) {
|
|
9
|
+
let o = e[a], s = e[a + 1];
|
|
10
|
+
if (o === "\"") {
|
|
11
|
+
i && s === "\"" ? (r += "\"", a += 1) : i = !i;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (o === "," && !i) {
|
|
15
|
+
n.push(r), r = "";
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if ((o === "\n" || o === "\r") && !i) {
|
|
19
|
+
o === "\r" && s === "\n" && (a += 1), (r.length > 0 || n.length > 0) && (n.push(r), t.push(n)), n = [], r = "";
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
r += o;
|
|
23
|
+
}
|
|
24
|
+
return (r.length > 0 || n.length > 0) && (n.push(r), t.push(n)), t.filter((e) => e.some((e) => e.trim().length > 0));
|
|
27
25
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
26
|
+
function a(e) {
|
|
27
|
+
return e.sku;
|
|
30
28
|
}
|
|
31
|
-
async function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
async function o(e) {
|
|
30
|
+
try {
|
|
31
|
+
let n = Math.max(0, Math.trunc(e.stock));
|
|
32
|
+
return await t({
|
|
33
|
+
sku: e.sku,
|
|
34
|
+
stock: n
|
|
35
|
+
}), r("/cms/products"), r("/cms/products/inventory"), {
|
|
36
|
+
success: !0,
|
|
37
|
+
itemKey: a(e),
|
|
38
|
+
stock: n
|
|
39
|
+
};
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return {
|
|
42
|
+
success: !1,
|
|
43
|
+
error: e instanceof Error ? e.message : "Failed to update inventory."
|
|
44
|
+
};
|
|
45
|
+
}
|
|
48
46
|
}
|
|
49
|
-
async function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
success: !1,
|
|
88
|
-
error: e instanceof Error ? e.message : "Failed to import inventory CSV."
|
|
89
|
-
};
|
|
90
|
-
}
|
|
47
|
+
async function s(a) {
|
|
48
|
+
try {
|
|
49
|
+
let o = i(a);
|
|
50
|
+
if (o.length < 2) return {
|
|
51
|
+
success: !1,
|
|
52
|
+
error: "The CSV file is empty."
|
|
53
|
+
};
|
|
54
|
+
let [s, ...c] = o, l = s.map((e) => e.trim().toLowerCase()), u = l.indexOf("sku"), d = l.indexOf("stock");
|
|
55
|
+
if (u === -1 || d === -1) return {
|
|
56
|
+
success: !1,
|
|
57
|
+
error: "The CSV format is invalid. Please import a file exported from the Inventory page."
|
|
58
|
+
};
|
|
59
|
+
let f = n(), p = 0;
|
|
60
|
+
for (let e of c) {
|
|
61
|
+
let n = (e[u] || "").trim(), r = Number.parseInt((e[d] || "").trim(), 10);
|
|
62
|
+
if (n) {
|
|
63
|
+
if (!Number.isFinite(r) || r < 0) return {
|
|
64
|
+
success: !1,
|
|
65
|
+
error: `Invalid stock value for SKU "${n}".`
|
|
66
|
+
};
|
|
67
|
+
await t({
|
|
68
|
+
sku: n,
|
|
69
|
+
stock: r
|
|
70
|
+
}, f), p += 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let m = await e(f);
|
|
74
|
+
return r("/cms/products"), r("/cms/products/inventory"), {
|
|
75
|
+
success: !0,
|
|
76
|
+
updatedCount: p,
|
|
77
|
+
items: m
|
|
78
|
+
};
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return {
|
|
81
|
+
success: !1,
|
|
82
|
+
error: e instanceof Error ? e.message : "Failed to import inventory CSV."
|
|
83
|
+
};
|
|
84
|
+
}
|
|
91
85
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
C as updateInventoryQuantityAction
|
|
95
|
-
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { s as importInventoryCsvAction, o as updateInventoryQuantityAction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../../../../currency.cjs.js"),t=require("../../../../variation-utils.cjs.js"),n=require("../actions.cjs.js"),r=require("../server-actions.cjs.js"),i=require("../components/ProductForm.cjs.js"),a=require("../../payments/queries.cjs.js");let o=require("@nextblock-cms/utils"),s=require("react/jsx-runtime"),c=require("@nextblock-cms/db/server");async function l({mediaPickerNode:l,availableLanguagesProp:u,translationGroupId:d,targetLanguageId:f,initialData:p}){let[m,h,g,_]=await Promise.all([a.getEnabledPaymentProviders(),a.getStoreConfigStatus(),n.getGlobalProductAttributes(),(0,c.getServiceRoleSupabaseClient)().from(`currencies`).select(`code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount`).eq(`is_active`,!0).order(`code`,{ascending:!0}).then(e=>e.data||[])]),v=(_||[]).map(t=>e.normalizeCurrencyRecord(t)),y=(g||[]).map(e=>({id:e.id,name:e.name,name_translations:e.name_translations||{},slug:e.slug,terms:(e.product_attribute_terms||[]).map(e=>({...e,value_translations:e.value_translations||{}}))})),b=u.find(e=>e.id===p?.language_id)?.code||u.find(e=>e.id===(f?parseInt(f,10):void 0))?.code||u.find(e=>e.is_default)?.code,{attributes:x,variants:S}=t.mapRawVariantRelations(p?.product_variants||[],b),C=p&&{...p,variation_attributes:p.variation_attributes||x.map(e=>({attribute_id:e.id,term_ids:e.terms.map(e=>e.id)})),variants:p.variants||S.map(e=>({...e,upc:e.upc??null,price:e.price/100,prices:Object.entries(e.prices||{}).reduce((e,[t,n])=>(e[t]=(0,o.minorUnitAmountToMajor)(n,t),e),{}),sale_price:typeof e.sale_price==`number`?e.sale_price/100:null,sale_prices:Object.entries(e.sale_prices||{}).reduce((e,[t,n])=>(e[t]=typeof n==`number`?(0,o.minorUnitAmountToMajor)(n,t):null,e),{}),main_media_id:e.main_media_id??null,main_image_url:e.image_url??null}))};return(0,s.jsx)(`div`,{className:`p-8`,children:(0,s.jsx)(i.ProductForm,{mediaPickerNode:l,availableLanguagesProp:u,globalAttributesProp:y,currenciesProp:v,translationGroupId:d,targetLanguageId:f,initialData:C,enabledProviders:m,configStatus:h,createAction:r.createProductAction})})}exports.NewProductPage=l;
|
|
@@ -5,5 +5,5 @@ interface NewProductPageProps {
|
|
|
5
5
|
targetLanguageId?: string;
|
|
6
6
|
initialData?: any;
|
|
7
7
|
}
|
|
8
|
-
export declare function NewProductPage({ mediaPickerNode, availableLanguagesProp, translationGroupId, targetLanguageId, initialData }: NewProductPageProps): Promise<import(
|
|
8
|
+
export declare function NewProductPage({ mediaPickerNode, availableLanguagesProp, translationGroupId, targetLanguageId, initialData }: NewProductPageProps): Promise<import('react').JSX.Element>;
|
|
9
9
|
export {};
|
|
@@ -1,76 +1,60 @@
|
|
|
1
|
+
import { normalizeCurrencyRecord as e } from "../../../../currency.es.js";
|
|
2
|
+
import { mapRawVariantRelations as t } from "../../../../variation-utils.es.js";
|
|
3
|
+
import { getGlobalProductAttributes as n } from "../actions.es.js";
|
|
4
|
+
import { createProductAction as r } from "../server-actions.es.js";
|
|
5
|
+
import { ProductForm as i } from "../components/ProductForm.es.js";
|
|
6
|
+
import { getEnabledPaymentProviders as a, getStoreConfigStatus as o } from "../../payments/queries.es.js";
|
|
7
|
+
import { minorUnitAmountToMajor as s } from "@nextblock-cms/utils";
|
|
1
8
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
),
|
|
52
|
-
sale_price: typeof e.sale_price == "number" ? e.sale_price / 100 : null,
|
|
53
|
-
sale_prices: Object.entries(e.sale_prices || {}).reduce((r, [o, n]) => (r[o] = typeof n == "number" ? m(n, o) : null, r), {}),
|
|
54
|
-
main_media_id: e.main_media_id ?? null,
|
|
55
|
-
main_image_url: e.image_url ?? null
|
|
56
|
-
}))
|
|
57
|
-
};
|
|
58
|
-
return /* @__PURE__ */ c("div", { className: "p-8", children: /* @__PURE__ */ c(
|
|
59
|
-
x,
|
|
60
|
-
{
|
|
61
|
-
mediaPickerNode: d,
|
|
62
|
-
availableLanguagesProp: i,
|
|
63
|
-
globalAttributesProp: b,
|
|
64
|
-
currenciesProp: f,
|
|
65
|
-
translationGroupId: a,
|
|
66
|
-
targetLanguageId: s,
|
|
67
|
-
initialData: h,
|
|
68
|
-
enabledProviders: u,
|
|
69
|
-
configStatus: _,
|
|
70
|
-
createAction: S
|
|
71
|
-
}
|
|
72
|
-
) });
|
|
9
|
+
import { getServiceRoleSupabaseClient as l } from "@nextblock-cms/db/server";
|
|
10
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/new/NewProductPage.tsx
|
|
11
|
+
async function u({ mediaPickerNode: u, availableLanguagesProp: d, translationGroupId: f, targetLanguageId: p, initialData: m }) {
|
|
12
|
+
let [h, g, _, v] = await Promise.all([
|
|
13
|
+
a(),
|
|
14
|
+
o(),
|
|
15
|
+
n(),
|
|
16
|
+
l().from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active", !0).order("code", { ascending: !0 }).then((e) => e.data || [])
|
|
17
|
+
]), y = (v || []).map((t) => e(t)), b = (_ || []).map((e) => ({
|
|
18
|
+
id: e.id,
|
|
19
|
+
name: e.name,
|
|
20
|
+
name_translations: e.name_translations || {},
|
|
21
|
+
slug: e.slug,
|
|
22
|
+
terms: (e.product_attribute_terms || []).map((e) => ({
|
|
23
|
+
...e,
|
|
24
|
+
value_translations: e.value_translations || {}
|
|
25
|
+
}))
|
|
26
|
+
})), x = d.find((e) => e.id === m?.language_id)?.code || d.find((e) => e.id === (p ? parseInt(p, 10) : void 0))?.code || d.find((e) => e.is_default)?.code, { attributes: S, variants: C } = t(m?.product_variants || [], x), w = m && {
|
|
27
|
+
...m,
|
|
28
|
+
variation_attributes: m.variation_attributes || S.map((e) => ({
|
|
29
|
+
attribute_id: e.id,
|
|
30
|
+
term_ids: e.terms.map((e) => e.id)
|
|
31
|
+
})),
|
|
32
|
+
variants: m.variants || C.map((e) => ({
|
|
33
|
+
...e,
|
|
34
|
+
upc: e.upc ?? null,
|
|
35
|
+
price: e.price / 100,
|
|
36
|
+
prices: Object.entries(e.prices || {}).reduce((e, [t, n]) => (e[t] = s(n, t), e), {}),
|
|
37
|
+
sale_price: typeof e.sale_price == "number" ? e.sale_price / 100 : null,
|
|
38
|
+
sale_prices: Object.entries(e.sale_prices || {}).reduce((e, [t, n]) => (e[t] = typeof n == "number" ? s(n, t) : null, e), {}),
|
|
39
|
+
main_media_id: e.main_media_id ?? null,
|
|
40
|
+
main_image_url: e.image_url ?? null
|
|
41
|
+
}))
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ c("div", {
|
|
44
|
+
className: "p-8",
|
|
45
|
+
children: /* @__PURE__ */ c(i, {
|
|
46
|
+
mediaPickerNode: u,
|
|
47
|
+
availableLanguagesProp: d,
|
|
48
|
+
globalAttributesProp: b,
|
|
49
|
+
currenciesProp: y,
|
|
50
|
+
translationGroupId: f,
|
|
51
|
+
targetLanguageId: p,
|
|
52
|
+
initialData: w,
|
|
53
|
+
enabledProviders: h,
|
|
54
|
+
configStatus: g,
|
|
55
|
+
createAction: r
|
|
56
|
+
})
|
|
57
|
+
});
|
|
73
58
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { u as NewProductPage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../../../currency.cjs.js");let t=require("@nextblock-cms/utils");function n(e){return Object.entries(e||{}).reduce((e,[n,r])=>(typeof r==`number`&&Number.isFinite(r)&&r>=0?e[(0,t.normalizeCurrencyCode)(n)]=r:r===null&&(e[(0,t.normalizeCurrencyCode)(n)]=null),e),{})}function r(t){let n=e.normalizeCurrencyRecord(t);return n.is_default!==!0&&n.auto_sync_product_prices===!0}function i(t){return t.map(t=>e.normalizeCurrencyRecord(t)).filter(e=>r(e)).map(e=>e.code)}function a(e,t){let r=new Set(i(t)),a=n(e);return Object.entries(a).reduce((e,[t,n])=>(r.has(t)||(e[t]=n),e),{})}function o(n){let{baseAmount:r,defaultCurrencyCode:i,targetCurrencyCode:a,currencies:o}=n;if(typeof r!=`number`||!Number.isFinite(r)||r<0)return null;let s=e.convertMinorUnitAmount({amount:(0,t.majorUnitAmountToMinor)(r,i),fromCurrencyCode:i,toCurrencyCode:a,currencies:o,applyRounding:!0});return(0,t.minorUnitAmountToMajor)(s,a)}function s(i){let{currencies:a,fallbackPrice:s,fallbackSalePrice:c}=i,l=n(i.prices),u=n(i.salePrices),d=a.find(e=>e.is_default)??a[0];if(!d)return{prices:l,salePrices:u};let f=(0,t.normalizeCurrencyCode)(d.code),p=l[f]??(typeof s==`number`?s:null),m=u[f]??(typeof c==`number`?c:null);return{prices:a.reduce((t,n)=>{let i=e.normalizeCurrencyRecord(n);return r(i)?(t[i.code]=o({baseAmount:p,defaultCurrencyCode:f,targetCurrencyCode:i.code,currencies:a}),t):(t[i.code]=l[i.code]??(i.code===f?p:void 0),t)},{}),salePrices:a.reduce((t,n)=>{let i=e.normalizeCurrencyRecord(n);return r(i)?(t[i.code]=o({baseAmount:m,defaultCurrencyCode:f,targetCurrencyCode:i.code,currencies:a}),t):(t[i.code]=u[i.code]??(i.code===f?m:void 0),t)},{})}}function c(e,n){let r=n.find(e=>e.is_default)??n[0],i=r?(0,t.normalizeCurrencyCode)(r.code):`USD`,o=a(e.prices,n),s=a(e.sale_prices,n);return{...e,price:typeof o[i]==`number`?o[i]:e.price,prices:o,sale_price:typeof s[i]==`number`?s[i]:e.sale_price??null,sale_prices:s}}function l(e,t){return e?.map(e=>c(e,t))||[]}function u(e,n){let r=n.find(e=>e.is_default)??n[0],i=r?(0,t.normalizeCurrencyCode)(r.code):`USD`,o=a(e.prices,n),s=a(e.sale_prices,n);return{...e,price:typeof o[i]==`number`?o[i]:e.price,prices:o,sale_price:typeof s[i]==`number`?s[i]:e.sale_price??null,sale_prices:s,variants:l(e.variants,n)}}exports.getStoreManagedPriceCurrencyCodes=i,exports.isCurrencyStoreManagedPrice=r,exports.resolveEditorCurrencyPriceMaps=s,exports.sanitizeProductFormValuesForStoreManagedCurrencies=u,exports.sanitizeVariantDraftForStoreManagedCurrencies=c,exports.sanitizeVariantDraftsForStoreManagedCurrencies=l;
|
|
@@ -1,98 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{}
|
|
7
|
-
);
|
|
1
|
+
import { convertMinorUnitAmount as e, normalizeCurrencyRecord as t } from "../../../currency.es.js";
|
|
2
|
+
import { majorUnitAmountToMinor as n, minorUnitAmountToMajor as r, normalizeCurrencyCode as i } from "@nextblock-cms/utils";
|
|
3
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/product-price-sync.ts
|
|
4
|
+
function a(e) {
|
|
5
|
+
return Object.entries(e || {}).reduce((e, [t, n]) => (typeof n == "number" && Number.isFinite(n) && n >= 0 ? e[i(t)] = n : n === null && (e[i(t)] = null), e), {});
|
|
8
6
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function o(e) {
|
|
8
|
+
let n = t(e);
|
|
9
|
+
return n.is_default !== !0 && n.auto_sync_product_prices === !0;
|
|
12
10
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
11
|
+
function s(e) {
|
|
12
|
+
return e.map((e) => t(e)).filter((e) => o(e)).map((e) => e.code);
|
|
15
13
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(t, [i, u]) => (o.has(i) || (t[i] = u), t),
|
|
20
|
-
{}
|
|
21
|
-
);
|
|
14
|
+
function c(e, t) {
|
|
15
|
+
let n = new Set(s(t)), r = a(e);
|
|
16
|
+
return Object.entries(r).reduce((e, [t, r]) => (n.has(t) || (e[t] = r), e), {});
|
|
22
17
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return z(i, n);
|
|
18
|
+
function l(t) {
|
|
19
|
+
let { baseAmount: i, defaultCurrencyCode: a, targetCurrencyCode: o, currencies: s } = t;
|
|
20
|
+
if (typeof i != "number" || !Number.isFinite(i) || i < 0) return null;
|
|
21
|
+
let c = e({
|
|
22
|
+
amount: n(i, a),
|
|
23
|
+
fromCurrencyCode: a,
|
|
24
|
+
toCurrencyCode: o,
|
|
25
|
+
currencies: s,
|
|
26
|
+
applyRounding: !0
|
|
27
|
+
});
|
|
28
|
+
return r(c, o);
|
|
35
29
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
30
|
+
function u(e) {
|
|
31
|
+
let { currencies: n, fallbackPrice: r, fallbackSalePrice: s } = e, c = a(e.prices), u = a(e.salePrices), d = n.find((e) => e.is_default) ?? n[0];
|
|
32
|
+
if (!d) return {
|
|
33
|
+
prices: c,
|
|
34
|
+
salePrices: u
|
|
35
|
+
};
|
|
36
|
+
let f = i(d.code), p = c[f] ?? (typeof r == "number" ? r : null), m = u[f] ?? (typeof s == "number" ? s : null);
|
|
37
|
+
return {
|
|
38
|
+
prices: n.reduce((e, r) => {
|
|
39
|
+
let i = t(r);
|
|
40
|
+
return o(i) ? (e[i.code] = l({
|
|
41
|
+
baseAmount: p,
|
|
42
|
+
defaultCurrencyCode: f,
|
|
43
|
+
targetCurrencyCode: i.code,
|
|
44
|
+
currencies: n
|
|
45
|
+
}), e) : (e[i.code] = c[i.code] ?? (i.code === f ? p : void 0), e);
|
|
46
|
+
}, {}),
|
|
47
|
+
salePrices: n.reduce((e, r) => {
|
|
48
|
+
let i = t(r);
|
|
49
|
+
return o(i) ? (e[i.code] = l({
|
|
50
|
+
baseAmount: m,
|
|
51
|
+
defaultCurrencyCode: f,
|
|
52
|
+
targetCurrencyCode: i.code,
|
|
53
|
+
currencies: n
|
|
54
|
+
}), e) : (e[i.code] = u[i.code] ?? (i.code === f ? m : void 0), e);
|
|
55
|
+
}, {})
|
|
56
|
+
};
|
|
64
57
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
function d(e, t) {
|
|
59
|
+
let n = t.find((e) => e.is_default) ?? t[0], r = n ? i(n.code) : "USD", a = c(e.prices, t), o = c(e.sale_prices, t);
|
|
60
|
+
return {
|
|
61
|
+
...e,
|
|
62
|
+
price: typeof a[r] == "number" ? a[r] : e.price,
|
|
63
|
+
prices: a,
|
|
64
|
+
sale_price: typeof o[r] == "number" ? o[r] : e.sale_price ?? null,
|
|
65
|
+
sale_prices: o
|
|
66
|
+
};
|
|
74
67
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
(o) => F(o, e)
|
|
78
|
-
) || [];
|
|
68
|
+
function f(e, t) {
|
|
69
|
+
return e?.map((e) => d(e, t)) || [];
|
|
79
70
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
71
|
+
function p(e, t) {
|
|
72
|
+
let n = t.find((e) => e.is_default) ?? t[0], r = n ? i(n.code) : "USD", a = c(e.prices, t), o = c(e.sale_prices, t);
|
|
73
|
+
return {
|
|
74
|
+
...e,
|
|
75
|
+
price: typeof a[r] == "number" ? a[r] : e.price,
|
|
76
|
+
prices: a,
|
|
77
|
+
sale_price: typeof o[r] == "number" ? o[r] : e.sale_price ?? null,
|
|
78
|
+
sale_prices: o,
|
|
79
|
+
variants: f(e.variants, t)
|
|
80
|
+
};
|
|
90
81
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
y as isCurrencyStoreManagedPrice,
|
|
94
|
-
v as resolveEditorCurrencyPriceMaps,
|
|
95
|
-
E as sanitizeProductFormValuesForStoreManagedCurrencies,
|
|
96
|
-
F as sanitizeVariantDraftForStoreManagedCurrencies,
|
|
97
|
-
D as sanitizeVariantDraftsForStoreManagedCurrencies
|
|
98
|
-
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { s as getStoreManagedPriceCurrencyCodes, o as isCurrencyStoreManagedPrice, u as resolveEditorCurrencyPriceMaps, p as sanitizeProductFormValuesForStoreManagedCurrencies, d as sanitizeVariantDraftForStoreManagedCurrencies, f as sanitizeVariantDraftsForStoreManagedCurrencies };
|