1
1
<template >
2
- <div v-if =" !fetching " class =" " >
2
+ <div v-if =" !loading " class =" " >
3
3
<section class =" px-10 mt-5 w-full mx-auto" >
4
4
<h1 class =" my-5 text-4xl font-semibold text-red-700" >
5
- {{ data .category.name }}
5
+ {{ result .category.name }}
6
6
</h1 >
7
7
<div class =" grid grid-cols-4 gap-6" >
8
8
<div
9
- v-for =" (card, index) in data .category.products.data"
9
+ v-for =" (card, index) in result .category.products.data"
10
10
:key =" `product-card-${index}`"
11
11
class ="
12
12
shadow
81
81
<Pagination
82
82
@previous =" previousButtonOnClick"
83
83
@next =" nextButtonOnClick"
84
- :total =" data .category.products.total"
85
- :per-page =" data .category.products.per_page"
86
- :current-page =" data .category.products.current_page"
87
- :from =" data .category.products.from"
88
- :to =" data .category.products.to"
89
- :last-page =" data .category.products.last_page"
90
- :has-more-pages =" data .category.products.has_more_pages"
84
+ :total =" result .category.products.total"
85
+ :per-page =" result .category.products.per_page"
86
+ :current-page =" result .category.products.current_page"
87
+ :from =" result .category.products.from"
88
+ :to =" result .category.products.to"
89
+ :last-page =" result .category.products.last_page"
90
+ :has-more-pages =" result .category.products.has_more_pages"
91
91
/>
92
92
</div >
93
93
</section >
@@ -109,10 +109,7 @@ import { useQuery } from "@vue/apollo-composable"
109
109
const slug = ref (router .currentRoute .value .params .slug )
110
110
const page = ref (1 )
111
111
112
- const {loading, result } = useQuery ({
113
- query: GetCategoryQuery ,
114
- variables: { slug: slug , page: page },
115
- })
112
+ const {loading, result } = useQuery (GetCategoryQuery , { slug: slug , page: page })
116
113
117
114
// watch(router.currentRoute, (newValue) => {
118
115
// slug.value = newValue.params.slug
@@ -122,16 +119,18 @@ import { useQuery } from "@vue/apollo-composable"
122
119
// requestPolicy: "network-only",
123
120
// })
124
121
// })
125
- // const nextButtonOnClick = () => {
126
- // page.value += 1
127
- // console.log('page ' + page.value)
128
- // result.executeQuery({
129
- // variables: { slug: slug, page: page },
130
- // requestPolicy: "network-only",
131
- // })
132
- // }
133
- // const previousButtonOnClick = () => {
134
-
122
+ const nextButtonOnClick = () => {
123
+ console .log (' next' )
124
+ // page.value += 1
125
+ // console.log('page ' + page.value)
126
+ // result.executeQuery({
127
+ // variables: { slug: slug, page: page },
128
+ // requestPolicy: "network-only",
129
+ // })
130
+ }
131
+ const previousButtonOnClick = () => {
132
+
133
+ console .log (' prev' )
135
134
// page.value -= 1
136
135
// if (page.value < 0) {
137
136
// page.value = 0
@@ -141,6 +140,6 @@ import { useQuery } from "@vue/apollo-composable"
141
140
// variables: { slug: slug, page: page },
142
141
// requestPolicy: "network-only",
143
142
// })
144
- // }
143
+ }
145
144
146
145
</script >
0 commit comments