@nextblock-cms/ecom 0.20.3 → 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 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";const e=require("../coupon-server.cjs.js");let t=require("@nextblock-cms/db/server");async function n(n){try{let r=(0,t.getServiceRoleSupabaseClient)();return await e.getCouponQuote({client:r,code:n.code,items:Array.isArray(n.items)?n.items:[],currencyCode:n.currencyCode})}catch(e){return console.error(`Failed to validate coupon:`,e),{success:!1,error:e.message||`Failed to validate coupon.`,errorKey:`ecommerce.coupon_validation_failed`}}}exports.getCouponQuoteAction=n;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use server";
|
|
2
|
+
import { getCouponQuote as e } from "../coupon-server.es.js";
|
|
3
|
+
import { getServiceRoleSupabaseClient as t } from "@nextblock-cms/db/server";
|
|
4
|
+
//#region libs/ecommerce/src/lib/server-actions/coupon-actions.ts
|
|
5
|
+
async function n(n) {
|
|
6
|
+
try {
|
|
7
|
+
let r = t();
|
|
8
|
+
return await e({
|
|
9
|
+
client: r,
|
|
10
|
+
code: n.code,
|
|
11
|
+
items: Array.isArray(n.items) ? n.items : [],
|
|
12
|
+
currencyCode: n.currencyCode
|
|
13
|
+
});
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return console.error("Failed to validate coupon:", e), {
|
|
16
|
+
success: !1,
|
|
17
|
+
error: e.message || "Failed to validate coupon.",
|
|
18
|
+
errorKey: "ecommerce.coupon_validation_failed"
|
|
19
|
+
};
|
|
20
|
+
}
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { n as getCouponQuoteAction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";const e=require("../customer.cjs.js"),t=require("../customer-addresses.cjs.js");let n=require("@nextblock-cms/db/server"),r=require("next/cache");async function i(i){let a=(0,n.createClient)(),{data:{user:o},error:s}=await a.auth.getUser();if(s||!o)throw Error(`Unauthorized`);let c={full_name:i.full_name||null,avatar_url:i.avatar_url||null,website:i.website||null,phone:i.phone||null,updated_at:new Date().toISOString()},{error:l}=await a.from(`profiles`).update(c).eq(`id`,o.id);if(l)throw console.error(`Error updating profile:`,l),Error(`Failed to update profile`);let u=e.normalizeCustomerAddress(i.billing_address),d=i.use_billing_for_shipping?u:e.normalizeCustomerAddress(i.shipping_address);return await t.upsertDefaultUserAddresses({userId:o.id,billingAddress:u,shippingAddress:d,client:a}),(0,r.revalidatePath)(`/profile`),(0,r.revalidatePath)(`/checkout`),{success:!0}}exports.updateProfile=i;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}), s("/profile"), s("/checkout"), { success: !0 };
|
|
1
|
+
"use server";
|
|
2
|
+
import { normalizeCustomerAddress as e } from "../customer.es.js";
|
|
3
|
+
import { upsertDefaultUserAddresses as t } from "../customer-addresses.es.js";
|
|
4
|
+
import { createClient as n } from "@nextblock-cms/db/server";
|
|
5
|
+
import { revalidatePath as r } from "next/cache";
|
|
6
|
+
//#region libs/ecommerce/src/lib/server-actions/customer-actions.ts
|
|
7
|
+
async function i(i) {
|
|
8
|
+
let a = n(), { data: { user: o }, error: s } = await a.auth.getUser();
|
|
9
|
+
if (s || !o) throw Error("Unauthorized");
|
|
10
|
+
let c = {
|
|
11
|
+
full_name: i.full_name || null,
|
|
12
|
+
avatar_url: i.avatar_url || null,
|
|
13
|
+
website: i.website || null,
|
|
14
|
+
phone: i.phone || null,
|
|
15
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
16
|
+
}, { error: l } = await a.from("profiles").update(c).eq("id", o.id);
|
|
17
|
+
if (l) throw console.error("Error updating profile:", l), Error("Failed to update profile");
|
|
18
|
+
let u = e(i.billing_address), d = i.use_billing_for_shipping ? u : e(i.shipping_address);
|
|
19
|
+
return await t({
|
|
20
|
+
userId: o.id,
|
|
21
|
+
billingAddress: u,
|
|
22
|
+
shippingAddress: d,
|
|
23
|
+
client: a
|
|
24
|
+
}), r("/profile"), r("/checkout"), { success: !0 };
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { i as updateProfile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../product-actions.cjs.js");let t=require("@nextblock-cms/db/server");async function n(n,r,i=[],a=[]){let o=(0,t.createClient)(),{data:s,error:c}=await e.fetchTranslatedProductsForCartInternal(o,n,r,i,a);return c?(console.error(`[getTranslatedProductsForCart] Error:`,c),[]):s||[]}exports.getTranslatedProductsForCart=n;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
o,
|
|
9
|
-
a,
|
|
10
|
-
e
|
|
11
|
-
);
|
|
12
|
-
return r ? (console.error("[getTranslatedProductsForCart] Error:", r), []) : s || [];
|
|
1
|
+
"use server";
|
|
2
|
+
import { fetchTranslatedProductsForCartInternal as e } from "../product-actions.es.js";
|
|
3
|
+
import { createClient as t } from "@nextblock-cms/db/server";
|
|
4
|
+
//#region libs/ecommerce/src/lib/server-actions/product-actions.ts
|
|
5
|
+
async function n(n, r, i = [], a = []) {
|
|
6
|
+
let o = t(), { data: s, error: c } = await e(o, n, r, i, a);
|
|
7
|
+
return c ? (console.error("[getTranslatedProductsForCart] Error:", c), []) : s || [];
|
|
13
8
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as getTranslatedProductsForCart };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";const e=require("../countries.cjs.js"),t=require("../shipping/resolver.cjs.js"),n=require("../states.cjs.js");async function r(r,i,a,o){try{let s=e.normalizeCountryCode(i.country);return s?{success:!0,methods:await t.resolveShippingOptions(r,{...i,country:s,state:n.normalizeSubdivisionCode(s,i.state)||void 0},a,o)}:{success:!1,error:`Country is required for shipping calculation`,errorKey:`ecommerce.shipping_country_required`}}catch(e){return console.error(`Failed to resolve shipping options:`,e),{success:!1,error:e.message||`Failed to calculate shipping`,errorKey:`ecommerce.shipping_calculation_failed`}}}exports.getShippingEstimates=r;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"use server";
|
|
2
|
+
import { normalizeCountryCode as e } from "../countries.es.js";
|
|
2
3
|
import { resolveShippingOptions as t } from "../shipping/resolver.es.js";
|
|
3
|
-
import { normalizeCountryCode as c } from "../countries.es.js";
|
|
4
4
|
import { normalizeSubdivisionCode as n } from "../states.es.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
//#region libs/ecommerce/src/lib/server-actions/shipping-actions.ts
|
|
6
|
+
async function r(r, i, a, o) {
|
|
7
|
+
try {
|
|
8
|
+
let s = e(i.country);
|
|
9
|
+
return s ? {
|
|
10
|
+
success: !0,
|
|
11
|
+
methods: await t(r, {
|
|
12
|
+
...i,
|
|
13
|
+
country: s,
|
|
14
|
+
state: n(s, i.state) || void 0
|
|
15
|
+
}, a, o)
|
|
16
|
+
} : {
|
|
17
|
+
success: !1,
|
|
18
|
+
error: "Country is required for shipping calculation",
|
|
19
|
+
errorKey: "ecommerce.shipping_country_required"
|
|
20
|
+
};
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return console.error("Failed to resolve shipping options:", e), {
|
|
23
|
+
success: !1,
|
|
24
|
+
error: e.message || "Failed to calculate shipping",
|
|
25
|
+
errorKey: "ecommerce.shipping_calculation_failed"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { r as getShippingEstimates };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";const e=require("../coupon-server.cjs.js"),t=require("../tax-calculation.cjs.js");let n=require("@nextblock-cms/db/server");async function r(r,i,a=`USD`,o,s){try{let c=(0,n.createClient)(),l=(0,n.getServiceRoleSupabaseClient)(),{data:u}=await c.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}),d=u??[],f;if(o){let t=await e.getCouponQuote({client:l,code:o,items:s&&s.length>0?s:r,currencyCode:a});t.success&&(f=e.getQuoteLineDiscountMap(t.quote))}let p=await t.buildCheckoutTaxableItemsFromCart(c,r,a,d,f);return{success:!0,tax:await t.calculateCheckoutTaxes(c,{items:p,destination:i})}}catch(e){return console.error(`Failed to estimate taxes:`,e),{success:!1,error:e.message||`Failed to calculate taxes`}}}exports.getTaxEstimate=r;
|
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { buildCheckoutTaxableItemsFromCart 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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return console.error("Failed to estimate taxes:", e), {
|
|
33
|
-
success: !1,
|
|
34
|
-
error: e.message || "Failed to calculate taxes"
|
|
35
|
-
};
|
|
36
|
-
}
|
|
1
|
+
"use server";
|
|
2
|
+
import { getCouponQuote as e, getQuoteLineDiscountMap as t } from "../coupon-server.es.js";
|
|
3
|
+
import { buildCheckoutTaxableItemsFromCart as n, calculateCheckoutTaxes as r } from "../tax-calculation.es.js";
|
|
4
|
+
import { createClient as i, getServiceRoleSupabaseClient as a } from "@nextblock-cms/db/server";
|
|
5
|
+
//#region libs/ecommerce/src/lib/server-actions/tax-actions.ts
|
|
6
|
+
async function o(o, s, c = "USD", l, u) {
|
|
7
|
+
try {
|
|
8
|
+
let d = i(), f = a(), { data: p } = await d.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 }), m = p ?? [], h;
|
|
9
|
+
if (l) {
|
|
10
|
+
let n = await e({
|
|
11
|
+
client: f,
|
|
12
|
+
code: l,
|
|
13
|
+
items: u && u.length > 0 ? u : o,
|
|
14
|
+
currencyCode: c
|
|
15
|
+
});
|
|
16
|
+
n.success && (h = t(n.quote));
|
|
17
|
+
}
|
|
18
|
+
let g = await n(d, o, c, m, h);
|
|
19
|
+
return {
|
|
20
|
+
success: !0,
|
|
21
|
+
tax: await r(d, {
|
|
22
|
+
items: g,
|
|
23
|
+
destination: s
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return console.error("Failed to estimate taxes:", e), {
|
|
28
|
+
success: !1,
|
|
29
|
+
error: e.message || "Failed to calculate taxes"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { o as getTaxEstimate };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@nextblock-cms/db/server");require("server-only");function t(t){return t??(0,e.getServiceRoleSupabaseClient)()}function n(e){return e?(Array.isArray(e)?e:[e]).map(e=>e?.code?.toUpperCase().trim()).filter(e=>!!e):[]}function r(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function i(e,t){return!e||e===t?t:`mixed`}async function a(e,t){let n=Array.from(t.reduce((e,t)=>{let n=t.sku.trim();return n&&e.set(n,{sku:n,quantity:Math.max(0,Math.trunc(t.quantity))}),e},new Map).values());if(n.length===0)return;let{error:r}=await e.from(`inventory_items`).upsert(n,{onConflict:`sku`});if(r)throw Error(r.message)}async function o(e,t){let n=r(t.map(e=>e.trim()).filter(Boolean));if(n.length===0)return new Map;let{data:i,error:a}=await e.from(`inventory_items`).select(`sku, quantity`).in(`sku`,n);if(a)throw Error(a.message);return new Map((i||[]).map(e=>[e.sku,Math.max(0,e.quantity??0)]))}async function s(e){let{data:t,error:r}=await e.from(`products`).select(`
|
|
2
2
|
id,
|
|
3
3
|
title,
|
|
4
4
|
sku,
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
sku,
|
|
13
13
|
stock_quantity
|
|
14
14
|
)
|
|
15
|
-
`).order(
|
|
15
|
+
`).order(`title`,{ascending:!0});if(r)throw Error(r.message);let a=new Map,o=(e,t,r,o,s)=>{let c=e.trim();if(!c)return;let l=n(o.languages),u=a.get(c);if(u){u.usageType=i(u.usageType,t),u.stockFallback=Math.min(u.stockFallback,r),u.productTitles.add(o.title),u.parentProductSkus.add(o.sku),u.languages=new Set([...u.languages,...l]),u.statuses.add(o.status),u.productIds.add(o.id),s&&u.variantIds.add(s);return}a.set(c,{sku:c,stockFallback:r,usageType:t,productTitles:new Set([o.title]),parentProductSkus:new Set([o.sku]),languages:new Set(l),statuses:new Set([o.status]),productIds:new Set([o.id]),variantIds:s?new Set([s]):new Set})};for(let e of t||[]){let t=e.product_variants||[];if(t.length>0){for(let n of t)o(n.sku,`variant`,Math.max(0,n.stock_quantity??0),e,n.id);continue}o(e.sku,`product`,Math.max(0,e.stock??0),e)}return a}async function c(e){let n=t(e),i=await s(n),c=[...i.keys()];if(c.length===0)return[];let l=await o(n,c),u=c.filter(e=>!l.has(e)).flatMap(e=>{let t=i.get(e);return t?[{sku:e,quantity:t.stockFallback}]:[]});return u.length>0&&(await a(n,u),l=await o(n,c)),c.flatMap(e=>{let t=i.get(e);return t?{key:e,sku:e,stock:l.get(e)??t.stockFallback,usageType:t.usageType,productTitles:r(t.productTitles),parentProductSkus:r(t.parentProductSkus),languages:r(t.languages),statuses:r(t.statuses),productIds:r(t.productIds),variantIds:r(t.variantIds)}:[]}).sort((e,t)=>e.sku.localeCompare(t.sku)||e.usageType.localeCompare(t.usageType)||e.productTitles.join(`, `).localeCompare(t.productTitles.join(`, `)))}async function l(e,n){let r=t(n),i=e.sku.trim(),o=Math.max(0,Math.trunc(e.stock));if(!i)throw Error(`SKU is required to update inventory.`);await a(r,[{sku:i,quantity:o}]);let c=(await s(r)).get(i);return{stock:o,affectedCount:(c?.productIds.size??0)+(c?.variantIds.size??0)}}async function u(e,n,r){let i=t(r);if(n.variants&&n.variants.length>0){await a(i,Array.from(n.variants.reduce((e,t)=>(e.set(t.sku.trim(),Math.max(0,Math.trunc(t.stock_quantity))),e),new Map).entries()).map(([e,t])=>({sku:e,quantity:t})));return}await a(i,[{sku:n.sku,quantity:Math.max(0,Math.trunc(n.stock))}])}exports.getInventoryItems=c,exports.setSharedInventoryQuantity=l,exports.syncSharedInventoryForSavedProduct=u;
|