<template>
  <div class="dash_wrap">
    <div class="row sm-all">
      <aside id="dashboard_sidebar" class="dashboard_sidebar d-1of5">
        <div class="sidebar-wrap">
          <div class="setting-logo">
            <img
              :src="logo_path+'logo-white.svg'"
            />
          </div>
          <!-- Sidebar navigation -->
          <ul class="nav sidebar-nav">
            <router-link to="/">
              <li>
                Settings
                <span><i class="fa fa-chevron-right"></i></span>
              </li>
            </router-link>

            <router-link to="/entities">
              <li>
                Entities
                <span><i class="fa fa-chevron-right"></i></span>
              </li>
            </router-link>

            <a href="https://www.bluearray.co.uk/enstract/" target="_blank">
              <li>
                Contact us
                <span><i class="fa fa-chevron-right"></i></span>
              </li>
            </a>
          </ul>
        </div>
      </aside>

      <div class="dashboard-content">
        <router-view v-bind="props"></router-view>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      logo_path: "",
      hasOnBoarded: false,
    };
  },
  mounted() {
    this.logo_path = wpApiSettings.assets_url;

    if (localStorage.getItem("dashboard_height")) {
      jQuery(".dashboard-content").height(
        localStorage.getItem("dashboard_height")
      );
    } else {
      localStorage.setItem("dashboard_height", jQuery(".dash_wrap").height());
    }

    if (this.hasOnBoarded == 1) {
      this.$router.push({ name: "dashboard.settings" });
    }
  },
  watch: {
    $route(to, from) {
      if (localStorage.getItem("dashboard_height")) {
        jQuery(".dashboard-content").height(
          localStorage.getItem("dashboard_height")
        );
      } else {
        localStorage.setItem("dashboard_height", jQuery(".dash_wrap").height());
      }
    },
  },
  methods: {
    updateState(data) {
      this.hasOnBoarded = data;
    },
  },
  props: ["props"],
};
</script>