<template>
  <div id="navbar">
    <nav class="navbar is-fixed-top is-transparent">
      <div class="navbar-brand">
        <div class="navbar-item">
          <img src="@/assets/logo.png" />
          <div class="navbar-item">
            <span>
              The Glassy Ladies
            </span>
          </div>
        </div>
        <a class="navbar-burger burger" v-on:click="toggleNavMenu">
          <span></span>
          <span></span>
          <span></span>
        </a>
      </div>
      <div :class="navMenu">
        <div class="navbar-start">
          <router-link to="/" class="navbar-item">
            Home
          </router-link>
          <router-link to="/about" class="navbar-item">
            About
          </router-link>
          <router-link to="/admin" class="navbar-item">
            Admin
          </router-link>
        </div>

        <transition
          mode="out-in"
          enter-active-class="animate__animated animate__flipInX"
          leave-active-class="animate__animated animate__flipOutX"
        >
          <div
            class="navbar-end"
            v-if="routeName != 'Administration'"
            key="cartCheckout"
          >
            <div
              class="navbar-item has-dropdown is-active"
              v-for="category in categories"
              :key="category"
            >
              <div class="navbar-link">
                {{ category }}
              </div>
            </div>

            <div class="navbar-item">
              <CartCheckout></CartCheckout>
            </div>
          </div>
        </transition>
      </div>
    </nav>
  </div>
</template>

<script>
import CartCheckout from "@/components/CartCheckout.vue";

export default {
  name: "Navbar",
  components: {
    CartCheckout
  },
  data() {
    return {
      isMenuActive: true
    };
  },
  computed: {
    navMenu() {
      if (this.isMenuActive) {
        return "navbar-menu is-active";
      } else {
        return "navbar-menu";
      }
    },
    categories() {
      //const raw = this.$store.getters.products.map(p => p.category.split("/"));
      //const raw = [
      //  [1, 2, 3],
      //  [1, 2, 4],
      //  [1, 5],
      //  [6, 7]
      //];
      return [];
    },
    routeName() {
      return this.$route.name;
    }
  },
  methods: {
    generateCategories() {
      let results = [];

      return results;
    },
    toggleNavMenu() {
      this.isMenuActive = !this.isMenuActive;
    }
  }
};
</script>
