replaced hardcoded € with intl.numberformat and created config .state.priceOverallInEur
This commit is contained in:
58
client/dist/inject.js
vendored
58
client/dist/inject.js
vendored
File diff suppressed because one or more lines are too long
58
client/dist/seatmap.js
vendored
58
client/dist/seatmap.js
vendored
File diff suppressed because one or more lines are too long
@@ -48,14 +48,13 @@ export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj:
|
||||
Events.addRedirectCheckout(url);
|
||||
}
|
||||
|
||||
export function calcOverallPrice(): string | undefined {
|
||||
if (!config.state.selectedSeatsArr.length) {
|
||||
export function calcOverallPrice(): void{
|
||||
if (!config.state.selectedSeatsArr.length)
|
||||
config.state.priceOverall = "0";
|
||||
return "0";
|
||||
}
|
||||
|
||||
else
|
||||
config.state.priceOverall = sumSeatPrices();
|
||||
return config.state.priceOverall;
|
||||
|
||||
config.state.priceOverallEur = getPriceInEur(config.state.priceOverall);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +85,11 @@ export function generateCheckoutUrl(): string | undefined {
|
||||
return `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue.user_context}&pid=${inputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
||||
}
|
||||
|
||||
export function getPriceInEur(inPrice: string): string {
|
||||
const price: number = parseInt(inPrice);
|
||||
return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(price);
|
||||
}
|
||||
|
||||
function appendHTML(inCartID: string, inColor: string, inCategory: string | undefined, inSeatStr: string): void {
|
||||
jQuery("#cartItemHTML .fl-html").append(`
|
||||
<div class="cartItem" id="${inCartID}">
|
||||
@@ -110,12 +114,14 @@ function addDropdownBuyerTypeOptions(inBuyerTypes: I.TypeBuyerType, inSelector:
|
||||
function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void {
|
||||
const desc: string = Utils.encodeCP850DecodeUTF8( <string>inArr[2] );
|
||||
const id: string = <string>inArr[0];
|
||||
const price: string = <string>inArr[1];
|
||||
const price: string = getPriceInEur(<string>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}`;
|
||||
opt.innerHTML = `${desc} ${price}`;
|
||||
dropdownBuyerTypes.appendChild(opt);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,20 +7,18 @@ export function setBtnCartText(): void {
|
||||
|
||||
function createCartBtnText(): string {
|
||||
const numTickets: number = config.state.selectedSeatsArr.length;
|
||||
|
||||
if (config.state.priceOverall !== "")
|
||||
return numTickets === 1 ? `${numTickets} Ticket für €${config.state.priceOverall}` : `${numTickets} Tickets für €${config.state.priceOverall}`;
|
||||
else
|
||||
return "0 Tickets für €0.00";
|
||||
return numTickets === 1 ? `${numTickets} Ticket für ${config.state.priceOverallEur}` : `${numTickets} Tickets für ${config.state.priceOverallEur}`;
|
||||
}
|
||||
|
||||
function createModalCartBtnText(): string {
|
||||
const numTickets: number = config.state.selectedSeatsArr.length;
|
||||
|
||||
if (config.state.priceOverall !== "")
|
||||
return `Summe (${numTickets} Plätze) €${config.state.priceOverall}`;
|
||||
else
|
||||
return `Summe (0 Plätze) €0,00`;
|
||||
return `Summe (${numTickets} Plätze) ${config.state.priceOverallEur}`;
|
||||
|
||||
// if (config.state.priceOverall !== "")
|
||||
// return `Summe (${numTickets} Plätze) €${config.state.priceOverall}`;
|
||||
// else
|
||||
// return `Summe (0 Plätze) €0,00`;
|
||||
}
|
||||
|
||||
export function showHideBtnCartLoading(inSwitch: string): void {
|
||||
|
||||
@@ -28,6 +28,7 @@ export const config: I.Config = {
|
||||
},
|
||||
state: {
|
||||
priceOverall: "",
|
||||
priceOverallEur: "",
|
||||
cartChanged: false,
|
||||
selectedSeatsArr: [],
|
||||
selectedSeatsObj: {},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { config } from "./config";
|
||||
import * as I from "../types/types";
|
||||
import Utils from "./utils";
|
||||
import * as Cart from "./cart";
|
||||
|
||||
export function convertLegendToDropdown(inID: string): void {
|
||||
jQuery('ul.seatCharts-legendList').each(function () {
|
||||
@@ -69,8 +70,8 @@ function createLegendItems(pricescaleArr: I.SeatmapPricescale[], venuePricescale
|
||||
const id: string = arr.id[0];
|
||||
const seatsKey: string = String.fromCharCode(97 + index).toLocaleUpperCase();
|
||||
const desc: string | undefined = Utils.encodeCP850DecodeUTF8( venuePricescaleArr.find(obj => obj.id[0] === id)?.desc[0]! );
|
||||
const price: string = pricescaleArr[index].ref_price[0];
|
||||
const description: string = `${desc} €${price}`;
|
||||
const price: string = Cart.getPriceInEur(pricescaleArr[index].ref_price[0]);
|
||||
const description: string = `${desc} ${price}`;
|
||||
return [seatsKey, "available", description];
|
||||
});
|
||||
}
|
||||
1
client/src/types/types.d.ts
vendored
1
client/src/types/types.d.ts
vendored
@@ -12,6 +12,7 @@ export interface Trim {
|
||||
}
|
||||
|
||||
export interface State {
|
||||
priceOverallEur: string;
|
||||
priceOverall: string;
|
||||
cartChanged: boolean;
|
||||
selectedSeatsArr: string[][];
|
||||
|
||||
Reference in New Issue
Block a user