diff --git a/src/advisor-view.component.vue b/src/advisor-view.component.vue index 3343af0..8324d2e 100644 --- a/src/advisor-view.component.vue +++ b/src/advisor-view.component.vue @@ -10,8 +10,6 @@ - - @@ -40,7 +38,6 @@ import PageComponent from './components/page/page.component.vue'; import ModalComponent from './components/modal/modal.teleport.component.vue'; import ComparisonComponent from './components/comparison/comparison.teleport.component.vue'; import ToastComponent from './components/toast/toast.teleport.component.vue'; -import ZoeDock from './components/zoe/zoe-dock.teleport.component.vue'; import './css/tokens.css'; import './css/variables.css'; diff --git a/src/components/product-card/components/product-card-footer/product-card-footer.component.vue b/src/components/product-card/components/product-card-footer/product-card-footer.component.vue index 240efa5..4a0c5ab 100644 --- a/src/components/product-card/components/product-card-footer/product-card-footer.component.vue +++ b/src/components/product-card/components/product-card-footer/product-card-footer.component.vue @@ -86,6 +86,7 @@ const props = defineProps<{ isInSummary: boolean; trackedUrl: string; addToCartToastText: string; + addToCartErrorToastText: string; compareLabel: string; startComparisonLabel: string; addToSummaryLabel: string; @@ -101,7 +102,7 @@ defineEmits<{ const { canStartComparison } = useComparisonState(); const { recordClickout } = useProductClickout(() => props.product); -const { recordAddToCart } = useProductAddToCart(() => props.product); +const { addToCart } = useProductAddToCart(() => props.product); const toggleCompare = () => { props.product.toggleSelection?.(); @@ -116,18 +117,16 @@ const openComparison = () => { EventBus.$emit('zv:modal:open:comparison'); }; -const handleAddToCart = (): void => { - // TODO: wire up your shop's cart API here. - // The full product is available as `props.product` (sku, productId, name, price, etc.). - // Example: - // fetch('/api/cart', { method: 'POST', body: JSON.stringify({ sku: props.product.sku }) }); - // Tracking: recordAddToCart() sends "add-to-cart"; call it - // only after your cart call succeeds. - recordAddToCart(); +const showToast = (toast: { message: string; variant?: 'error' }): void => { + EventBus.$emit('zv:toast:show', toast); +}; - EventBus.$emit('zv:toast:show', { - message: props.addToCartToastText, - }); +const handleAddToCart = async (): Promise => { + if (await addToCart()) { + showToast({ message: props.addToCartToastText }); + } else { + showToast({ message: props.addToCartErrorToastText, variant: 'error' }); + } }; diff --git a/src/components/product-card/product-card.component.vue b/src/components/product-card/product-card.component.vue index 76b72c4..44f4e99 100644 --- a/src/components/product-card/product-card.component.vue +++ b/src/components/product-card/product-card.component.vue @@ -55,6 +55,9 @@ :is-in-summary="isInSummary" :tracked-url="trackedUrl" :add-to-cart-toast-text="componentConfiguration.addToCartToastText" + :add-to-cart-error-toast-text=" + componentConfiguration.addToCartErrorToastText + " :compare-label="t(componentConfiguration.compareLabel)" :start-comparison-label=" t(componentConfiguration.startComparisonLabel) diff --git a/src/components/product-card/product-card.configuration.ts b/src/components/product-card/product-card.configuration.ts index fbb0016..c5eb31d 100644 --- a/src/components/product-card/product-card.configuration.ts +++ b/src/components/product-card/product-card.configuration.ts @@ -10,4 +10,5 @@ export class ProductCardConfiguration { addedToSummaryLabel!: string; opensInNewTabLabel!: string; addToCartToastText!: string; + addToCartErrorToastText!: string; } diff --git a/src/components/product-card/product-card.preset.ts b/src/components/product-card/product-card.preset.ts index 2abcfde..daf5904 100644 --- a/src/components/product-card/product-card.preset.ts +++ b/src/components/product-card/product-card.preset.ts @@ -44,6 +44,10 @@ export const productCardPreset = object( default: 'Added to cart', label: 'Add To Cart Toast Text', }), + addToCartErrorToastText: standardText({ + default: 'Please try again. This product is not in your cart yet.', + label: 'Add To Cart Error Toast Text', + }), }, { label: 'Product Card', format: EmbeddedComponentParameterFormat.ACCORDION }, ); diff --git a/src/components/results-page/results-page.component.vue b/src/components/results-page/results-page.component.vue index 7d1af08..2f288c3 100644 --- a/src/components/results-page/results-page.component.vue +++ b/src/components/results-page/results-page.component.vue @@ -5,9 +5,14 @@ -

- {{ t(componentConfiguration.headlineText) }} -

+
+

+ {{ t(componentConfiguration.headlineText) }} +

+

+ {{ t(componentConfiguration.subheadlineText) }} +

+