Skip to content

Commit e48e651

Browse files
committed
Refactor categories
1 parent fcdc7a8 commit e48e651

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

components/Category/CategoryShowAll.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
2-
<div v-if="categories">
2+
<div v-if="data.productCategories">
33
<section class="mx-auto bg-white">
44
<div
55
class="grid gap-2 px-2 pt-2 pb-2 lg:px-0 xl:px-0 md:px-0 lg:grid-cols-4 sm:grid-cols-2 md:grid-cols-3 xs:grid-cols-3"
66
>
7-
<template v-for="nodes in categories">
7+
<template v-for="nodes in data.productCategories">
88
<template v-for="category in nodes">
99
<div v-if="category.slug !== undefined" :key="category.id">
1010
<NuxtLink
@@ -33,10 +33,8 @@
3333
</template>
3434

3535
<script setup>
36-
defineProps({
37-
categories: {
38-
type: [Object],
39-
required: true,
40-
},
41-
});
36+
import FETCH_ALL_CATEGORIES_QUERY from "@/apollo/queries/FETCH_ALL_CATEGORIES_QUERY.gql";
37+
38+
const variables = { limit: 99 };
39+
const { data } = await useAsyncQuery(FETCH_ALL_CATEGORIES_QUERY, variables);
4240
</script>

pages/categories.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
<template>
2-
<div v-if="data.productCategories">
3-
<CategoryShowAll :categories="data.productCategories" />
4-
</div>
5-
<div v-else>
6-
<SpinnerLoading />
7-
</div>
2+
<CategoryShowAll />
83
</template>
94

105
<script setup>
11-
import FETCH_ALL_CATEGORIES_QUERY from "@/apollo/queries/FETCH_ALL_CATEGORIES_QUERY.gql";
12-
13-
const variables = { limit: 5 };
14-
const { data } = await useAsyncQuery(FETCH_ALL_CATEGORIES_QUERY, variables);
15-
166
useHead({
177
title: "Categories",
188
titleTemplate: "%s - Nuxt 3 Woocommerce",

0 commit comments

Comments
 (0)