Skip to content

Commit 5d6218f

Browse files
committed
Refactor Index
1 parent a5ede4c commit 5d6218f

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

components/Products/ProductsShowAll.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<div v-if="products">
2+
<div v-if="data?.products?.nodes">
33
<section>
44
<div id="product-container" class="flex flex-wrap items-center">
5-
<template v-for="product in products">
5+
<template v-for="product in data.products.nodes">
66
<div
77
v-if="product.slug !== undefined"
88
:key="product.id"
@@ -54,14 +54,14 @@
5454
</template>
5555

5656
<script setup>
57+
import FETCH_ALL_PRODUCTS_QUERY from "@/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql";
5758
import { filteredVariantPrice } from "@/utils/functions";
5859
59-
defineProps({
60-
products: { type: Array, required: true },
61-
});
62-
6360
const productImage = (product) =>
6461
product.image ? product.image.sourceUrl : process.env.placeholderSmallImage;
62+
63+
const variables = { limit: 99 };
64+
const { data } = await useAsyncQuery(FETCH_ALL_PRODUCTS_QUERY, variables);
6565
</script>
6666

6767
<style scoped>

pages/index.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<template>
22
<div>
33
<IndexHero />
4-
<div v-if="data.products">
5-
<ProductsShowAll :products="data.products.nodes" />
6-
</div>
4+
<ProductsShowAll />
75
</div>
86
</template>
9-
10-
<script setup>
11-
import FETCH_ALL_PRODUCTS_QUERY from "@/apollo/queries/FETCH_ALL_PRODUCTS_QUERY.gql";
12-
13-
const variables = { limit: 5 };
14-
const { data } = await useAsyncQuery(FETCH_ALL_PRODUCTS_QUERY, variables);
15-
</script>

0 commit comments

Comments
 (0)