import { config } from "./config";

export function setBtnCartText(): void {
    jQuery("#modalCart .uabb-button-text")[0].innerText = createCartBtnText();
    jQuery("#modalCartSum .uabb-heading-text")[0].textContent = createModalCartBtnText();
}

function createCartBtnText(): string {
    const numTickets: number = config.state.selectedSeatsArr.length;
    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;

    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 {
    if (inSwitch === "show") {
        jQuery("#modalCart .uabb-button").css("pointer-events", "none");
        jQuery("#modalCart i").hide();
        jQuery("#modalCart .uabb-button-text").addClass("dot-pulse");
    }
    else if (inSwitch === "hide") {
        jQuery("#modalCart i").show();
        jQuery("#modalCart .uabb-button-text").removeClass("dot-pulse");
        jQuery("#modalCart .uabb-button").css("pointer-events", "all");
    }
}