@@ -8,6 +8,7 @@ const localePath = useLocalePath();
88import ' swiper/css' ;
99import ' swiper/css/navigation' ;
1010import ' swiper/css/pagination' ;
11+ import ProductPrice from " ~/components/ProductPrice.vue" ;
1112
1213const thumbsSwiper = ref (null );
1314const setThumbsSwiper = swiper => {
@@ -51,13 +52,6 @@ watchEffect(() => {
5152 }
5253});
5354
54- const calculateDiscountPercentage = computed (() => {
55- if (! product .value .salePrice || ! product .value .regularPrice ) return 0 ;
56- const salePriceValue = parseFloat (product .value .salePrice .replace (/ [^ 0-9 ] / g , ' ' ));
57- const regularPriceValue = parseFloat (product .value .regularPrice .replace (/ [^ 0-9 ] / g , ' ' ));
58- return Math .round (((salePriceValue - regularPriceValue) / regularPriceValue) * 100 );
59- });
60-
6155const { name } = useAppConfig ();
6256const url = useRequestURL ();
6357const canonical = url .origin + url .pathname ;
@@ -159,17 +153,7 @@ const { handleAddToCart, addToCartButtonStatus } = useCart();
159153 < div class = " flex-col flex gap-4 lg:max-h-[530px] xl:max-h-[600px] overflow-hidden" >
160154 < div class = " p-3 lg:pb-4 lg:p-0 border-b border-[#efefef] dark:border-[#262626]" >
161155 < h1 class = " text-2xl font-semibold mb-1" > {{ product .name }}< / h1>
162- < div class = " flex justify-between flex-row items-baseline" >
163- < div class = " flex flex-row items-baseline" >
164- < p class = " text-xl font-bold text-alizarin-crimson-700" v- html= " product.salePrice" >< / p>
165- < p class = " text-sm ml-2" > {{ $t (' product.vat_included' ) }}< / p>
166- < / div>
167- < / div>
168- < div class = " flex-wrap items-baseline flex-row flex" >
169- < p class = " text-sm" > {{ $t (' product.originally' ) }}: < / p>
170- < p class = " text-sm ml-1 line-through" v- html= " product.regularPrice" >< / p>
171- < p class = " text-sm ml-1 text-alizarin-crimson-700" > {{ calculateDiscountPercentage }}% < / p>
172- < / div>
156+ < ProductPrice : sale- price= " product.salePrice" : regular- price= " product.regularPrice" / >
173157 < / div>
174158
175159 < div class = " flex gap-2 px-3 lg:px-0" v- for = " (variation, i) in product.productTypes?.nodes" : key= " i" >
@@ -178,12 +162,12 @@ const { handleAddToCart, addToCartButtonStatus } = useCart();
178162 : to= " localePath(`/product/${vars.slug}-${product.sku.split('-')[0]}`)"
179163 : class = " [
180164 'flex w-12 rounded-lg border-2 select-varitaion transition-all duration-200 bg-neutral-200 dark:bg-neutral-800',
181- vars.allPaColor .nodes[0].name === product.allPaColor .nodes[0].name ? 'selected-varitaion' : 'border-[#9b9b9b] dark:border-[#8c8c8c]',
165+ vars.allPaStyle? .nodes[0]? .name === product.allPaStyle .nodes[0].name ? 'selected-varitaion' : 'border-[#9b9b9b] dark:border-[#8c8c8c]',
182166 ]" >
183167 < NuxtImg
184- : alt= " vars.allPaColor.nodes[0].name"
168+ : alt= " vars.allPaColor? .nodes[0]? .name"
185169 : src= " vars.image.sourceUrl"
186- : title= " vars.allPaColor.nodes[0].name"
170+ : title= " vars.allPaColor? .nodes[0]? .name"
187171 class = " rounded-md border-2 border-white dark:border-black" / >
188172 < / NuxtLink>
189173 < / div>
0 commit comments