/*
REQUEST_STATUS_PENDING_REVIEW = 0  # initial state
REQUEST_STATUS_APPROVED       = 1  # approved, waiting slicing
REQUEST_STATUS_AWAITING_PRINT = 2  # sliced, in print queur
REQUEST_STATUS_PRINTING       = 3  # currently printing
REQUEST_STATUS_INSPECTING     = 7  # Inspecting finished elment
REQUEST_STATUS_FINISHED       = 4  # done printing, waiting for recuperation
REQUEST_STATUS_CLOSED         = 5  # archived
REQUEST_STATUS_PICKED         = 6  # picked up
REQUEST_STATUS_REJECTED       = 10 # refused by operator
REQUEST_STATUS_PRINT_FAILED   = 11 # print failed more than allowed
REQUEST_STATUS_STANDBY        = 12 # on hold, from any state
*/

module.exports = {
    secondsToHms(d) {
        d = Number(d);
        var h = Math.floor(d / 3600);
        var m = Math.floor(d % 3600 / 60);
        var s = Math.floor(d % 3600 % 60);

        var hDisplay = h > 0 ? h + (h == 1 ? " h, " : "h, ") : "";
        var mDisplay = m > 0 ? m + (m == 1 ? " min, " : " min, ") : "";
        var sDisplay = s > 0 ? s + (s == 1 ? " sec" : " sec") : "";
        return hDisplay + mDisplay + sDisplay; 
    },
    available_status_code () {
        return [0, 1, 2, 3, 7, 4, 5, 10, 11, 12]
    },
    account_type_text (access) {
        switch (access) {
            case -1:
                return {text: 'Banni', color: 'red', icon: 'mdi-account-cancel'}
            case 0:
                return {text: 'Utilisateur', color: 'white', icon: 'mdi-account'}
            case 1:
                return {text: 'Observateur', color: 'yellow', icon: 'mdi-account-search'}
            case 2:
                return {text: 'Administrateur', color: 'red', icon: 'mdi-account-cog'}
        }
    },
    status_to_icon_info (status){
        switch (status) {
            case 0:
                return {text: 'mdi-cog', color: 'blue'}
            case 1:
                return {text: 'mdi-progress-wrench', color: 'indigo'}
            case 2:
                return {text: 'mdi-printer-3d', color: 'indigo'}
            case 3:
                return {text: 'mdi-printer-3d-nozzle', color: 'indigo'}
            case 7:
                return {text: 'mdi-magnify', color: 'blue'}
            case 4:
                return {text: 'mdi-check-circle', color: 'green'}
            case 5:
                return {text: 'mdi-archive', color: 'grey'}
            case 6:
                return {text: 'mdi-check-all', color: 'green'}
         
            case 10:
                return {text: 'mdi-account-alert', color: 'red'}
            case 11:
                return {text: 'mdi-printer-3d-nozzle-alert', color: 'red'}
            case 12:
                return {text: 'mdi-pause-circle', color: 'yellow'}
            default:
                return {text: 'mdi-help', color: 'red'}

        }
    },
    status_to_text (status) {
        switch (status) {
            case 0:
                return "En attente d'approbation"
            case 1:
                return "Préparation de l'impression"
            case 2:
                return "En attente d'impression"
            case 3:
                return "En cours d'impression"
            case 7:
                return "En cours d'inspection"
            case 4:
                return "Prêt à être récupéré"
            case 5:
                return "Cloturé"
            case 6:
                return "Récupéré"
            
            case 10:
                return "Rejeté par un opérateur"
            case 11:
                return "Echec d'impression"
            case 12:
                return "En attente"
            default:
                return "Status inconnu"
        }
    }
}