before state inputswithvalue
This commit is contained in:
@@ -2,7 +2,10 @@ import axios, { AxiosResponse } from 'axios';
|
||||
var xml2jsParser = require('xml2js').parseString;
|
||||
import * as I from "../types/types";
|
||||
import Utils from './utils';
|
||||
//import { state } from "../seatmap";
|
||||
import * as UI from "./ui";
|
||||
import { config } from "./config";
|
||||
import * as Communication from "./communication";
|
||||
|
||||
|
||||
export function getXMLPromise(url: string): Promise<unknown> {
|
||||
return axios.get(url)
|
||||
@@ -60,3 +63,116 @@ export function getEventInfo(inVenueXML: I.VenueXML): I.EventInfo {
|
||||
return eventInfo;
|
||||
}
|
||||
|
||||
export function isValidSeatSelection(inInputsWithValue: I.InputsWithValue) {
|
||||
console.log("checking seat selection");
|
||||
console.log(inInputsWithValue);
|
||||
jQuery("#modalCart-overlay").hide();
|
||||
|
||||
if (!config.state.selectedSeatsArr.length)
|
||||
return;
|
||||
|
||||
UI.showHideBtnCartLoading("show");
|
||||
|
||||
jQuery("#modalCart i").hide();
|
||||
jQuery("#modalCart .uabb-button-text").addClass("dot-pulse");
|
||||
|
||||
const url = generateCheckoutUrl(inInputsWithValue);
|
||||
|
||||
// const selectedSeatIndexes: string = generateSelectedSeatIndexes();
|
||||
// const url: string = `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue.user_context}&pid=${inputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
||||
|
||||
const message: I.Message = {
|
||||
message: {
|
||||
url: url,
|
||||
},
|
||||
from: "child",
|
||||
event: "child_needCheckoutResponse",
|
||||
date: Date.now()
|
||||
};
|
||||
Communication.sendMessage(message, "parent");
|
||||
}
|
||||
|
||||
export function generateCheckoutUrl(inInputsWithValue: I.InputsWithValue): string | undefined {
|
||||
console.log(inInputsWithValue);
|
||||
if (!config.state.selectedSeatsArr.length)
|
||||
return;
|
||||
else {
|
||||
const selectedSeatIndexes: string = generateSelectedSeatIndexes();
|
||||
return `${inInputsWithValue["ticketPurchaseUrl"]}?user_context=${inInputsWithValue.user_context}&pid=${inInputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
||||
}
|
||||
}
|
||||
|
||||
function generateSelectedSeatIndexes(): string {
|
||||
return (config.state.selectedSeatsArr.map(function (arr) {
|
||||
return arr.join(",");
|
||||
})).join("|");
|
||||
}
|
||||
|
||||
export function getSectionDescBySectionID(inVenueXML: I.VenueXML, sectionID: string): string | undefined {
|
||||
const sectionArr = inVenueXML.master_config[0].section_config[0].section;
|
||||
|
||||
const sectionDesc = sectionArr.find(arr => {
|
||||
return sectionID === arr.id[0];
|
||||
})?.desc[0];
|
||||
|
||||
return sectionDesc;
|
||||
}
|
||||
|
||||
export function processSMAP(inInputsWithValue: I.InputsWithValue) {
|
||||
if (!inInputsWithValue.smap)
|
||||
return;
|
||||
|
||||
const smapArr = inInputsWithValue.smap.split("").map(Number);
|
||||
|
||||
if (!smapArr[0])
|
||||
jQuery("#eventInfoCapacity").hide();
|
||||
}
|
||||
|
||||
export function getVenuePricescalePropertyByPricescaleID(property: I.Pricescale2Properties, pricescaleID: string, inVenueXML: I.VenueXML) {
|
||||
const venuePricescaleArr: I.Pricescale2[] = inVenueXML.venue[0].pricescales[0].pricescale;
|
||||
|
||||
return venuePricescaleArr.find(obj => {
|
||||
if (obj.id[0] === pricescaleID)
|
||||
return obj;
|
||||
|
||||
return undefined;
|
||||
})?.[property][0];
|
||||
}
|
||||
|
||||
export function getBuyerTypeCodeByBuyerTypeID(inVenueXML: I.VenueXML, inBuyerTypeID: string): string | undefined {
|
||||
const venueBuyerTypeArr = inVenueXML.venue[0].buyer_types[0].buyer_type;
|
||||
return venueBuyerTypeArr.find(arr => {
|
||||
return inBuyerTypeID === arr.id[0];
|
||||
})?.code[0];
|
||||
}
|
||||
|
||||
export function getPriceByBuyertypeID(inBuyertypeID: string, inPricescaleObj: I.Pricescale5) {
|
||||
const price = inPricescaleObj?.buyer_type.find(arr => {
|
||||
return arr.id[0] === inBuyertypeID;
|
||||
})?.price[0];
|
||||
|
||||
if (price)
|
||||
return parseFloat(price);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getVenuePriceStructurePropertyByPricescaleID(inVenueXML: I.VenueXML, inID: string): I.Pricescale5 | undefined {
|
||||
const venuePricescaleArr: I.Pricescale5[] = inVenueXML.price_structure[0].pricescale;
|
||||
return venuePricescaleArr.find(obj => {
|
||||
return obj.id[0] === inID;
|
||||
});
|
||||
}
|
||||
|
||||
export function generatePricescaleCSS(inVenueXML: I.VenueXML): string {
|
||||
const venuePricescalesArr: I.Pricescale2[] = inVenueXML.venue[0].pricescales[0].pricescale;
|
||||
let cssArr: string[] = [];
|
||||
|
||||
venuePricescalesArr.forEach(element => {
|
||||
const ID: string = element.id[0];
|
||||
let color: string = `#${element.color[0]} !important`; // Update: Colors are always defined: fallback colors exist in system so every XML provides them
|
||||
cssArr.push(`._${ID} { background-color: ${color}; }`);
|
||||
});
|
||||
|
||||
return (cssArr.join("\r\n"));
|
||||
}
|
||||
Reference in New Issue
Block a user