diff --git a/packages/commerce/components/buy/carousel-buy-card.tsx b/packages/commerce/components/buy/carousel-buy-card.tsx index 7f701343..81b96556 100644 --- a/packages/commerce/components/buy/carousel-buy-card.tsx +++ b/packages/commerce/components/buy/carousel-buy-card.tsx @@ -203,7 +203,7 @@ const CarouselBuyCard: React.FC<{
= ({ ))} - - + {r.current.items.length > 1 && (<> + + + )} )} diff --git a/packages/commerce/components/cart/cart-panel/cart-line-item.tsx b/packages/commerce/components/cart/cart-panel/cart-line-item.tsx index 69cb91c5..4ed4f7a4 100644 --- a/packages/commerce/components/cart/cart-panel/cart-line-item.tsx +++ b/packages/commerce/components/cart/cart-panel/cart-line-item.tsx @@ -61,7 +61,7 @@ const CartLineItem: React.FC<{
- + {item.quantity > 1 && ({'@' + formatCurrencyValue(item.price)})}
diff --git a/packages/commerce/context/commerce-ui.ts b/packages/commerce/context/commerce-ui.ts index 07e4a4f9..afac2f7c 100644 --- a/packages/commerce/context/commerce-ui.ts +++ b/packages/commerce/context/commerce-ui.ts @@ -4,22 +4,20 @@ import { makeObservable, observable, } from 'mobx' -import type { CommerceService, LineItem } from '../types' +import type { CommerceService, LineItem, ObsLineItemRef } from '../types' - -interface CommerceUI { +interface CommerceUI extends ObsLineItemRef { showBuyOptions: (skuPath: string) => void hideBuyOptions: () => void get buyOptionsSkuPath(): string | undefined - itemQuantityChanged(item: LineItem, val: number, prevVal: number): void - get activeItem(): LineItem | undefined + itemQuantityChanged(item: LineItem, val: number, prevVal: number): void } class CommerceUIStore implements CommerceUI { - static readonly TIMEOUT = 2500 + static readonly TIMEOUT = 1500 _buyOptionsSkuPath: string | undefined = undefined _paused: boolean = false _activeItem: LineItem | undefined = undefined @@ -36,7 +34,7 @@ class CommerceUIStore implements CommerceUI { buyOptionsSkuPath: computed, itemQuantityChanged: action, tick: action, - activeItem: computed + item: computed }) } @@ -92,7 +90,7 @@ class CommerceUIStore implements CommerceUI { } } - get activeItem(): LineItem | undefined { + get item(): LineItem | undefined { return this._activeItem } } diff --git a/packages/commerce/context/index.tsx b/packages/commerce/context/index.tsx index c6e7dc14..61989d47 100644 --- a/packages/commerce/context/index.tsx +++ b/packages/commerce/context/index.tsx @@ -37,19 +37,22 @@ const CommerceProvider: React.FC + DEBUG_NO_TICK?: boolean }> = ({ children, families, rootNode, options, - uiSpecs + uiSpecs, + DEBUG_NO_TICK=false }) => { useEffect(() => { + if (DEBUG_NO_TICK) return const intervalId = setInterval(() => { (valueRef.current.ui as CommerceUIStore).tick() }, 250) - return () => {clearInterval(intervalId)} + return () => { clearInterval(intervalId) } }, []) // TODO: Inject Promo fixture here from siteDef diff --git a/packages/commerce/index.ts b/packages/commerce/index.ts index 77a5e7e4..721c6484 100644 --- a/packages/commerce/index.ts +++ b/packages/commerce/index.ts @@ -1,5 +1,6 @@ export * from './context' export * from './components' + // Impl-dependent, so leave w impl export type { StandaloneServiceOptions as ServiceOptions } from './service/impls/standalone/standalone-service' export { useSyncSkuParamWithCurrentItem, diff --git a/packages/commerce/util/line-item-ref.ts b/packages/commerce/util/line-item-ref.ts index b6d888f6..da560f11 100644 --- a/packages/commerce/util/line-item-ref.ts +++ b/packages/commerce/util/line-item-ref.ts @@ -16,6 +16,7 @@ class LineItemRef implements ObsLineItemRef { } get item(): LineItem | undefined { return this._item } + set = (v: LineItem | undefined): void => { this._item = v } }