<template>
  <div id="q-app">
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  preFetch({
    store,
    currentRoute,
    previousRoute,
    redirect,
    ssrContext,
    urlPath,
    publicPath,
  }) {
    let meta = Object.keys(currentRoute.meta);
    if (meta) {
      meta = meta[0];
    }
    return store
      .dispatch("auth/fetchLoggedInUserInfo")
      .then((res) => {
        switch (meta) {
          case "guestMiddleware":
            redirect("/qbank/dashboard/welcome");
            break;
          default:
        }
      })
      .catch((e) => {
        switch (meta) {
          case "requiresAuth":
            redirect("/login");
            break;
          default:
        }
        console.log("not logged in prefetch");
      });
  },
  mounted() {
    this.$store.commit("cart/initCart");
  }
};
</script>
<style >
.watch-link:hover {
  background: lightblue !important;
}
.fa-check-circle {
  font-size: 3em;
  color: green;
}
.fa-times-circle {
  font-size: 3em;
  color: red;
}
.custom-notification {
  width: 330px;
  padding: 14px 26px 14px 13px;
  border-radius: 8px;
  box-sizing: border-box;
  border: 1px solid #ebeef5;
  background-color: #fff !important;
  color: #606266 !important;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s,
    bottom 0.3s;
  overflow: hidden;
}
.round-img {
  border: 2px solid #ecedf1;
  border-radius: 50%;
  width: 160px;
  height: 160px;
  max-width: 160px;
}
.free-trial-color {
  background: #04b1ed !important;
}
.link {
  cursor: pointer;
}
</style>