<template>
  <div id="app">
    <the-header v-if="!maintenanceOn"></the-header>

    <main class="bg-color-root pt-4">
      <div class="container">
        <router-view/>
      </div>
    </main>

    <the-overlay v-if="wrongNetwork && isConnected"></the-overlay>
    <the-footer></the-footer>
  </div>
</template>

<script>
import {mapGetters} from "vuex";
import TheHeader from "@/components/UI/TheHeader.vue";
import TheFooter from "@/components/UI/TheFooter.vue";
import typeActions from "@/store/typeActions.js";
import TheOverlay from "@/components/UI/TheOverlay.vue";
import constantesService from "@/services/constantes.service.js";

export default {
  components: {
    TheHeader,
    TheOverlay,
    TheFooter
  },
  data() {
    return {
      maintenanceOn: false
    };
  },
  computed: {
    ...mapGetters("global", ["account", "wrongNetwork", "isConnected"]),
  },
  methods: {
    translateMe(val) {
      return this.$t(val);
    }
  },
  async beforeCreate() {
    await this.$store.dispatch(typeActions.initWeb3);
    await this.$store.dispatch(typeActions.initOnMountedGlobal);
  },
  async checkMaintenance() {
    
  },
  async mounted() {
    // to be able to use $t from state
    this.$store.state.$t = this.translateMe;
    const maintenanceMode = await constantesService.getMaintenanceActive();
    if (maintenanceMode) {
      this.$router.push("maintenance");
      this.maintenanceOn = true;
    }

    this.setIntervalId = setInterval(async () => {
      const maintenanceMode = await constantesService.getMaintenanceActive();
      if (maintenanceMode) {
        this.$router.push("maintenance");
        this.maintenanceOn = true;
      } else {
        this.maintenanceOn = false;
      }
    }, 300000);
   
  },
  beforeUnmount() {
    clearInterval(this.setIntervalId);
  }
  
};
</script>

<style>
:root {
  --text-grey: #878383;
  --light-purple: #d8beeb;
  --normal-purple: #85289b;
  --black-custom: #333;
  --blue-custom: #3F43CD;
  --grey-custom: #f0f4fc;
  --metadex-theme-gradient: linear-gradient(30deg, rgba(19, 0, 36, 1) 0%, rgba(121, 9, 120, 1) 70%, rgba(0, 129, 255, 1) 100%);
  --red-custom: #DB4437;
}

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
}

input:focus + label {
  color: var(--blue-custom);
}

input:focus.in-error + label {
  color: var(--red-custom);
}

small.in-error {
  color: var(--red-custom);
}

.form-control:focus {
  box-shadow: 0 0 0 0.1rem var(--blue-custom);
}

.form-control:focus.in-error {
  box-shadow: 0 0 0 0.1rem var(--red-custom);
}

.card-custom-title {
  padding: 2rem 1rem 0.5rem;
  margin-bottom: 0;
  color: var(--black-custom);
}

.card-custom-info {
  color: var(--text-grey);
  padding: 0 1rem 0;
}

.p-card {
  padding-left: 2rem;
  padding-right: 2rem;
}

.empty-card {
  text-align: center;
}

.empty-card > .empty-card-title {
  font-size: x-large;
  font-weight: bold;
  padding-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--black-custom);
}

.empty-card > .empty-card-description {
  padding-bottom: 2rem;
  color: var(--text-grey);
}

.btn-meta-1 {
  background-color: var(--blue-custom);
  color: white;
  border: none;
}

.btn-meta-1:hover {
  background-color: #3337b8;
  color: white;
}

.btn-meta-1:focus {
  background-color: #3337b8;
  color: white;
}

.btn-meta-2 {
  background-color: var(--grey-custom);
  color: #3F43CD;
  border: none;
}

.btn-meta-2:hover {
  background-color: #e0e4f4;
  color: #3F43CD;
  border: none
}

.btn-meta-3 {
  background-color: white;
  color: var(--black-custom);
  border: none;
}

.btn-meta-3:hover {
  background-color: var(--grey-custom);
  color: var(--black-custom);
  border: none
}

.btn-meta-3:focus {
  background-color: white;
  color: var(--black-custom);
  border: none;
}

hr.dashed {
  border-top: 3px dashed #bbb;
}

.card {
  box-shadow: 10px 5px 15px rgba(0, 0, 0, 0.9);
}

.subtitle-card {
  font-size: 0.7em;
}

.title-figure {
  margin-top: 2rem;
  margin-bottom: unset;
}

.bg-meta-secondary {
  background-color: var(--grey-custom);
}

html {
  background: url('./assets/lightmode_background3.jpg') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

body {
  color: var(--black-custom);
  font-family: 'Sawarabi Gothic';
  font-size: medium;
}

.bg-color-root {
  background: url('./assets/lightmode_background3.jpg') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

footer {
  position: fixed;
  height: 50px;
  bottom: 0;
  width: 100%;
}

@font-face {
  font-family: "Sawarabi Gothic";
  src: local("Sawarabi Gothic"),
  url(./assets/Sawarabi_Gothic/SawarabiGothic-Regular.ttf) format("truetype");
}
</style>
