feat(poc): use const instead of let

This commit is contained in:
Björn Meyer 2023-07-12 14:17:40 +02:00
parent a1b435487f
commit 3c797b2d4f
2 changed files with 9 additions and 9 deletions

View File

@ -204,7 +204,7 @@ export async function getProduct(handle: string | []): Promise<Product | undefin
} }
export async function getProductRecommendations(productId: string): Promise<Product[]> { export async function getProductRecommendations(productId: string): Promise<Product[]> {
let products: ExtendedProductListingResult = {}; const products: ExtendedProductListingResult = {};
const res = await requestCrossSell(productId, getDefaultCrossSellingCriteria()); 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 // @ToDo: Make this more dynamic to merge multiple Cross-Sellings, at the moment we only get the first one

View File

@ -17,7 +17,7 @@ import {
import { ListItem } from 'components/layout/search/filter'; import { ListItem } from 'components/layout/search/filter';
export function transformMenu(res: ExtendedCategory[], type: string) { export function transformMenu(res: ExtendedCategory[], type: string) {
let menu: Menu[] = []; const menu: Menu[] = [];
res.map((item) => menu.push(transformMenuItem(item, type))); res.map((item) => menu.push(transformMenuItem(item, type)));
@ -105,7 +105,7 @@ export function transformCollection(
} }
export function transformStaticCollection(resCategory: CategoryListingResultSW): Collection[] { export function transformStaticCollection(resCategory: CategoryListingResultSW): Collection[] {
let collection: Collection[] = []; const collection: Collection[] = [];
if (resCategory.elements && resCategory.elements.length > 0) { if (resCategory.elements && resCategory.elements.length > 0) {
resCategory.elements.map((item) => resCategory.elements.map((item) =>
@ -129,7 +129,7 @@ export function transformStaticCollection(resCategory: CategoryListingResultSW):
} }
export function transformStaticCollectionToList(collection: Collection[]): ListItem[] { export function transformStaticCollectionToList(collection: Collection[]): ListItem[] {
let listItem: ListItem[] = []; const listItem: ListItem[] = [];
if (collection && collection.length > 0) { if (collection && collection.length > 0) {
collection.map((item) => collection.map((item) =>
@ -144,7 +144,7 @@ export function transformStaticCollectionToList(collection: Collection[]): ListI
} }
export function transformProducts(res: ExtendedProductListingResult): Product[] { export function transformProducts(res: ExtendedProductListingResult): Product[] {
let products: Product[] = []; const products: Product[] = [];
if (res.elements && res.elements.length > 0) { if (res.elements && res.elements.length > 0) {
res.elements.map((item) => products.push(transformProduct(item))); res.elements.map((item) => products.push(transformProduct(item)));
@ -210,9 +210,9 @@ export function transformProduct(item: ExtendedProduct): Product {
function transformOptions(parent: ExtendedProduct): ProductOption[] { function transformOptions(parent: ExtendedProduct): ProductOption[] {
// we only transform options for parents with children, ignore child products with options // 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) { if (parent.children && parent.parentId === null && parent.children.length > 0) {
let group: { [key: string]: string[] } = {}; const group: { [key: string]: string[] } = {};
parent.children.map((child) => { parent.children.map((child) => {
child.options?.map((option) => { child.options?.map((option) => {
if (option && option.group) { if (option && option.group) {
@ -238,11 +238,11 @@ function transformOptions(parent: ExtendedProduct): ProductOption[] {
} }
function transformVariants(parent: ExtendedProduct): ProductVariant[] { function transformVariants(parent: ExtendedProduct): ProductVariant[] {
let productVariants: ProductVariant[] = []; const productVariants: ProductVariant[] = [];
if (parent.children && parent.parentId === null && parent.children.length > 0) { if (parent.children && parent.parentId === null && parent.children.length > 0) {
parent.children.map((child) => { parent.children.map((child) => {
if (child.id) { if (child.id) {
let selectedOptions: { name: string; value: string }[] = []; const selectedOptions: { name: string; value: string }[] = [];
child.options?.map((option) => { child.options?.map((option) => {
if (option.group) { if (option.group) {
selectedOptions.push({ selectedOptions.push({