1
1
<template >
2
- <div v-if =" allCategoryProducts?.productCategory?.products?.nodes" >
2
+ <template v-if =" allCategoryProducts ?.productCategory ?.products ?.nodes " >
3
3
<section >
4
4
<div id =" product-container" class =" flex flex-wrap items-center" >
5
5
<template
17
17
query: { id: product.databaseId },
18
18
}"
19
19
>
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
+
26
22
<div class =" flex justify-center pt-3" >
27
23
<p class =" text-2xl font-bold text-center cursor-pointer" >
28
24
{{ product.name }}
29
25
</p >
30
26
</div >
31
27
</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
+ />
51
33
</div >
52
34
</template >
53
35
</div >
54
36
</section >
55
- </div >
37
+ </template >
56
38
<div v-else >
57
39
<section >
58
40
<div id =" product-container" class =" flex flex-wrap items-center" >
69
51
query: { id: product.databaseId },
70
52
}"
71
53
>
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)" />
78
55
<div class =" flex justify-center pt-3" >
79
56
<p class =" text-2xl font-bold text-center cursor-pointer" >
80
57
{{ product.name }}
81
58
</p >
82
59
</div >
83
60
</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
+ />
103
66
</div >
104
67
</template >
105
68
</div >
111
74
import FETCH_ALL_PRODUCTS_QUERY from " @/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql" ;
112
75
import GET_PRODUCTS_FROM_CATEGORY_QUERY from " @/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql" ;
113
76
114
- import { filteredVariantPrice } from " @/utils/functions" ;
77
+ import ProductImage from " @/components/Products/ProductImage.vue" ;
78
+ import ProductPrice from " @/components/Products/ProductPrice.vue" ;
115
79
116
80
const props = defineProps ({
117
81
categoryId: { type: String , required: false },
@@ -121,7 +85,7 @@ const props = defineProps({
121
85
const config = useRuntimeConfig ();
122
86
123
87
const productImage = (product ) =>
124
- product .image ? product .image .sourceUrl : config .placeholderImage ;
88
+ product .image ? product .image .sourceUrl : config .public . placeholderImage ;
125
89
126
90
const productVariables = { limit: 99 };
127
91
const { data: allProducts } = await useAsyncQuery (
0 commit comments