Merge pull request 'staging' (#16) from staging into master

Reviewed-on: http://localhost:3000/zino/seatmapv2/pulls/16
This commit is contained in:
zino
2021-07-28 16:45:21 +02:00
3 changed files with 10 additions and 16 deletions

View File

@@ -17,12 +17,10 @@ export function addItem(inSeatObj: I.JSCSelectedSeat): void {
const cartID: string = `cartItem-${inSeatObj.id}`; const cartID: string = `cartItem-${inSeatObj.id}`;
const dropdownBuyerTypesSelector: string = `#${cartID} .dropdownBuyerTypes`; const dropdownBuyerTypesSelector: string = `#${cartID} .dropdownBuyerTypes`;
console.log(category);
console.log(seatStr);
appendHTML(cartID, color, category, seatStr); appendHTML(cartID, color, category, seatStr);
addDropdownBuyerTypeOptions(buyerTypes, dropdownBuyerTypesSelector); addDropdownBuyerTypeOptions(buyerTypes, dropdownBuyerTypesSelector);
Events.addCartDropdownBuyerTypes(dropdownBuyerTypesSelector, inSeatObj); Events.addCartDropdownBuyerTypes(dropdownBuyerTypesSelector, inSeatObj);
//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 { export function removeCartItems(): void {
@@ -32,9 +30,7 @@ export function removeCartItems(): void {
} }
export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj: I.JSCSelectedSeat): void { export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj: I.JSCSelectedSeat): void {
const index: number = config.state.selectedSeatsArr.findIndex(arr => const index: number = config.state.selectedSeatsArr.findIndex(arr => arr[0] === inSeatObj.id);
arr[0] === inSeatObj.id);
config.state.selectedSeatsArr[index][1] = inSelect.value; config.state.selectedSeatsArr[index][1] = inSelect.value;
const buyerTypeCode = XMLHelper.getBuyerTypeCodeByBuyerTypeID(inSelect.value); const buyerTypeCode = XMLHelper.getBuyerTypeCodeByBuyerTypeID(inSelect.value);
@@ -43,7 +39,6 @@ export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj:
calcOverallPrice(); calcOverallPrice();
CartButtons.setBtnCartText(); CartButtons.setBtnCartText();
const url = generateCheckoutUrl(); const url = generateCheckoutUrl();
Events.addRedirectCheckout(url); Events.addRedirectCheckout(url);
} }
@@ -113,8 +108,6 @@ function addDropdownBuyerTypeOptions(inBuyerTypes: I.TypeBuyerType, inSelector:
if (!inBuyerTypes) if (!inBuyerTypes)
return; return;
console.log(inBuyerTypes);
inBuyerTypes.sort((a, b) => { inBuyerTypes.sort((a, b) => {
return <any>b[1] - <any>a[1]; return <any>b[1] - <any>a[1];
}).forEach(arr => { }).forEach(arr => {
@@ -129,8 +122,6 @@ function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void {
const price: string = getPriceInEur(<string>inArr[1]); const price: string = getPriceInEur(<string>inArr[1]);
const dropdownBuyerTypes: HTMLElement = jQuery(inSelector).get(0); const dropdownBuyerTypes: HTMLElement = jQuery(inSelector).get(0);
console.log(price);
let opt: HTMLOptionElement = document.createElement('option'); let opt: HTMLOptionElement = document.createElement('option');
opt.value = id; opt.value = id;
opt.innerHTML = `${desc} ${price}`; opt.innerHTML = `${desc} ${price}`;
@@ -152,7 +143,6 @@ function getSeatPrice(arr: string[]) {
if (pricescaleObj) { if (pricescaleObj) {
const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj); const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj);
if (seatPrice) if (seatPrice)
return seatPrice; return seatPrice;
} }

View File

@@ -9,9 +9,13 @@ export function addSeatToState(inSelectedSeat: I.JSCSelectedSeat): void {
const pricescaleObj: I.Pricescale5 | undefined = XMLHelper.getVenuePriceStructurePropertyByPricescaleID(pricescaleID); const pricescaleObj: I.Pricescale5 | undefined = XMLHelper.getVenuePriceStructurePropertyByPricescaleID(pricescaleID);
if (pricescaleObj) { if (pricescaleObj) {
const firstBuyerTypeID: string = pricescaleObj.buyer_type[0].id[0]; //const firstBuyerTypeID: string = pricescaleObj.buyer_type[0].id[0]; // needs to be highest amount
const buyerTypeCode: string | undefined = XMLHelper.getBuyerTypeCodeByBuyerTypeID(firstBuyerTypeID); const mostExpensiveBuyerTypeID: string = pricescaleObj.buyer_type.reduce((prev, current) => {
const selectedSeatsArrItem: (string | undefined)[] = [inSelectedSeat.id, firstBuyerTypeID, buyerTypeCode]; 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); addSeatsItemToState(selectedSeatsArrItem);
} }
else else