From 269b982575cc5e29a7ee243abfd90898f0304ad6 Mon Sep 17 00:00:00 2001 From: zino Date: Wed, 28 Jul 2021 15:16:12 +0200 Subject: [PATCH 1/3] fixed not refreshing checkouturl on highest buyer type sort --- client/src/modules/cart.ts | 11 ++--------- client/src/modules/events.ts | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/client/src/modules/cart.ts b/client/src/modules/cart.ts index d5eb346..74c60f4 100644 --- a/client/src/modules/cart.ts +++ b/client/src/modules/cart.ts @@ -17,12 +17,10 @@ export function addItem(inSeatObj: I.JSCSelectedSeat): void { const cartID: string = `cartItem-${inSeatObj.id}`; const dropdownBuyerTypesSelector: string = `#${cartID} .dropdownBuyerTypes`; - console.log(category); - console.log(seatStr); - appendHTML(cartID, color, category, seatStr); addDropdownBuyerTypeOptions(buyerTypes, dropdownBuyerTypesSelector); Events.addCartDropdownBuyerTypes(dropdownBuyerTypesSelector, inSeatObj); + jQuery(".dropdownBuyerTypes").trigger("change"); // refresh cart because of highest buyer type sort } export function removeCartItems(): void { @@ -32,9 +30,7 @@ export function removeCartItems(): void { } export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj: I.JSCSelectedSeat): void { - const index: number = config.state.selectedSeatsArr.findIndex(arr => - arr[0] === inSeatObj.id); - + const index: number = config.state.selectedSeatsArr.findIndex(arr => arr[0] === inSeatObj.id); config.state.selectedSeatsArr[index][1] = inSelect.value; const buyerTypeCode = XMLHelper.getBuyerTypeCodeByBuyerTypeID(inSelect.value); @@ -43,7 +39,6 @@ export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj: calcOverallPrice(); CartButtons.setBtnCartText(); - const url = generateCheckoutUrl(); Events.addRedirectCheckout(url); } @@ -113,8 +108,6 @@ function addDropdownBuyerTypeOptions(inBuyerTypes: I.TypeBuyerType, inSelector: if (!inBuyerTypes) return; - console.log(inBuyerTypes); - inBuyerTypes.sort((a, b) => { return b[1] - a[1]; }).forEach(arr => { diff --git a/client/src/modules/events.ts b/client/src/modules/events.ts index e909fca..c8cf591 100644 --- a/client/src/modules/events.ts +++ b/client/src/modules/events.ts @@ -44,7 +44,7 @@ export function addModalCart(): void { export function addRedirectCheckout(inUrl: string | undefined): void { if (!inUrl) return; - + const btnCheckout = jQuery("#modalCart-overlay #checkout .fl-button").get(0); if (btnCheckout) { btnCheckout.addEventListener("click", () => { From 5d0c971d83504f2101efeb5b2590c2bd66481b8e Mon Sep 17 00:00:00 2001 From: zino Date: Wed, 28 Jul 2021 15:25:33 +0200 Subject: [PATCH 2/3] remove console.log --- client/src/modules/cart.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/modules/cart.ts b/client/src/modules/cart.ts index 74c60f4..c894a99 100644 --- a/client/src/modules/cart.ts +++ b/client/src/modules/cart.ts @@ -122,8 +122,6 @@ function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void { const price: string = getPriceInEur(inArr[1]); const dropdownBuyerTypes: HTMLElement = jQuery(inSelector).get(0); - console.log(price); - let opt: HTMLOptionElement = document.createElement('option'); opt.value = id; opt.innerHTML = `${desc} ${price}`; From 6325183558ed90635583d4ba4cecd99d67c9744b Mon Sep 17 00:00:00 2001 From: zino Date: Wed, 28 Jul 2021 16:05:15 +0200 Subject: [PATCH 3/3] fixed highest price by adding most expensive buyertypeid to state on seat select --- client/src/modules/cart.ts | 3 +-- client/src/modules/state.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/src/modules/cart.ts b/client/src/modules/cart.ts index c894a99..1491e24 100644 --- a/client/src/modules/cart.ts +++ b/client/src/modules/cart.ts @@ -20,7 +20,7 @@ export function addItem(inSeatObj: I.JSCSelectedSeat): void { appendHTML(cartID, color, category, seatStr); addDropdownBuyerTypeOptions(buyerTypes, dropdownBuyerTypesSelector); Events.addCartDropdownBuyerTypes(dropdownBuyerTypesSelector, inSeatObj); - jQuery(".dropdownBuyerTypes").trigger("change"); // refresh cart because of highest buyer type sort + //jQuery(".dropdownBuyerTypes").trigger("change"); // refresh cart because of highest buyer type sort => we dont need this because we add mostExpensiveBuyerTypeID now } export function removeCartItems(): void { @@ -143,7 +143,6 @@ function getSeatPrice(arr: string[]) { if (pricescaleObj) { const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj); - if (seatPrice) return seatPrice; } diff --git a/client/src/modules/state.ts b/client/src/modules/state.ts index cf45bca..ef9ceaf 100644 --- a/client/src/modules/state.ts +++ b/client/src/modules/state.ts @@ -9,9 +9,13 @@ export function addSeatToState(inSelectedSeat: I.JSCSelectedSeat): void { const pricescaleObj: I.Pricescale5 | undefined = XMLHelper.getVenuePriceStructurePropertyByPricescaleID(pricescaleID); if (pricescaleObj) { - const firstBuyerTypeID: string = pricescaleObj.buyer_type[0].id[0]; - const buyerTypeCode: string | undefined = XMLHelper.getBuyerTypeCodeByBuyerTypeID(firstBuyerTypeID); - const selectedSeatsArrItem: (string | undefined)[] = [inSelectedSeat.id, firstBuyerTypeID, buyerTypeCode]; + //const firstBuyerTypeID: string = pricescaleObj.buyer_type[0].id[0]; // needs to be highest amount + const mostExpensiveBuyerTypeID: string = pricescaleObj.buyer_type.reduce((prev, current) => { + return (prev.price[0] > current.price[0]) ? prev : current + }).id[0] + + const buyerTypeCode: string | undefined = XMLHelper.getBuyerTypeCodeByBuyerTypeID(mostExpensiveBuyerTypeID); + const selectedSeatsArrItem: (string | undefined)[] = [inSelectedSeat.id, mostExpensiveBuyerTypeID, buyerTypeCode]; addSeatsItemToState(selectedSeatsArrItem); } else