11<template >
2- <div v-if =" allCategoryProducts?.productCategory?.products?.nodes" >
2+ <template v-if =" allCategoryProducts ?.productCategory ?.products ?.nodes " >
33 <section >
44 <div id =" product-container" class =" flex flex-wrap items-center" >
55 <template
1717 query: { id: product.databaseId },
1818 }"
1919 >
20- <img
21- id =" product-image"
22- class =" p-8 border mx-auto w-4/5 border-gray-200 rounded drop-shadow-lg transition duration-500 ease-in-out transform cursor-pointer lg:ml-0 lg:w-full lg:p-2 hover:scale-95"
23- :alt =" product.name"
24- :src =" productImage(product)"
25- />
20+ <ProductImage :alt =" product.name" :src =" productImage(product)" />
21+
2622 <div class =" flex justify-center pt-3" >
2723 <p class =" text-2xl font-bold text-center cursor-pointer" >
2824 {{ product.name }}
2925 </p >
3026 </div >
3127 </NuxtLink >
32- <div v-if =" product.onSale" class =" flex justify-center mt-2" >
33- <div class =" text-lg text-gray-900 line-through" >
34- <span v-if =" product.variations" >
35- {{ filteredVariantPrice(product.price, "right") }}</span
36- >
37- <span v-else >{{ product.regularPrice }}</span >
38- </div >
39- <div class =" ml-4 text-xl text-gray-900" >
40- <span v-if =" product.variations" >
41- {{ filteredVariantPrice(product.price) }}</span
42- >
43- <span v-else >{{ product.salePrice }}</span >
44- </div >
45- </div >
46- <div v-else >
47- <p class =" mt-2 text-xl text-center text-gray-900" >
48- {{ product.price }}
49- </p >
50- </div >
28+ <ProductPrice
29+ :product =" product"
30+ priceFontSize =" normal"
31+ :shouldCenterPrice =" true"
32+ />
5133 </div >
5234 </template >
5335 </div >
5436 </section >
55- </div >
37+ </template >
5638 <div v-else >
5739 <section >
5840 <div id =" product-container" class =" flex flex-wrap items-center" >
6951 query: { id: product.databaseId },
7052 }"
7153 >
72- <img
73- id =" product-image"
74- class =" p-8 border mx-auto w-4/5 border-gray-200 rounded drop-shadow-lg transition duration-500 ease-in-out transform cursor-pointer lg:ml-0 lg:w-full lg:p-2 hover:scale-95"
75- :alt =" product.name"
76- :src =" productImage(product)"
77- />
54+ <ProductImage :alt =" product.name" :src =" productImage(product)" />
7855 <div class =" flex justify-center pt-3" >
7956 <p class =" text-2xl font-bold text-center cursor-pointer" >
8057 {{ product.name }}
8158 </p >
8259 </div >
8360 </NuxtLink >
84- <div v-if =" product.onSale" class =" flex justify-center mt-2" >
85- <div class =" text-lg text-gray-900 line-through" >
86- <span v-if =" product.variations" >
87- {{ filteredVariantPrice(product.price, "right") }}</span
88- >
89- <span v-else >{{ product.regularPrice }}</span >
90- </div >
91- <div class =" ml-4 text-xl text-gray-900" >
92- <span v-if =" product.variations" >
93- {{ filteredVariantPrice(product.price) }}</span
94- >
95- <span v-else >{{ product.salePrice }}</span >
96- </div >
97- </div >
98- <div v-else >
99- <p class =" mt-2 text-xl text-center text-gray-900" >
100- {{ product.price }}
101- </p >
102- </div >
61+ <ProductPrice
62+ :product =" product"
63+ priceFontSize =" normal"
64+ :shouldCenterPrice =" true"
65+ />
10366 </div >
10467 </template >
10568 </div >
11174import FETCH_ALL_PRODUCTS_QUERY from " @/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql" ;
11275import GET_PRODUCTS_FROM_CATEGORY_QUERY from " @/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql" ;
11376
114- import { filteredVariantPrice } from " @/utils/functions" ;
77+ import ProductImage from " @/components/Products/ProductImage.vue" ;
78+ import ProductPrice from " @/components/Products/ProductPrice.vue" ;
11579
11680const props = defineProps ({
11781 categoryId: { type: String , required: false },
@@ -121,7 +85,7 @@ const props = defineProps({
12185const config = useRuntimeConfig ();
12286
12387const productImage = (product ) =>
124- product .image ? product .image .sourceUrl : config .placeholderImage ;
88+ product .image ? product .image .sourceUrl : config .public . placeholderImage ;
12589
12690const productVariables = { limit: 99 };
12791const { data: allProducts } = await useAsyncQuery (
0 commit comments