File tree Expand file tree Collapse file tree 3 files changed +24
-46
lines changed Expand file tree Collapse file tree 3 files changed +24
-46
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5555
5656<script setup>
5757import FETCH_ALL_PRODUCTS_QUERY from " @/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql" ;
58+ import GET_PRODUCTS_FROM_CATEGORY_QUERY from " @/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql" ;
59+
5860import { filteredVariantPrice } from " @/utils/functions" ;
5961
62+ const props = defineProps ({
63+ categoryId: { type: String , required: false },
64+ categorySlug: { type: String , required: false },
65+ });
66+
6067const config = useRuntimeConfig ();
6168
6269const productImage = (product ) =>
6370 product .image ? product .image .sourceUrl : config .placeholderImage ;
6471
65- const variables = { limit: 99 };
66- const { data } = await useAsyncQuery (FETCH_ALL_PRODUCTS_QUERY , variables);
72+ const productVariables = { limit: 99 };
73+ const { data } = await useAsyncQuery (
74+ FETCH_ALL_PRODUCTS_QUERY ,
75+ productVariables
76+ );
77+
78+ if (props .id ) {
79+ const categoryVariables = { id: props .categoryId , slug: props .categorySlug };
80+ const { data } = await useAsyncQuery (
81+ GET_PRODUCTS_FROM_CATEGORY_QUERY ,
82+ categoryVariables
83+ );
84+ }
6785 </script >
6886
6987<style scoped>
Original file line number Diff line number Diff line change 11<template >
2- <div v-if =" data?.productCategory" >
3- <CategoryShowProducts :products =" data.productCategory" />
4- </div >
5- <div v-else >
6- <SpinnerLoading />
7- </div >
2+ <ProductsShowAll
3+ :category-id =" route.query.id"
4+ :category-slug =" route.params.product"
5+ />
86</template >
97
108<script setup>
11- import GET_PRODUCTS_FROM_CATEGORY_QUERY from " @/apollo/queries/GET_PRODUCTS_FROM_CATEGORY_QUERY.gql" ;
12-
139const route = useRoute ();
1410
15- const variables = { id: route .query .id , slug: route .params .category };
16- const { data } = await useAsyncQuery (
17- GET_PRODUCTS_FROM_CATEGORY_QUERY ,
18- variables
19- );
20-
2111useHead ({
2212 title: route .params .category ,
2313 titleTemplate: " %s - Nuxt 3 Woocommerce" ,
You can’t perform that action at this time.
0 commit comments