Skip to content

Commit 30cfb06

Browse files
refactor: remove category getters call from app header
- apply suggestions from code review Co-authored-by: Artur Tagisow <[email protected]>
1 parent e1e54ed commit 30cfb06

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

packages/theme/components/AppHeader.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,13 @@ export default defineComponent({
183183
useFetch(async () => {
184184
await categoriesListLoad({ pageSize: 20 });
185185
186-
function prepareMenuData() {
187-
return categoryList.value?.[0]?.children
188-
.map((category) => ({
189-
includeInMenu: category.include_in_menu,
190-
label: category.name,
191-
slug: `/${category.url_path}${category.url_suffix}`,
192-
}))
193-
.filter((category) => category.includeInMenu) ?? [];
194-
}
195-
196-
categoryTree.value = prepareMenuData();
186+
categoryTree.value = categoryList.value?.[0]?.children
187+
.filter((category) => category.include_in_menu)
188+
.map((category) => ({
189+
includeInMenu: category.include_in_menu,
190+
label: category.name,
191+
slug: `/${category.url_path}${category.url_suffix}`,
192+
})) ?? [];
197193
});
198194
199195
onMounted(() => {

packages/theme/helpers/product/productData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const productData = (products) => {
88
id,
99
product: computed(() => {
1010
if (!products) return {};
11-
return Array.isArray(products.value?.items) && products.value?.items[0] ? products.value?.items[0] : [];
11+
return products.value?.items?.[0] ?? [];
1212
}),
1313
};
1414
};

packages/theme/pages/Home.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ import {
106106
} from '@nuxtjs/composition-api';
107107
import LazyHydrate from 'vue-lazy-hydration';
108108
import { useCache, CacheTagPrefix } from '@vue-storefront/cache';
109-
import { productGetters } from '~/getters';
110109
import { useProduct } from '~/composables';
111110
import MobileStoreBanner from '~/components/MobileStoreBanner.vue';
112111
import InstagramFeed from '~/components/InstagramFeed.vue';
@@ -241,7 +240,7 @@ export default defineComponent({
241240
]);
242241
243242
onMounted(async () => {
244-
const productsData = await getProductList({
243+
newProducts.value = await getProductList({
245244
pageSize: 10,
246245
currentPage: 1,
247246
sort: {
@@ -250,8 +249,6 @@ export default defineComponent({
250249
});
251250
252251
addTags([{ prefix: CacheTagPrefix.View, value: 'home' }]);
253-
254-
newProducts.value = productsData?.items;
255252
});
256253
257254
// @ts-ignore
@@ -260,7 +257,6 @@ export default defineComponent({
260257
heroes,
261258
newProducts,
262259
newProductsLoading,
263-
productGetters,
264260
};
265261
},
266262
});

0 commit comments

Comments
 (0)