export const convertPaymetricCardType = (cardType: string) => {
    switch (cardType.toLowerCase()) {
        case "vi":
            return "Visa";
        case "mc":
            return "MasterCard";
        case "ax":
            return "American Express";
        case "dc":
            return "Diner's";
        case "di":
            return "Discover";
        case "jc":
            return "JCB";
        case "sw":
            return "Maestro";
        default:
            return "unknown";
    }
};

export const convertTokenExCardType = (cardType: string) => {
    if (cardType.indexOf("american") > -1) {
        return "AMERICAN EXPRESS";
    }

    return cardType.toUpperCase();
};

export const convertSpreedlyCardType = (cardType: string) => {
    const cardTypes: Record<string, string> = {
        alelo: "Alelo",
        alia: "Alia",
        american_express: "American Express",
        anda: "Anda",
        cabal: "Cabal",
        carnet: "Carnet",
        confiable: "Confiable",
        creditel: "Creditel",
        dankort: "Dankort",
        diners_club: "Diners Club",
        discover: "Discover",
        edenred: "Edenred",
        elo: "Elo",
        jcb: "JCB",
        mada: "Mada",
        maestro: "Maestro",
        maestro_no_luhn: "Maestro",
        master: "Mastercard",
        naranja: "Naranja",
        panal: "Panal",
        passcard: "Passcard",
        routex: "Routex",
        sodexo: "Sodexo",
        sodexo_no_luhn: "Sodexo",
        synchrony: "Synchrony",
        tarjeta_d: "Tarjeta_d",
        unionpay: "UnionPay",
        verve: "Verve",
        visa: "Visa",
    };

    const cardTypeName = cardTypes[cardType];

    return cardTypeName ?? cardType;
};

export const convertApiDataToTokenExCardType = (cardType: string) => {
    const loweredCardType = cardType.toLowerCase();

    if (loweredCardType === "mastercard") {
        return "masterCard";
    }
    if (loweredCardType === "american express") {
        return "americanExpress";
    }

    return loweredCardType;
};
