From 3c797b2d4fccc74a817ca6873bf3de0a1804c8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Meyer?= Date: Wed, 12 Jul 2023 14:17:40 +0200 Subject: [PATCH] feat(poc): use const instead of let --- lib/shopware/index.ts | 2 +- lib/shopware/transform.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/shopware/index.ts b/lib/shopware/index.ts index b46bdc920..c9bee2058 100644 --- a/lib/shopware/index.ts +++ b/lib/shopware/index.ts @@ -204,7 +204,7 @@ export async function getProduct(handle: string | []): Promise { - let products: ExtendedProductListingResult = {}; + const products: ExtendedProductListingResult = {}; const res = await requestCrossSell(productId, getDefaultCrossSellingCriteria()); // @ToDo: Make this more dynamic to merge multiple Cross-Sellings, at the moment we only get the first one diff --git a/lib/shopware/transform.ts b/lib/shopware/transform.ts index e67906678..8b0c23d83 100644 --- a/lib/shopware/transform.ts +++ b/lib/shopware/transform.ts @@ -17,7 +17,7 @@ import { import { ListItem } from 'components/layout/search/filter'; export function transformMenu(res: ExtendedCategory[], type: string) { - let menu: Menu[] = []; + const menu: Menu[] = []; res.map((item) => menu.push(transformMenuItem(item, type))); @@ -105,7 +105,7 @@ export function transformCollection( } export function transformStaticCollection(resCategory: CategoryListingResultSW): Collection[] { - let collection: Collection[] = []; + const collection: Collection[] = []; if (resCategory.elements && resCategory.elements.length > 0) { resCategory.elements.map((item) => @@ -129,7 +129,7 @@ export function transformStaticCollection(resCategory: CategoryListingResultSW): } export function transformStaticCollectionToList(collection: Collection[]): ListItem[] { - let listItem: ListItem[] = []; + const listItem: ListItem[] = []; if (collection && collection.length > 0) { collection.map((item) => @@ -144,7 +144,7 @@ export function transformStaticCollectionToList(collection: Collection[]): ListI } export function transformProducts(res: ExtendedProductListingResult): Product[] { - let products: Product[] = []; + const products: Product[] = []; if (res.elements && res.elements.length > 0) { res.elements.map((item) => products.push(transformProduct(item))); @@ -210,9 +210,9 @@ export function transformProduct(item: ExtendedProduct): Product { function transformOptions(parent: ExtendedProduct): ProductOption[] { // we only transform options for parents with children, ignore child products with options - let productOptions: ProductOption[] = []; + const productOptions: ProductOption[] = []; if (parent.children && parent.parentId === null && parent.children.length > 0) { - let group: { [key: string]: string[] } = {}; + const group: { [key: string]: string[] } = {}; parent.children.map((child) => { child.options?.map((option) => { if (option && option.group) { @@ -238,11 +238,11 @@ function transformOptions(parent: ExtendedProduct): ProductOption[] { } function transformVariants(parent: ExtendedProduct): ProductVariant[] { - let productVariants: ProductVariant[] = []; + const productVariants: ProductVariant[] = []; if (parent.children && parent.parentId === null && parent.children.length > 0) { parent.children.map((child) => { if (child.id) { - let selectedOptions: { name: string; value: string }[] = []; + const selectedOptions: { name: string; value: string }[] = []; child.options?.map((option) => { if (option.group) { selectedOptions.push({