File tree Expand file tree Collapse file tree 4 files changed +22
-32
lines changed Expand file tree Collapse file tree 4 files changed +22
-32
lines changed Original file line number Diff line number Diff line change 24
24
</template >
25
25
26
26
<script setup>
27
- import FETCH_ALL_PRODUCTS_QUERY from " @/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql" ;
28
- import GET_PRODUCTS_FROM_CATEGORY_QUERY from " @/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql" ;
29
-
30
27
import ProductImage from " @/components/Products/ProductImage.vue" ;
31
28
import ProductPrice from " @/components/Products/ProductPrice.vue" ;
32
29
33
- const props = defineProps ({
34
- categoryId: { type: String , required: false },
35
- categorySlug: { type: String , required: false },
36
- });
37
-
38
30
const config = useRuntimeConfig ();
39
31
40
- const products = computed (() => {
41
- return (
42
- allCategoryProducts .value ? .productCategory ? .products ? .nodes ||
43
- allProducts .value ? .products ? .nodes ||
44
- []
45
- );
32
+ const props = defineProps ({
33
+ products: {
34
+ type: Array ,
35
+ required: true ,
36
+ },
46
37
});
47
38
48
39
/**
@@ -68,18 +59,6 @@ const productLink = (product) => {
68
59
*/
69
60
const productImage = (product ) =>
70
61
product .image ? product .image .sourceUrl : config .public .placeholderImage ;
71
-
72
- const productVariables = { limit: 99 };
73
- const { data: allProducts } = await useAsyncQuery (
74
- FETCH_ALL_PRODUCTS_QUERY ,
75
- productVariables,
76
- );
77
-
78
- const categoryVariables = { id: props .categoryId };
79
- const { data: allCategoryProducts } = await useAsyncQuery (
80
- GET_PRODUCTS_FROM_CATEGORY_QUERY ,
81
- categoryVariables,
82
- );
83
62
</script >
84
63
85
64
<style scoped>
Original file line number Diff line number Diff line change 1
1
<template >
2
- <ProductsShowAll
3
- :category-id =" route.query.id"
4
- :category-slug =" route.params.product"
5
- />
2
+ <ProductsShowAll :products =" products" />
6
3
</template >
7
4
8
5
<script setup>
6
+ import GET_PRODUCTS_FROM_CATEGORY_QUERY from " @/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql" ;
9
7
const route = useRoute ();
10
8
9
+ const { data } = await useAsyncQuery (GET_PRODUCTS_FROM_CATEGORY_QUERY , { id: route .query .id });
10
+ const products = computed (() => data .value ? .productCategory ? .products ? .nodes || []);
11
+
11
12
useHead ({
12
13
title: route .params .category ,
13
14
titleTemplate: " %s - Nuxt 3 Woocommerce" ,
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
3
<IndexHero />
4
- <ProductsShowAll />
4
+ <ProductsShowAll :products = " products " />
5
5
</div >
6
6
</template >
7
7
8
8
<script setup>
9
+ import FETCH_ALL_PRODUCTS_QUERY from " @/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql" ;
10
+
11
+ const { data } = await useAsyncQuery (FETCH_ALL_PRODUCTS_QUERY );
12
+ const products = computed (() => data .value ? .products ? .nodes || []);
13
+
9
14
useHead ({
10
15
title: " Index" ,
11
16
titleTemplate: " %s - Nuxt 3 Woocommerce" ,
Original file line number Diff line number Diff line change 1
1
<template >
2
- <ProductsShowAll />
2
+ <ProductsShowAll :products = " products " />
3
3
</template >
4
4
5
5
<script setup>
6
+ import FETCH_ALL_PRODUCTS_QUERY from " @/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql" ;
7
+
8
+ const { data } = await useAsyncQuery (FETCH_ALL_PRODUCTS_QUERY );
9
+ const products = computed (() => data .value ? .products ? .nodes || []);
10
+
6
11
useHead ({
7
12
title: " Products" ,
8
13
titleTemplate: " %s - Nuxt 3 Woocommerce" ,
You can’t perform that action at this time.
0 commit comments