const release = "binkrassdufass.dirty"
const apiClientBaseURL = "/api/"

const originURL = "https://bkdf-tibi-2024.code.testversion.online"
const cryptchaSiteId = "66cb701e093846000151707e"

// @ts-ignore
if (release && typeof context !== "undefined") {
    context.response.header("X-Release", release)
}
/**
 *
 * @param {number} price
 * @param {number} quantity

 * @returns {number|string}
 */
function formatPrice(price, quantity = 1) {
    const newPrice = Math.floor((Math.round(price * 100) / 100) * quantity)
    return newPrice.toFixed(2) + " €"
}
const daysForReturn = 30
const daysToArrive = 3
/**
 *
 * @param {Date} countdownStart
 * @returns {Date}
 */
function getLastDayForReturn(countdownStart) {
    const date = new Date(countdownStart)
    date.setDate(date.getDate() + daysForReturn + daysToArrive)
    return date
}

/**
 *
 * @param {Date} countdownStart
 * @returns {boolean}
 */
function checkIfOrderMayArrived(countdownStart) {
    const date = new Date(countdownStart)
    date.setDate(date.getDate() + daysToArrive)
    return date < new Date()
}

module.exports = {
    release,
    apiClientBaseURL,
    frontendBase: "https://binkrassdufass.de/",
    tibiUrl: "https://dev.tibicms.de",
    bkdfApiUrl: "https://binkrassdufass.de/api/",
    originURL,
    cryptchaSiteId,
    formatPrice,
    daysForReturn: daysForReturn,
    getLastDayForReturn,
    daysToArrive,
    checkIfOrderMayArrived,
}
