// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
import vuetify from "@/plugins/vuetify";
import "@mdi/font/css/materialdesignicons.css";
import store from "./store/store";
import axios from "axios";

// Vue.config.silent = true
// ! FIXME
axios.defaults.baseURL = "/myfab/api";
if (process.env['NODE_ENV'] != 'production') {
  axios.defaults.baseURL = "http://127.0.0.1:5000/"; // uncomment for local dev
}

export const bus = new Vue();
Vue.use(require("vue-cookies"));

if (Vue.$cookies.get("authjwt") != undefined) {
  // console.log(Vue.$cookies.get("authjwt"));
  axios.defaults.headers.common = {
    Authorization: `Bearer ${Vue.$cookies.get("authjwt")}`
  };
  store.dispatch("load_user_infos");
  console.log("[DEBUG] Loaded user infos");
} else {
  console.log("[DEBUG] No connection detected");
}

Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
  vuetify,
  store,
  el: "#app",
  router,
  components: { App },
  template: "<App/>"
});
