//CTRL+M+H => Tạo region code




//#region Imports
import Vue from 'vue';
import axios from 'axios';
import router from './router/index';
import store from './store';
import { sync } from 'vuex-router-sync';
import App from 'views/app-root';
import Toast from "vue-toastification";
import "vue-toastification/dist/index.css";
import Vuelidate from 'vuelidate'
//#endregion

//#region Toast
var toastOption = {
    position: "bottom-left",
    timeout: 5000,
    closeOnClick: true,
    pauseOnFocusLoss: true,
    pauseOnHover: true,
    draggable: true,
    draggablePercent: 0.6,
    showCloseButtonOnHover: false,
    hideProgressBar: false,
    closeButton: "button",
    icon: true,
    rtl: false
};

Vue.use(Toast, toastOption);
//#endregion

//#region User
var username = '';
var userId = 0;
if (userInfo !== undefined) {
    for (var i = 0; i < userInfo.length; i++) {
        if (userInfo[i].Type === 'preferred_username') {
            username = userInfo[i].Value;
        }
        else if (userInfo[i].Type === 'sub') {
            userId = parseInt(userInfo[i].Value);
        }
    }
}
var user = {
    Username: username,
    UserId: userId
}
store.commit('UPDATE_USER', user);
//#endregion

//#region Axios
var options = {
    headers: {
        "Authorization": "Bearer " +  accessToken  ,
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Expires": "-1"
    }
};
const axiosInstant = axios.create(options);
Vue.prototype.$http = axiosInstant;
//#endregion

Vue.use(Vuelidate);

const app = new Vue({
    store,
    router,
    ...App
})

export {
    app,
    router,
    store
}
