@nextblock-cms/ecom 0.8.6 → 0.8.7
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/index.cjs.js +1 -1
- package/index.es.js +136 -533
- package/lib/CurrencyProvider.cjs.js +1 -0
- package/lib/CurrencyProvider.es.js +99 -0
- package/lib/cart-store.cjs.js +1 -0
- package/{cart-store.es.js → lib/cart-store.es.js} +13 -13
- package/lib/components/AccountNavigationMenu.cjs.js +1 -0
- package/lib/components/AccountNavigationMenu.es.js +44 -0
- package/lib/components/AddToCartButton.cjs.js +1 -0
- package/{AddToCartButton-ffE0DhHu.js → lib/components/AddToCartButton.es.js} +14 -13
- package/lib/components/Cart.cjs.js +1 -0
- package/lib/components/Cart.es.js +148 -0
- package/lib/components/CartDrawer.cjs.js +1 -0
- package/{components → lib/components}/CartDrawer.es.js +15 -14
- package/{components → lib/components}/CartIcon.cjs.js +1 -1
- package/{components → lib/components}/CartIcon.es.js +1 -0
- package/lib/components/Checkout.cjs.js +1 -0
- package/{components → lib/components}/Checkout.es.js +330 -363
- package/lib/components/CouponForm.cjs.js +1 -0
- package/lib/components/CouponForm.es.js +136 -0
- package/lib/components/CurrencySwitcher.cjs.js +1 -0
- package/{components → lib/components}/CurrencySwitcher.es.js +5 -4
- package/lib/components/CustomerProfileForm.cjs.js +1 -0
- package/lib/components/CustomerProfileForm.es.js +355 -0
- package/lib/components/FeaturedProduct.cjs.js +1 -0
- package/{components → lib/components}/FeaturedProduct.es.js +9 -8
- package/lib/components/InvoiceDocument.cjs.js +1 -0
- package/lib/components/InvoiceDocument.es.js +196 -0
- package/lib/components/InvoiceViewerShell.cjs.js +29 -0
- package/lib/components/InvoiceViewerShell.es.js +100 -0
- package/lib/components/ProductCard.cjs.js +1 -0
- package/lib/components/ProductCard.es.js +119 -0
- package/lib/components/ProductDetailsLayout.cjs.js +1 -0
- package/lib/components/ProductDetailsLayout.es.js +361 -0
- package/lib/components/ProductGallery.cjs.js +1 -0
- package/lib/components/ProductGallery.es.js +41 -0
- package/lib/components/ProductGrid.cjs.js +1 -0
- package/lib/components/ProductGrid.es.js +19 -0
- package/lib/components/ShippingEstimator.cjs.js +1 -0
- package/lib/components/ShippingEstimator.es.js +125 -0
- package/lib/components/SubscriptionSelector.cjs.js +1 -0
- package/lib/components/SubscriptionSelector.es.js +140 -0
- package/lib/countries.cjs.js +1 -0
- package/lib/countries.es.js +77 -0
- package/lib/coupon-server.cjs.js +1 -0
- package/{coupon-server-DUKVtyYs.js → lib/coupon-server.es.js} +68 -82
- package/lib/coupons.cjs.js +1 -0
- package/lib/coupons.es.js +17 -0
- package/lib/currency-store.cjs.js +1 -0
- package/lib/currency-store.es.js +27 -0
- package/lib/currency-sync.cjs.js +1 -0
- package/lib/currency-sync.es.js +180 -0
- package/lib/customer-addresses.cjs.js +1 -0
- package/lib/customer-addresses.es.js +116 -0
- package/lib/customer-orders.cjs.js +1 -0
- package/lib/customer-orders.es.js +45 -0
- package/lib/customer.cjs.js +1 -0
- package/{customer-C3xccjUg.js → lib/customer.es.js} +15 -14
- package/lib/export-helpers.cjs.js +1 -0
- package/lib/export-helpers.es.js +56 -0
- package/lib/factory.cjs.js +1 -0
- package/lib/factory.es.js +8 -0
- package/lib/freemius-coupons.cjs.js +1 -0
- package/lib/freemius-coupons.es.js +272 -0
- package/lib/freemius-order-sync.cjs.js +1 -0
- package/lib/freemius-order-sync.es.js +284 -0
- package/lib/inventory-settings.cjs.js +1 -0
- package/lib/inventory-settings.es.js +86 -0
- package/lib/invoice-server.cjs.js +33 -0
- package/lib/invoice-server.es.js +141 -0
- package/lib/invoice-ui.cjs.js +1 -0
- package/lib/invoice-ui.es.js +71 -0
- package/lib/invoice.cjs.js +1 -0
- package/lib/invoice.es.js +102 -0
- package/lib/order-inventory.cjs.js +61 -0
- package/lib/order-inventory.es.js +128 -0
- package/lib/order-tax-details.cjs.js +1 -0
- package/lib/order-tax-details.es.js +164 -0
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
- package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
- package/lib/pages/cms/coupons/actions.cjs.js +1 -0
- package/lib/pages/cms/coupons/actions.es.js +128 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +27 -0
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
- package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
- package/lib/pages/cms/orders/actions.cjs.js +7 -0
- package/lib/pages/cms/orders/actions.es.js +71 -0
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +27 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +55 -0
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
- package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
- package/lib/pages/cms/payments/actions.cjs.js +1 -0
- package/lib/pages/cms/payments/actions.es.js +23 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -0
- package/lib/pages/cms/payments/queries.es.js +30 -0
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
- package/lib/pages/cms/products/ProductsPage.es.js +46 -0
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
- package/lib/pages/cms/products/actions.cjs.js +44 -0
- package/lib/pages/cms/products/actions.es.js +175 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +95 -0
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
- package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +98 -0
- package/lib/pages/cms/products/server-actions.cjs.js +1 -0
- package/lib/pages/cms/products/server-actions.es.js +193 -0
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
- package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +159 -0
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
- package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
- package/lib/pages/cms/taxes/actions.cjs.js +1 -0
- package/lib/pages/cms/taxes/actions.es.js +57 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
- package/lib/product-actions.cjs.js +237 -0
- package/lib/product-actions.es.js +524 -0
- package/lib/product-context.cjs.js +1 -0
- package/lib/product-context.es.js +16 -0
- package/lib/product-schema.cjs.js +1 -0
- package/lib/product-schema.es.js +134 -0
- package/lib/providers/freemius.cjs.js +5 -0
- package/lib/providers/freemius.es.js +538 -0
- package/lib/providers/stripe.cjs.js +1 -0
- package/lib/providers/stripe.es.js +473 -0
- package/lib/server-actions/coupon-actions.cjs.js +1 -0
- package/lib/server-actions/coupon-actions.es.js +23 -0
- package/lib/server-actions/customer-actions.cjs.js +1 -0
- package/lib/server-actions/customer-actions.es.js +30 -0
- package/lib/server-actions/product-actions.cjs.js +1 -0
- package/{server-actions → lib/server-actions}/product-actions.es.js +5 -4
- package/lib/server-actions/shipping-actions.cjs.js +1 -0
- package/{shipping-actions-BnHjlo2q.js → lib/server-actions/shipping-actions.es.js} +9 -7
- package/lib/server-actions/tax-actions.cjs.js +1 -0
- package/lib/server-actions/tax-actions.es.js +40 -0
- package/lib/shared-inventory.cjs.js +15 -0
- package/lib/shared-inventory.es.js +171 -0
- package/lib/shipping/resolver.cjs.js +7 -0
- package/lib/shipping/resolver.es.js +62 -0
- package/lib/shipping-rate-currency.cjs.js +1 -0
- package/lib/shipping-rate-currency.es.js +72 -0
- package/lib/states.cjs.js +1 -0
- package/{states-DlHJezQ1.js → lib/states.es.js} +27 -100
- package/lib/stripe/checkout.cjs.js +1 -0
- package/lib/stripe/checkout.es.js +182 -0
- package/lib/stripe/client.cjs.js +1 -0
- package/lib/stripe/client.es.js +7 -0
- package/lib/stripe/order-sync.cjs.js +1 -0
- package/lib/stripe/order-sync.es.js +130 -0
- package/lib/stripe/webhooks.cjs.js +1 -0
- package/lib/stripe/webhooks.es.js +30 -0
- package/lib/tax-calculation.cjs.js +1 -0
- package/lib/tax-calculation.es.js +101 -0
- package/lib/trials.cjs.js +1 -0
- package/{trials-RDcRAZKx.js → lib/trials.es.js} +9 -9
- package/{use-cart.es.js → lib/use-cart.es.js} +1 -0
- package/lib/zod-config.cjs.js +1 -0
- package/lib/zod-config.es.js +6 -0
- package/package.json +4 -4
- package/server.cjs.js +1 -110
- package/server.es.js +178 -6052
- package/AddToCartButton-DsSEH9yp.cjs +0 -1
- package/CouponForm-BI_5SBHQ.js +0 -152
- package/CouponForm-D_uu2bLP.cjs +0 -1
- package/CurrencyProvider-Cg-Q6ucj.cjs +0 -1
- package/CurrencyProvider-OzlRN96V.js +0 -120
- package/CurrencyProvider.cjs.js +0 -1
- package/CurrencyProvider.es.js +0 -10
- package/ProductDetailsLayout-BxJH_BxR.cjs +0 -1
- package/ProductDetailsLayout-Dg8dRTYp.js +0 -530
- package/ProductGrid-BdL7iglO.cjs +0 -1
- package/ProductGrid-D3AWM8sr.js +0 -130
- package/actions-AHmBrS5e.cjs +0 -48
- package/actions-j5fuSZX-.js +0 -820
- package/cart-store.cjs.js +0 -1
- package/components/Cart.cjs.js +0 -1
- package/components/Cart.es.js +0 -259
- package/components/CartDrawer.cjs.js +0 -1
- package/components/Checkout.cjs.js +0 -1
- package/components/CurrencySwitcher.cjs.js +0 -1
- package/components/FeaturedProduct.cjs.js +0 -1
- package/components/ProductDetailsLayout.cjs.js +0 -1
- package/components/ProductDetailsLayout.es.js +0 -19
- package/components/ProductGrid.cjs.js +0 -1
- package/components/ProductGrid.es.js +0 -6
- package/coupon-server-C9ySm3I5.cjs +0 -1
- package/customer-C-UPvrYN.cjs +0 -1
- package/invoice-ui-CAnJPu6n.cjs +0 -29
- package/invoice-ui-DtpbTJE1.js +0 -2886
- package/product-actions-CONBF8i6.cjs +0 -251
- package/product-actions-DjlIWCMH.js +0 -691
- package/resolver-Fz_FKsfX.cjs +0 -7
- package/resolver-cfrCaHpE.js +0 -128
- package/server-actions/product-actions.cjs.js +0 -1
- package/shipping-actions-D6zt20gg.cjs +0 -1
- package/states-CWYRxV4B.cjs +0 -1
- package/tax-calculation-Dab89aHd.js +0 -181
- package/tax-calculation-MkDKOEkL.cjs +0 -1
- package/trials-DvZaOtNy.cjs +0 -1
- /package/{components → lib/components}/SimpleTiptapRenderer.cjs.js +0 -0
- /package/{components → lib/components}/SimpleTiptapRenderer.es.js +0 -0
- /package/{currency-constants.cjs.js → lib/currency-constants.cjs.js} +0 -0
- /package/{currency-constants.es.js → lib/currency-constants.es.js} +0 -0
- /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
- /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
- /package/{currency.cjs.js → lib/currency.cjs.js} +0 -0
- /package/{currency.es.js → lib/currency.es.js} +0 -0
- /package/{types.cjs.js → lib/types.cjs.js} +0 -0
- /package/{types.es.js → lib/types.es.js} +0 -0
- /package/{use-cart.cjs.js → lib/use-cart.cjs.js} +0 -0
- /package/{variation-utils.cjs.js → lib/variation-utils.cjs.js} +0 -0
- /package/{variation-utils.es.js → lib/variation-utils.es.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),n=require("react"),h=require("@nextblock-cms/utils"),f=require("./currency.cjs.js"),v=require("./currency-store.cjs.js"),z=require("./currency-constants.cjs.js"),g=n.createContext(null);function x(o){return f.sortCurrencies(o.filter(r=>r.is_active!==!1))}function M(o){const{currencies:r,storedCurrencyCode:C,hasHydrated:y,initialCurrencyCode:t,locale:l}=o,u=new Set(r.map(a=>h.normalizeCurrencyCode(a.code))),i=f.getDefaultCurrency(r),s=t?h.normalizeCurrencyCode(t):null,e=C?h.normalizeCurrencyCode(C):null;if(y&&e&&u.has(e))return e;if(s&&u.has(s))return s;const d=f.inferCurrencyCodeFromLocale(l,r);return u.has(d)?d:i.code}function p({children:o,initialCurrencies:r,initialCurrencyCode:C,locale:y}){const[t,l]=n.useState(()=>x(r)),u=v.useCurrencyPreferenceStore(c=>c.activeCurrencyCode),i=v.useCurrencyPreferenceStore(c=>c.hasHydrated),s=v.useCurrencyPreferenceStore(c=>c.setActiveCurrencyCode);n.useEffect(()=>{v.useCurrencyPreferenceStore.persist.rehydrate()},[]),n.useEffect(()=>{r.length>0&&l(x(r))},[r]),n.useEffect(()=>{if(r.length>0)return;async function c(){const{fetchActiveCurrenciesFromRest:m}=await Promise.resolve().then(()=>require("./currency-rest-client.cjs.js")),S=await m();S.length>0&&l(x(S.map(P=>f.normalizeCurrencyRecord(P))))}c()},[r.length]);const e=n.useMemo(()=>M({currencies:t,storedCurrencyCode:u,hasHydrated:i,initialCurrencyCode:C,locale:y}),[t,u,i,C,y]);n.useEffect(()=>{e&&u!==e&&s(e)},[e,s,u]),n.useEffect(()=>{!e||typeof document>"u"||(document.cookie=`${z.CURRENCY_COOKIE_NAME}=${e}; Path=/; Max-Age=31536000; SameSite=Lax`)},[e]);const d=n.useMemo(()=>f.getDefaultCurrency(t),[t]),a=n.useMemo(()=>t.find(c=>c.code===e)??d,[t,d,e]),E=n.useMemo(()=>({currencies:t,defaultCurrency:d,activeCurrency:a,activeCurrencyCode:a.code,isHydrated:i,setActiveCurrencyCode:c=>{const m=h.normalizeCurrencyCode(c);t.some(P=>P.code===m)&&s(m)}}),[a,t,d,i,s]);return q.jsx(g.Provider,{value:E,children:o})}function A(){const o=n.useContext(g);if(!o)throw new Error("useCurrency must be used inside a CurrencyProvider");return o}exports.CurrencyProvider=p;exports.useCurrency=A;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as E, useState as z, useEffect as a, useMemo as l, useContext as H } from "react";
|
|
4
|
+
import { normalizeCurrencyCode as h } from "@nextblock-cms/utils";
|
|
5
|
+
import { getDefaultCurrency as S, sortCurrencies as R, normalizeCurrencyRecord as M, inferCurrencyCodeFromLocale as _ } from "./currency.es.js";
|
|
6
|
+
import { useCurrencyPreferenceStore as v } from "./currency-store.es.js";
|
|
7
|
+
import { CURRENCY_COOKIE_NAME as F } from "./currency-constants.es.js";
|
|
8
|
+
const A = E(null);
|
|
9
|
+
function g(n) {
|
|
10
|
+
return R(
|
|
11
|
+
n.filter((r) => r.is_active !== !1)
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
function L(n) {
|
|
15
|
+
const { currencies: r, storedCurrencyCode: i, hasHydrated: f, initialCurrencyCode: t, locale: y } = n, c = new Set(
|
|
16
|
+
r.map((C) => h(C.code))
|
|
17
|
+
), d = S(r), s = t ? h(t) : null, e = i ? h(i) : null;
|
|
18
|
+
if (f && e && c.has(e))
|
|
19
|
+
return e;
|
|
20
|
+
if (s && c.has(s))
|
|
21
|
+
return s;
|
|
22
|
+
const u = _(y, r);
|
|
23
|
+
return c.has(u) ? u : d.code;
|
|
24
|
+
}
|
|
25
|
+
function D({
|
|
26
|
+
children: n,
|
|
27
|
+
initialCurrencies: r,
|
|
28
|
+
initialCurrencyCode: i,
|
|
29
|
+
locale: f
|
|
30
|
+
}) {
|
|
31
|
+
const [t, y] = z(
|
|
32
|
+
() => g(r)
|
|
33
|
+
), c = v(
|
|
34
|
+
(o) => o.activeCurrencyCode
|
|
35
|
+
), d = v((o) => o.hasHydrated), s = v(
|
|
36
|
+
(o) => o.setActiveCurrencyCode
|
|
37
|
+
);
|
|
38
|
+
a(() => {
|
|
39
|
+
v.persist.rehydrate();
|
|
40
|
+
}, []), a(() => {
|
|
41
|
+
r.length > 0 && y(g(r));
|
|
42
|
+
}, [r]), a(() => {
|
|
43
|
+
if (r.length > 0)
|
|
44
|
+
return;
|
|
45
|
+
async function o() {
|
|
46
|
+
const { fetchActiveCurrenciesFromRest: m } = await import("./currency-rest-client.es.js"), p = await m();
|
|
47
|
+
p.length > 0 && y(
|
|
48
|
+
g(p.map((x) => M(x)))
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
o();
|
|
52
|
+
}, [r.length]);
|
|
53
|
+
const e = l(
|
|
54
|
+
() => L({
|
|
55
|
+
currencies: t,
|
|
56
|
+
storedCurrencyCode: c,
|
|
57
|
+
hasHydrated: d,
|
|
58
|
+
initialCurrencyCode: i,
|
|
59
|
+
locale: f
|
|
60
|
+
}),
|
|
61
|
+
[t, c, d, i, f]
|
|
62
|
+
);
|
|
63
|
+
a(() => {
|
|
64
|
+
e && c !== e && s(e);
|
|
65
|
+
}, [e, s, c]), a(() => {
|
|
66
|
+
!e || typeof document > "u" || (document.cookie = `${F}=${e}; Path=/; Max-Age=31536000; SameSite=Lax`);
|
|
67
|
+
}, [e]);
|
|
68
|
+
const u = l(
|
|
69
|
+
() => S(t),
|
|
70
|
+
[t]
|
|
71
|
+
), C = l(
|
|
72
|
+
() => t.find((o) => o.code === e) ?? u,
|
|
73
|
+
[t, u, e]
|
|
74
|
+
), P = l(
|
|
75
|
+
() => ({
|
|
76
|
+
currencies: t,
|
|
77
|
+
defaultCurrency: u,
|
|
78
|
+
activeCurrency: C,
|
|
79
|
+
activeCurrencyCode: C.code,
|
|
80
|
+
isHydrated: d,
|
|
81
|
+
setActiveCurrencyCode: (o) => {
|
|
82
|
+
const m = h(o);
|
|
83
|
+
t.some((x) => x.code === m) && s(m);
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
[C, t, u, d, s]
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ w(A.Provider, { value: P, children: n });
|
|
89
|
+
}
|
|
90
|
+
function I() {
|
|
91
|
+
const n = H(A);
|
|
92
|
+
if (!n)
|
|
93
|
+
throw new Error("useCurrency must be used inside a CurrencyProvider");
|
|
94
|
+
return n;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
D as CurrencyProvider,
|
|
98
|
+
I as useCurrency
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("zustand"),p=require("zustand/middleware"),o=require("./types.cjs.js"),k=require("./CurrencyProvider.cjs.js"),_=require("./currency.cjs.js");function a(r,c,e){return r.reduce((t,s)=>o.isDigitalItem(s)||s.sku!==c||e&&s.id===e?t:t+s.quantity,0)}const l=y.create()(p.persist((r,c)=>({items:[],appliedCoupon:null,isOpen:!1,addItem:e=>{const{items:t}=c(),s=e.quantity??1,i=typeof e.stock=="number"?e.stock:null,u=i!==null?a(t,e.sku):0;if(o.isDigitalItem(e))return t.find(d=>d.product_id===e.product_id&&o.isDigitalItem(d))?{success:!1,error:"This software license is already in your cart."}:(r({items:[...t,{...e,quantity:1}],isOpen:!0}),{success:!0});const C=t.find(n=>n.id===e.id);return i!==null&&i<=0?{success:!1,error:"This item is out of stock."}:i!==null&&u+s>i?{success:!1,error:`Only ${i} available for this SKU.`}:(r(C?{items:t.map(n=>n.id===e.id?{...n,...e,quantity:n.quantity+s}:n),isOpen:!0}:{items:[...t,{...e,quantity:s}],isOpen:!0}),{success:!0})},removeItem:e=>{const{items:t}=c();r({items:t.filter(s=>s.id!==e)})},updateQuantity:(e,t)=>{const{items:s}=c(),i=s.find(u=>u.id===e);i&&o.isDigitalItem(i)||(i&&typeof i.stock=="number"&&t+a(s,i.sku,e)>i.stock&&(t=Math.max(i.stock-a(s,i.sku,e),0)),t<=0?r({items:s.filter(u=>u.id!==e)}):r({items:s.map(u=>u.id===e?{...u,quantity:t}:u)}))},setAppliedCoupon:e=>{const t=c().appliedCoupon;t?.code===e?.code&&t?.couponId===e?.couponId||r({appliedCoupon:e})},removeCoupon:()=>{c().appliedCoupon&&r({appliedCoupon:null})},clearCart:()=>r({items:[],appliedCoupon:null}),toggleCart:()=>r(e=>({isOpen:!e.isOpen})),setIsOpen:e=>r({isOpen:e}),setItems:e=>r({items:e})}),{name:"cart-storage",storage:p.createJSONStorage(()=>localStorage),skipHydration:!0})),S=()=>l(c=>c.items).reduce((c,e)=>c+e.quantity,0);function f(r,c){return _.resolveEffectivePriceForCurrency({prices:r.prices,salePrices:r.sale_prices,fallbackPrice:r.price,fallbackSalePrice:r.sale_price,saleStartAt:r.sale_start_at,saleEndAt:r.sale_end_at,scheduledPrice:r.scheduled_price,scheduledPrices:r.scheduled_prices,scheduledPriceAt:r.scheduled_price_at,currencyCode:c.currencyCode,currencies:c.currencies})}const b=()=>{const r=l(t=>t.items),{activeCurrencyCode:c,currencies:e}=k.useCurrency();return r.reduce((t,s)=>{const{price:i,sale_price:u}=f(s,{currencyCode:c,currencies:e});return t+(u??i)*s.quantity},0)};exports.getCartItemActivePrice=f;exports.useCartStore=l;exports.useCartSubtotal=b;exports.useCartTotalItems=S;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create as f } from "zustand";
|
|
2
2
|
import { persist as C, createJSONStorage as y } from "zustand/middleware";
|
|
3
3
|
import { isDigitalItem as n } from "./types.es.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useCurrency as k } from "./CurrencyProvider.es.js";
|
|
5
5
|
import { resolveEffectivePriceForCurrency as _ } from "./currency.es.js";
|
|
6
6
|
function a(r, i, e) {
|
|
7
7
|
return r.reduce((s, t) => n(t) || t.sku !== i || e && t.id === e ? s : s + t.quantity, 0);
|
|
@@ -13,7 +13,7 @@ const p = f()(
|
|
|
13
13
|
appliedCoupon: null,
|
|
14
14
|
isOpen: !1,
|
|
15
15
|
addItem: (e) => {
|
|
16
|
-
const { items: s } = i(), t = e.quantity ?? 1, c = typeof e.stock == "number" ? e.stock : null,
|
|
16
|
+
const { items: s } = i(), t = e.quantity ?? 1, c = typeof e.stock == "number" ? e.stock : null, o = c !== null ? a(s, e.sku) : 0;
|
|
17
17
|
if (n(e))
|
|
18
18
|
return s.find(
|
|
19
19
|
(l) => l.product_id === e.product_id && n(l)
|
|
@@ -24,20 +24,20 @@ const p = f()(
|
|
|
24
24
|
items: [...s, { ...e, quantity: 1 }],
|
|
25
25
|
isOpen: !0
|
|
26
26
|
}), { success: !0 });
|
|
27
|
-
const d = s.find((
|
|
27
|
+
const d = s.find((u) => u.id === e.id);
|
|
28
28
|
return c !== null && c <= 0 ? {
|
|
29
29
|
success: !1,
|
|
30
30
|
error: "This item is out of stock."
|
|
31
|
-
} : c !== null &&
|
|
31
|
+
} : c !== null && o + t > c ? {
|
|
32
32
|
success: !1,
|
|
33
33
|
error: `Only ${c} available for this SKU.`
|
|
34
34
|
} : (r(d ? {
|
|
35
35
|
items: s.map(
|
|
36
|
-
(
|
|
37
|
-
...
|
|
36
|
+
(u) => u.id === e.id ? {
|
|
37
|
+
...u,
|
|
38
38
|
...e,
|
|
39
|
-
quantity:
|
|
40
|
-
} :
|
|
39
|
+
quantity: u.quantity + t
|
|
40
|
+
} : u
|
|
41
41
|
),
|
|
42
42
|
isOpen: !0
|
|
43
43
|
} : {
|
|
@@ -52,15 +52,15 @@ const p = f()(
|
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
54
|
updateQuantity: (e, s) => {
|
|
55
|
-
const { items: t } = i(), c = t.find((
|
|
55
|
+
const { items: t } = i(), c = t.find((o) => o.id === e);
|
|
56
56
|
c && n(c) || (c && typeof c.stock == "number" && s + a(t, c.sku, e) > c.stock && (s = Math.max(
|
|
57
57
|
c.stock - a(t, c.sku, e),
|
|
58
58
|
0
|
|
59
59
|
)), s <= 0 ? r({
|
|
60
|
-
items: t.filter((
|
|
60
|
+
items: t.filter((o) => o.id !== e)
|
|
61
61
|
}) : r({
|
|
62
62
|
items: t.map(
|
|
63
|
-
(
|
|
63
|
+
(o) => o.id === e ? { ...o, quantity: s } : o
|
|
64
64
|
)
|
|
65
65
|
}));
|
|
66
66
|
},
|
|
@@ -101,11 +101,11 @@ function S(r, i) {
|
|
|
101
101
|
const g = () => {
|
|
102
102
|
const r = p((s) => s.items), { activeCurrencyCode: i, currencies: e } = k();
|
|
103
103
|
return r.reduce((s, t) => {
|
|
104
|
-
const { price: c, sale_price:
|
|
104
|
+
const { price: c, sale_price: o } = S(t, {
|
|
105
105
|
currencyCode: i,
|
|
106
106
|
currencies: e
|
|
107
107
|
});
|
|
108
|
-
return s + (
|
|
108
|
+
return s + (o ?? c) * t.quantity;
|
|
109
109
|
}, 0);
|
|
110
110
|
};
|
|
111
111
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("next/link"),h=require("next/navigation"),i=require("lucide-react"),c=require("@nextblock-cms/utils");function u(t,s,a){const n=t(s);return n===s?a:n}function f(t){return t==="password"?i.KeyRound:i.Package2}function g({links:t,title:s,className:a}){const n=h.usePathname(),{t:o}=c.useTranslations();return t.length?r.jsxs("div",{className:c.cn("w-full space-y-3",a),children:[r.jsx("div",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:s||u(o,"account_navigation","Account")}),r.jsx("div",{className:"space-y-2",children:t.map(e=>{const l=f(e.icon),d=n===e.href||n.startsWith(`${e.href}/`);return r.jsxs(m,{href:e.href,className:c.cn("flex items-center gap-3 rounded-xl border px-3 py-2.5 text-sm font-medium transition-colors",d?"border-slate-900 bg-slate-900 text-white":"border-border bg-background hover:bg-muted/40"),children:[r.jsx(l,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{children:u(o,e.labelKey,e.fallbackLabel)})]},e.href)})})]}):null}exports.AccountNavigationMenu=g;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
3
|
+
import l from "next/link";
|
|
4
|
+
import { usePathname as f } from "next/navigation";
|
|
5
|
+
import { KeyRound as h, Package2 as p } from "lucide-react";
|
|
6
|
+
import { useTranslations as b, cn as i } from "@nextblock-cms/utils";
|
|
7
|
+
function m(r, n, o) {
|
|
8
|
+
const t = r(n);
|
|
9
|
+
return t === n ? o : t;
|
|
10
|
+
}
|
|
11
|
+
function g(r) {
|
|
12
|
+
return r === "password" ? h : p;
|
|
13
|
+
}
|
|
14
|
+
function A({
|
|
15
|
+
links: r,
|
|
16
|
+
title: n,
|
|
17
|
+
className: o
|
|
18
|
+
}) {
|
|
19
|
+
const t = f(), { t: s } = b();
|
|
20
|
+
return r.length ? /* @__PURE__ */ c("div", { className: i("w-full space-y-3", o), children: [
|
|
21
|
+
/* @__PURE__ */ a("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: n || m(s, "account_navigation", "Account") }),
|
|
22
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: r.map((e) => {
|
|
23
|
+
const u = g(e.icon), d = t === e.href || t.startsWith(`${e.href}/`);
|
|
24
|
+
return /* @__PURE__ */ c(
|
|
25
|
+
l,
|
|
26
|
+
{
|
|
27
|
+
href: e.href,
|
|
28
|
+
className: i(
|
|
29
|
+
"flex items-center gap-3 rounded-xl border px-3 py-2.5 text-sm font-medium transition-colors",
|
|
30
|
+
d ? "border-slate-900 bg-slate-900 text-white" : "border-border bg-background hover:bg-muted/40"
|
|
31
|
+
),
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ a(u, { className: "h-4 w-4 shrink-0" }),
|
|
34
|
+
/* @__PURE__ */ a("span", { children: m(s, e.labelKey, e.fallbackLabel) })
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
e.href
|
|
38
|
+
);
|
|
39
|
+
}) })
|
|
40
|
+
] }) : null;
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
A as AccountNavigationMenu
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("@nextblock-cms/ui/button"),_=require("lucide-react"),l=require("sonner"),v=require("next/link"),y=require("../use-cart.cjs.js"),q=require("@nextblock-cms/utils"),o=require("../types.cjs.js"),C=require("../CurrencyProvider.cjs.js"),b=({product:e,className:s,quantity:c})=>{const n=y.useCart(t=>t),{t:r}=q.useTranslations(),{activeCurrencyCode:d}=C.useCurrency();if(!!e.has_variants&&!e.variant_id&&!o.isDigitalProduct(e))return i.jsx(a.Button,{asChild:!0,className:s,children:i.jsx(v,{href:`/product/${e.slug}`,children:"Select Options"})});if(!n)return i.jsxs(a.Button,{disabled:!0,className:s,children:[i.jsx(_.ShoppingCart,{className:"mr-2 h-4 w-4"}),r("ecommerce.add_to_cart")]});const{addItem:u}=n,m=()=>{const t=o.getProductPaymentProvider(e)??"stripe",{success:g,error:h}=u({id:e.variant_id||e.id,product_id:e.id,title:e.title,price:e.price,prices:e.prices,sale_price:e.sale_price,sale_prices:e.sale_prices,is_taxable:e.is_taxable,image_url:e.image_url,slug:e.slug,sku:e.sku,stock:e.stock,language_id:e.language_id,translation_group_id:e.translation_group_id,product_type:e.product_type,payment_provider:e.payment_provider??t,provider:t,freemius_product_id:e.freemius_product_id,freemius_plan_id:e.freemius_plan_id,trial_period_days:e.trial_period_days??0,trial_requires_payment_method:e.trial_requires_payment_method??!1,has_variants:e.has_variants,variant_id:e.variant_id,variant_label:e.variant_label,selected_options:e.selected_options,currency_code:d,quantity:c});g?l.toast.success(r("ecommerce.added_to_cart_success",{item:e.title})):l.toast.error(h||r("ecommerce.added_to_cart_error"))};return i.jsxs(a.Button,{onClick:m,className:s,children:[i.jsx(_.ShoppingCart,{className:"mr-2 h-4 w-4"}),r("ecommerce.add_to_cart")]})};exports.AddToCartButton=b;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as a, jsxs as n } from "react/jsx-runtime";
|
|
2
|
-
import { Button as
|
|
3
|
+
import { Button as s } from "@nextblock-cms/ui/button";
|
|
3
4
|
import { ShoppingCart as o } from "lucide-react";
|
|
4
5
|
import { toast as l } from "sonner";
|
|
5
6
|
import p from "next/link";
|
|
6
|
-
import { useCart as g } from "
|
|
7
|
-
import { useTranslations as
|
|
8
|
-
import { isDigitalProduct as
|
|
9
|
-
import {
|
|
10
|
-
const V = ({ product: e, className:
|
|
11
|
-
const _ = g((r) => r), { t: i } =
|
|
12
|
-
if (!!e.has_variants && !e.variant_id && !
|
|
13
|
-
return /* @__PURE__ */ a(
|
|
7
|
+
import { useCart as g } from "../use-cart.es.js";
|
|
8
|
+
import { useTranslations as v } from "@nextblock-cms/utils";
|
|
9
|
+
import { isDigitalProduct as u, getProductPaymentProvider as y } from "../types.es.js";
|
|
10
|
+
import { useCurrency as C } from "../CurrencyProvider.es.js";
|
|
11
|
+
const V = ({ product: e, className: t, quantity: m }) => {
|
|
12
|
+
const _ = g((r) => r), { t: i } = v(), { activeCurrencyCode: d } = C();
|
|
13
|
+
if (!!e.has_variants && !e.variant_id && !u(e))
|
|
14
|
+
return /* @__PURE__ */ a(s, { asChild: !0, className: t, children: /* @__PURE__ */ a(p, { href: `/product/${e.slug}`, children: "Select Options" }) });
|
|
14
15
|
if (!_)
|
|
15
|
-
return /* @__PURE__ */ n(
|
|
16
|
+
return /* @__PURE__ */ n(s, { disabled: !0, className: t, children: [
|
|
16
17
|
/* @__PURE__ */ a(o, { className: "mr-2 h-4 w-4" }),
|
|
17
18
|
i("ecommerce.add_to_cart")
|
|
18
19
|
] });
|
|
19
20
|
const { addItem: c } = _;
|
|
20
|
-
return /* @__PURE__ */ n(
|
|
21
|
+
return /* @__PURE__ */ n(s, { onClick: () => {
|
|
21
22
|
const r = y(e) ?? "stripe", { success: f, error: h } = c({
|
|
22
23
|
id: e.variant_id || e.id,
|
|
23
24
|
product_id: e.id,
|
|
@@ -49,11 +50,11 @@ const V = ({ product: e, className: s, quantity: m }) => {
|
|
|
49
50
|
quantity: m
|
|
50
51
|
});
|
|
51
52
|
f ? l.success(i("ecommerce.added_to_cart_success", { item: e.title })) : l.error(h || i("ecommerce.added_to_cart_error"));
|
|
52
|
-
}, className:
|
|
53
|
+
}, className: t, children: [
|
|
53
54
|
/* @__PURE__ */ a(o, { className: "mr-2 h-4 w-4" }),
|
|
54
55
|
i("ecommerce.add_to_cart")
|
|
55
56
|
] });
|
|
56
57
|
};
|
|
57
58
|
export {
|
|
58
|
-
V as
|
|
59
|
+
V as AddToCartButton
|
|
59
60
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),C=require("react"),_=require("@nextblock-cms/ui/badge"),n=require("@nextblock-cms/ui/button"),r=require("@nextblock-cms/ui/table"),h=require("lucide-react"),j=require("../cart-store.cjs.js"),q=require("../use-cart.cjs.js"),o=require("../types.cjs.js"),T=require("next/navigation"),d=require("@nextblock-cms/utils"),w=require("./ShippingEstimator.cjs.js"),k=require("../CurrencyProvider.cjs.js"),S=require("../trials.cjs.js"),P=require("./CouponForm.cjs.js"),B=()=>{const g=T.useRouter(),u=q.useCart(s=>s),b=j.useCartSubtotal(),{t}=d.useTranslations(),{activeCurrencyCode:l,currencies:m}=k.useCurrency(),i=u?.items??[],f=C.useMemo(()=>i.reduce((s,a)=>{if(o.isDigitalItem(a))return s;const c=j.getCartItemActivePrice(a,{currencyCode:l,currencies:m});return s+(c.sale_price??c.price)*a.quantity},0),[l,m,i]);if(!u)return null;const{updateQuantity:p,removeItem:N}=u,v=s=>i.reduce((a,c)=>o.isDigitalItem(c)||c.sku!==s?a:a+c.quantity,0),y=()=>{g.push("/checkout")};return i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-12",children:[e.jsx("h2",{className:"text-2xl font-bold",children:t("ecommerce.cart_empty")}),e.jsx("p",{className:"text-muted-foreground",children:t("ecommerce.cart_empty_description")}),e.jsx(n.Button,{asChild:!0,children:e.jsx("a",{href:"/shop",children:t("ecommerce.continue_shopping")})})]}):e.jsxs("div",{className:"container mx-auto py-12",children:[e.jsx("h1",{className:"mb-8 text-3xl font-bold",children:t("ecommerce.shopping_cart")}),e.jsxs("div",{className:"grid gap-12 lg:grid-cols-12 lg:items-start",children:[e.jsx("div",{className:"lg:col-span-8",children:e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(r.Table,{children:[e.jsx(r.TableHeader,{children:e.jsxs(r.TableRow,{children:[e.jsx(r.TableHead,{children:t("ecommerce.product")}),e.jsx(r.TableHead,{children:t("ecommerce.quantity")}),e.jsx(r.TableHead,{className:"text-right",children:t("ecommerce.price")}),e.jsx(r.TableHead,{className:"text-right",children:t("ecommerce.total")}),e.jsx(r.TableHead,{className:"w-[50px]"})]})}),e.jsx(r.TableBody,{children:i.map(s=>{const a=v(s.sku),c=j.getCartItemActivePrice(s,{currencyCode:l,currencies:m}),x=S.getTrialSummary(s);return e.jsxs(r.TableRow,{children:[e.jsx(r.TableCell,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[s.image_url?e.jsx("div",{className:"h-16 w-16 overflow-hidden rounded border bg-neutral-100",children:e.jsx("img",{src:s.image_url,alt:s.title,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded bg-secondary",children:e.jsx("span",{className:"text-[10px] text-muted-foreground",children:t("ecommerce.no_image")})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.title}),s.variant_label&&e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s.variant_label}),o.isDigitalItem(s)&&s.billing_cycle&&e.jsxs("div",{className:"mt-1 text-xs capitalize text-muted-foreground",children:[s.billing_cycle," Subscription"]}),x&&e.jsxs("div",{className:"mt-1 text-xs font-medium text-emerald-700",children:[x.label," - ",x.paymentRequirementLabel]})]})]})}),e.jsx(r.TableCell,{children:o.isDigitalItem(s)?e.jsx(_.Badge,{variant:"secondary",className:"font-normal text-xs",children:"1 (License)"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n.Button,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>p(s.id,s.quantity-1),children:e.jsx(h.Minus,{className:"h-4 w-4"})}),e.jsx("span",{className:"w-8 text-center",children:s.quantity}),e.jsx(n.Button,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>p(s.id,s.quantity+1),disabled:typeof s.stock=="number"&&a>=s.stock,children:e.jsx(h.Plus,{className:"h-4 w-4"})})]})}),e.jsx(r.TableCell,{className:"text-right",children:e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"font-medium",children:d.formatPrice(c.sale_price??c.price,l)}),c.sale_price&&e.jsx("span",{className:"text-xs text-muted-foreground line-through",children:d.formatPrice(c.price,l)})]})}),e.jsx(r.TableCell,{className:"text-right font-medium",children:d.formatPrice((c.sale_price??c.price)*s.quantity,l)}),e.jsx(r.TableCell,{children:e.jsx(n.Button,{variant:"ghost",size:"icon",onClick:()=>N(s.id),className:"text-muted-foreground hover:text-destructive",children:e.jsx(h.Trash2,{className:"h-4 w-4"})})})]},s.id)})})]})})}),e.jsx("div",{className:"lg:col-span-4",children:e.jsxs("div",{className:"rounded-lg border bg-card p-6 shadow-sm",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold",children:t("ecommerce.order_summary")}),e.jsxs("div",{className:"flex justify-between border-b pb-4",children:[e.jsx("span",{children:t("ecommerce.subtotal")}),e.jsx("span",{className:"font-medium",children:d.formatPrice(b,l)})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("ecommerce.shipping_taxes_calculated")}),i.some(s=>!o.isDigitalItem(s))&&e.jsx(w.ShippingEstimator,{physicalSubtotal:f}),e.jsx(P.CouponForm,{items:i,currencyCode:l,compact:!0}),e.jsx(n.Button,{className:"w-full mt-4",size:"lg",onClick:y,children:t("ecommerce.proceed_to_checkout")})]})]})})]})]})};exports.Cart=B;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as k } from "react";
|
|
4
|
+
import { Badge as T } from "@nextblock-cms/ui/badge";
|
|
5
|
+
import { Button as n } from "@nextblock-cms/ui/button";
|
|
6
|
+
import { Table as q, TableHeader as S, TableRow as g, TableHead as o, TableBody as j, TableCell as d } from "@nextblock-cms/ui/table";
|
|
7
|
+
import { Minus as z, Plus as P, Trash2 as B } from "lucide-react";
|
|
8
|
+
import { useCartSubtotal as Q, getCartItemActivePrice as N } from "../cart-store.es.js";
|
|
9
|
+
import { useCart as R } from "../use-cart.es.js";
|
|
10
|
+
import { isDigitalItem as m } from "../types.es.js";
|
|
11
|
+
import { useRouter as A } from "next/navigation";
|
|
12
|
+
import { useTranslations as H, formatPrice as u } from "@nextblock-cms/utils";
|
|
13
|
+
import { ShippingEstimator as L } from "./ShippingEstimator.es.js";
|
|
14
|
+
import { useCurrency as M } from "../CurrencyProvider.es.js";
|
|
15
|
+
import { getTrialSummary as D } from "../trials.es.js";
|
|
16
|
+
import { CouponForm as E } from "./CouponForm.es.js";
|
|
17
|
+
const ce = () => {
|
|
18
|
+
const b = A(), h = R((r) => r), v = Q(), { t } = H(), { activeCurrencyCode: a, currencies: p } = M(), s = h?.items ?? [], y = k(
|
|
19
|
+
() => s.reduce((r, i) => {
|
|
20
|
+
if (m(i))
|
|
21
|
+
return r;
|
|
22
|
+
const l = N(i, {
|
|
23
|
+
currencyCode: a,
|
|
24
|
+
currencies: p
|
|
25
|
+
});
|
|
26
|
+
return r + (l.sale_price ?? l.price) * i.quantity;
|
|
27
|
+
}, 0),
|
|
28
|
+
[a, p, s]
|
|
29
|
+
);
|
|
30
|
+
if (!h) return null;
|
|
31
|
+
const { updateQuantity: x, removeItem: _ } = h, C = (r) => s.reduce((i, l) => m(l) || l.sku !== r ? i : i + l.quantity, 0), w = () => {
|
|
32
|
+
b.push("/checkout");
|
|
33
|
+
};
|
|
34
|
+
return s.length === 0 ? /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center space-y-4 py-12", children: [
|
|
35
|
+
/* @__PURE__ */ e("h2", { className: "text-2xl font-bold", children: t("ecommerce.cart_empty") }),
|
|
36
|
+
/* @__PURE__ */ e("p", { className: "text-muted-foreground", children: t("ecommerce.cart_empty_description") }),
|
|
37
|
+
/* @__PURE__ */ e(n, { asChild: !0, children: /* @__PURE__ */ e("a", { href: "/shop", children: t("ecommerce.continue_shopping") }) })
|
|
38
|
+
] }) : /* @__PURE__ */ c("div", { className: "container mx-auto py-12", children: [
|
|
39
|
+
/* @__PURE__ */ e("h1", { className: "mb-8 text-3xl font-bold", children: t("ecommerce.shopping_cart") }),
|
|
40
|
+
/* @__PURE__ */ c("div", { className: "grid gap-12 lg:grid-cols-12 lg:items-start", children: [
|
|
41
|
+
/* @__PURE__ */ e("div", { className: "lg:col-span-8", children: /* @__PURE__ */ e("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ c(q, { children: [
|
|
42
|
+
/* @__PURE__ */ e(S, { children: /* @__PURE__ */ c(g, { children: [
|
|
43
|
+
/* @__PURE__ */ e(o, { children: t("ecommerce.product") }),
|
|
44
|
+
/* @__PURE__ */ e(o, { children: t("ecommerce.quantity") }),
|
|
45
|
+
/* @__PURE__ */ e(o, { className: "text-right", children: t("ecommerce.price") }),
|
|
46
|
+
/* @__PURE__ */ e(o, { className: "text-right", children: t("ecommerce.total") }),
|
|
47
|
+
/* @__PURE__ */ e(o, { className: "w-[50px]" })
|
|
48
|
+
] }) }),
|
|
49
|
+
/* @__PURE__ */ e(j, { children: s.map((r) => {
|
|
50
|
+
const i = C(r.sku), l = N(r, {
|
|
51
|
+
currencyCode: a,
|
|
52
|
+
currencies: p
|
|
53
|
+
}), f = D(r);
|
|
54
|
+
return /* @__PURE__ */ c(g, { children: [
|
|
55
|
+
/* @__PURE__ */ e(d, { children: /* @__PURE__ */ c("div", { className: "flex items-center gap-4", children: [
|
|
56
|
+
r.image_url ? /* @__PURE__ */ e("div", { className: "h-16 w-16 overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e(
|
|
57
|
+
"img",
|
|
58
|
+
{
|
|
59
|
+
src: r.image_url,
|
|
60
|
+
alt: r.title,
|
|
61
|
+
className: "h-full w-full object-cover"
|
|
62
|
+
}
|
|
63
|
+
) }) : /* @__PURE__ */ e("div", { className: "flex h-16 w-16 items-center justify-center rounded bg-secondary", children: /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: t("ecommerce.no_image") }) }),
|
|
64
|
+
/* @__PURE__ */ c("div", { children: [
|
|
65
|
+
/* @__PURE__ */ e("div", { className: "font-medium", children: r.title }),
|
|
66
|
+
r.variant_label && /* @__PURE__ */ e("div", { className: "mt-1 text-xs text-muted-foreground", children: r.variant_label }),
|
|
67
|
+
m(r) && r.billing_cycle && /* @__PURE__ */ c("div", { className: "mt-1 text-xs capitalize text-muted-foreground", children: [
|
|
68
|
+
r.billing_cycle,
|
|
69
|
+
" Subscription"
|
|
70
|
+
] }),
|
|
71
|
+
f && /* @__PURE__ */ c("div", { className: "mt-1 text-xs font-medium text-emerald-700", children: [
|
|
72
|
+
f.label,
|
|
73
|
+
" - ",
|
|
74
|
+
f.paymentRequirementLabel
|
|
75
|
+
] })
|
|
76
|
+
] })
|
|
77
|
+
] }) }),
|
|
78
|
+
/* @__PURE__ */ e(d, { children: m(r) ? /* @__PURE__ */ e(T, { variant: "secondary", className: "font-normal text-xs", children: "1 (License)" }) : /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
79
|
+
/* @__PURE__ */ e(
|
|
80
|
+
n,
|
|
81
|
+
{
|
|
82
|
+
variant: "outline",
|
|
83
|
+
size: "icon",
|
|
84
|
+
className: "h-8 w-8",
|
|
85
|
+
onClick: () => x(r.id, r.quantity - 1),
|
|
86
|
+
children: /* @__PURE__ */ e(z, { className: "h-4 w-4" })
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ e("span", { className: "w-8 text-center", children: r.quantity }),
|
|
90
|
+
/* @__PURE__ */ e(
|
|
91
|
+
n,
|
|
92
|
+
{
|
|
93
|
+
variant: "outline",
|
|
94
|
+
size: "icon",
|
|
95
|
+
className: "h-8 w-8",
|
|
96
|
+
onClick: () => x(r.id, r.quantity + 1),
|
|
97
|
+
disabled: typeof r.stock == "number" && i >= r.stock,
|
|
98
|
+
children: /* @__PURE__ */ e(P, { className: "h-4 w-4" })
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
] }) }),
|
|
102
|
+
/* @__PURE__ */ e(d, { className: "text-right", children: /* @__PURE__ */ c("div", { className: "flex flex-col items-end", children: [
|
|
103
|
+
/* @__PURE__ */ e("span", { className: "font-medium", children: u(l.sale_price ?? l.price, a) }),
|
|
104
|
+
l.sale_price && /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground line-through", children: u(l.price, a) })
|
|
105
|
+
] }) }),
|
|
106
|
+
/* @__PURE__ */ e(d, { className: "text-right font-medium", children: u(
|
|
107
|
+
(l.sale_price ?? l.price) * r.quantity,
|
|
108
|
+
a
|
|
109
|
+
) }),
|
|
110
|
+
/* @__PURE__ */ e(d, { children: /* @__PURE__ */ e(
|
|
111
|
+
n,
|
|
112
|
+
{
|
|
113
|
+
variant: "ghost",
|
|
114
|
+
size: "icon",
|
|
115
|
+
onClick: () => _(r.id),
|
|
116
|
+
className: "text-muted-foreground hover:text-destructive",
|
|
117
|
+
children: /* @__PURE__ */ e(B, { className: "h-4 w-4" })
|
|
118
|
+
}
|
|
119
|
+
) })
|
|
120
|
+
] }, r.id);
|
|
121
|
+
}) })
|
|
122
|
+
] }) }) }),
|
|
123
|
+
/* @__PURE__ */ e("div", { className: "lg:col-span-4", children: /* @__PURE__ */ c("div", { className: "rounded-lg border bg-card p-6 shadow-sm", children: [
|
|
124
|
+
/* @__PURE__ */ e("h2", { className: "mb-4 text-lg font-semibold", children: t("ecommerce.order_summary") }),
|
|
125
|
+
/* @__PURE__ */ c("div", { className: "flex justify-between border-b pb-4", children: [
|
|
126
|
+
/* @__PURE__ */ e("span", { children: t("ecommerce.subtotal") }),
|
|
127
|
+
/* @__PURE__ */ e("span", { className: "font-medium", children: u(v, a) })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ c("div", { className: "mt-4 flex flex-col gap-4", children: [
|
|
130
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("ecommerce.shipping_taxes_calculated") }),
|
|
131
|
+
s.some((r) => !m(r)) && /* @__PURE__ */ e(L, { physicalSubtotal: y }),
|
|
132
|
+
/* @__PURE__ */ e(
|
|
133
|
+
E,
|
|
134
|
+
{
|
|
135
|
+
items: s,
|
|
136
|
+
currencyCode: a,
|
|
137
|
+
compact: !0
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ e(n, { className: "w-full mt-4", size: "lg", onClick: w, children: t("ecommerce.proceed_to_checkout") })
|
|
141
|
+
] })
|
|
142
|
+
] }) })
|
|
143
|
+
] })
|
|
144
|
+
] });
|
|
145
|
+
};
|
|
146
|
+
export {
|
|
147
|
+
ce as Cart
|
|
148
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("@nextblock-cms/ui/sheet"),_=require("@nextblock-cms/ui/badge"),d=require("@nextblock-cms/ui/button"),q=require("next/navigation"),m=require("lucide-react"),j=require("../cart-store.cjs.js"),k=require("../use-cart.cjs.js"),o=require("@nextblock-cms/utils"),p=require("../types.cjs.js"),S=require("../CurrencyProvider.cjs.js"),P=require("../trials.cjs.js"),D=require("./CouponForm.cjs.js"),T=()=>{const x=q.useRouter(),h=k.useCart(t=>t),b=j.useCartSubtotal(),{t:s}=o.useTranslations(),{activeCurrencyCode:c,currencies:g}=S.useCurrency();if(!h)return null;const{isOpen:y,setIsOpen:a,items:n,updateQuantity:f,removeItem:v}=h,N=t=>n.reduce((i,r)=>p.isDigitalItem(r)||r.sku!==t?i:i+r.quantity,0),w=()=>{a(!1),x.push("/cart")},C=()=>{a(!1),x.push("/checkout")};return e.jsx(l.Sheet,{open:y,onOpenChange:a,children:e.jsxs(l.SheetContent,{className:"flex w-full flex-col pr-0 sm:max-w-lg",children:[e.jsxs(l.SheetHeader,{className:"px-1 text-left",children:[e.jsxs(l.SheetTitle,{children:[s("ecommerce.shopping_cart")," (",n.length,")"]}),e.jsx(l.SheetDescription,{className:"sr-only",children:s("ecommerce.shopping_cart")})]}),n.length>0?e.jsx("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto p-1 pr-6 pt-4",children:n.map(t=>{const i=N(t.sku);return e.jsx("div",{className:"flex gap-4",children:(()=>{const r=j.getCartItemActivePrice(t,{currencyCode:c,currencies:g}),u=P.getTrialSummary(t);return e.jsxs(e.Fragment,{children:[t.image_url?e.jsx("div",{className:"relative aspect-square h-20 w-20 min-w-fit overflow-hidden rounded border bg-neutral-100",children:e.jsx("img",{src:t.image_url,alt:t.title,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded bg-secondary",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:s("ecommerce.no_image")})}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"line-clamp-2 text-sm font-medium leading-tight",children:t.title}),t.variant_label&&e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t.variant_label}),u&&e.jsxs("div",{className:"mt-1 text-xs font-medium text-emerald-700",children:[u.label," - ",u.paymentRequirementLabel]})]}),e.jsxs("span",{className:"text-sm font-semibold",children:[r.sale_price&&e.jsx("span",{className:"mr-1.5 text-xs font-normal text-muted-foreground line-through",children:o.formatPrice(r.price,c)}),o.formatPrice(r.sale_price??r.price,c)]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[p.isDigitalItem(t)?e.jsx(_.Badge,{variant:"secondary",className:"font-normal text-xs",children:"1 (License)"}):e.jsxs("div",{className:"flex items-center rounded-md border text-xs",children:[e.jsx("button",{onClick:()=>f(t.id,t.quantity-1),className:"flex h-7 w-7 items-center justify-center border-r",type:"button",children:e.jsx(m.Minus,{className:"h-3 w-3"})}),e.jsx("span",{className:"flex h-7 w-8 items-center justify-center",children:t.quantity}),e.jsx("button",{onClick:()=>f(t.id,t.quantity+1),className:"flex h-7 w-7 items-center justify-center border-l",type:"button",disabled:typeof t.stock=="number"&&i>=t.stock,children:e.jsx(m.Plus,{className:"h-3 w-3"})})]}),e.jsx("button",{onClick:()=>v(t.id),className:"text-muted-foreground hover:text-destructive",type:"button",children:e.jsx(m.Trash2,{className:"h-4 w-4"})})]})]})]})})()},t.id)})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center space-y-2",children:[e.jsx("span",{className:"text-muted-foreground",children:s("ecommerce.cart_empty")}),e.jsx(d.Button,{variant:"outline",onClick:()=>a(!1),children:s("ecommerce.continue_shopping")})]}),n.length>0&&e.jsxs("div",{className:"border-t pr-6 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-base font-medium",children:[e.jsx("span",{children:s("ecommerce.subtotal")}),e.jsx("span",{children:o.formatPrice(b,c)})]}),e.jsx("p",{className:"mb-4 mt-1 text-xs text-muted-foreground",children:s("ecommerce.shipping_taxes_calculated")}),e.jsx("div",{className:"mb-4",children:e.jsx(D.CouponForm,{items:n,currencyCode:c,compact:!0})}),e.jsx(d.Button,{variant:"outline",className:"w-full mb-3",onClick:w,children:s("ecommerce.view_full_cart")}),e.jsx(d.Button,{className:"w-full",onClick:C,children:s("ecommerce.ready_to_checkout")})]})]})})};exports.CartDrawer=T;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as e, jsxs as r, Fragment as C } from "react/jsx-runtime";
|
|
2
3
|
import { Sheet as _, SheetContent as k, SheetHeader as j, SheetTitle as S, SheetDescription as q } from "@nextblock-cms/ui/sheet";
|
|
3
4
|
import { Badge as P } from "@nextblock-cms/ui/badge";
|
|
@@ -8,13 +9,13 @@ import { useCartSubtotal as A, getCartItemActivePrice as B } from "../cart-store
|
|
|
8
9
|
import { useCart as F } from "../use-cart.es.js";
|
|
9
10
|
import { useTranslations as I, formatPrice as d } from "@nextblock-cms/utils";
|
|
10
11
|
import { isDigitalItem as p } from "../types.es.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { useCurrency as L } from "../CurrencyProvider.es.js";
|
|
13
|
+
import { getTrialSummary as R } from "../trials.es.js";
|
|
14
|
+
import { CouponForm as H } from "./CouponForm.es.js";
|
|
14
15
|
const ee = () => {
|
|
15
|
-
const u = T(), h = F((t) => t), x = A(), { t: l } = I(), { activeCurrencyCode:
|
|
16
|
+
const u = T(), h = F((t) => t), x = A(), { t: l } = I(), { activeCurrencyCode: s, currencies: y } = L();
|
|
16
17
|
if (!h) return null;
|
|
17
|
-
const { isOpen: N, setIsOpen: a, items:
|
|
18
|
+
const { isOpen: N, setIsOpen: a, items: n, updateQuantity: f, removeItem: g } = h, b = (t) => n.reduce((i, c) => p(c) || c.sku !== t ? i : i + c.quantity, 0), v = () => {
|
|
18
19
|
a(!1), u.push("/cart");
|
|
19
20
|
}, w = () => {
|
|
20
21
|
a(!1), u.push("/checkout");
|
|
@@ -24,16 +25,16 @@ const ee = () => {
|
|
|
24
25
|
/* @__PURE__ */ r(S, { children: [
|
|
25
26
|
l("ecommerce.shopping_cart"),
|
|
26
27
|
" (",
|
|
27
|
-
|
|
28
|
+
n.length,
|
|
28
29
|
")"
|
|
29
30
|
] }),
|
|
30
31
|
/* @__PURE__ */ e(q, { className: "sr-only", children: l("ecommerce.shopping_cart") })
|
|
31
32
|
] }),
|
|
32
|
-
|
|
33
|
+
n.length > 0 ? /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col gap-5 overflow-y-auto p-1 pr-6 pt-4", children: n.map((t) => {
|
|
33
34
|
const i = b(t.sku);
|
|
34
35
|
return /* @__PURE__ */ e("div", { className: "flex gap-4", children: (() => {
|
|
35
|
-
const
|
|
36
|
-
currencyCode:
|
|
36
|
+
const c = B(t, {
|
|
37
|
+
currencyCode: s,
|
|
37
38
|
currencies: y
|
|
38
39
|
}), o = R(t);
|
|
39
40
|
return /* @__PURE__ */ r(C, { children: [
|
|
@@ -57,8 +58,8 @@ const ee = () => {
|
|
|
57
58
|
] })
|
|
58
59
|
] }),
|
|
59
60
|
/* @__PURE__ */ r("span", { className: "text-sm font-semibold", children: [
|
|
60
|
-
|
|
61
|
-
d(
|
|
61
|
+
c.sale_price && /* @__PURE__ */ e("span", { className: "mr-1.5 text-xs font-normal text-muted-foreground line-through", children: d(c.price, s) }),
|
|
62
|
+
d(c.sale_price ?? c.price, s)
|
|
62
63
|
] })
|
|
63
64
|
] }),
|
|
64
65
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between text-sm", children: [
|
|
@@ -101,13 +102,13 @@ const ee = () => {
|
|
|
101
102
|
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: l("ecommerce.cart_empty") }),
|
|
102
103
|
/* @__PURE__ */ e(m, { variant: "outline", onClick: () => a(!1), children: l("ecommerce.continue_shopping") })
|
|
103
104
|
] }),
|
|
104
|
-
|
|
105
|
+
n.length > 0 && /* @__PURE__ */ r("div", { className: "border-t pr-6 pt-4", children: [
|
|
105
106
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between text-base font-medium", children: [
|
|
106
107
|
/* @__PURE__ */ e("span", { children: l("ecommerce.subtotal") }),
|
|
107
|
-
/* @__PURE__ */ e("span", { children: d(x,
|
|
108
|
+
/* @__PURE__ */ e("span", { children: d(x, s) })
|
|
108
109
|
] }),
|
|
109
110
|
/* @__PURE__ */ e("p", { className: "mb-4 mt-1 text-xs text-muted-foreground", children: l("ecommerce.shipping_taxes_calculated") }),
|
|
110
|
-
/* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e(H, { items:
|
|
111
|
+
/* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e(H, { items: n, currencyCode: s, compact: !0 }) }),
|
|
111
112
|
/* @__PURE__ */ e(m, { variant: "outline", className: "w-full mb-3", onClick: v, children: l("ecommerce.view_full_cart") }),
|
|
112
113
|
/* @__PURE__ */ e(m, { className: "w-full", onClick: w, children: l("ecommerce.ready_to_checkout") })
|
|
113
114
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("@nextblock-cms/ui/badge"),a=require("@nextblock-cms/ui/button"),s=require("lucide-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("@nextblock-cms/ui/badge"),a=require("@nextblock-cms/ui/button"),s=require("lucide-react"),i=require("../cart-store.cjs.js"),c=require("../use-cart.cjs.js"),l=()=>{const n=i.useCartStore(t=>t.toggleCart),r=i.useCartTotalItems();return c.useCart(t=>t.isOpen)!==void 0?e.jsxs(a.Button,{variant:"ghost",size:"icon",className:"relative",onClick:n,"aria-label":"Open cart",children:[e.jsx(s.ShoppingBag,{className:"h-5 w-5"}),r>0&&e.jsx(o.Badge,{variant:"destructive",className:"absolute -right-1 -top-1 h-4 w-4 items-center justify-center p-0 text-[10px]",children:r})]}):e.jsx(a.Button,{variant:"ghost",size:"icon",className:"relative","aria-label":"Open cart",children:e.jsx(s.ShoppingBag,{className:"h-5 w-5"})})};exports.CartIcon=l;
|