<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>
        </div>
        <div class="navbar-end">
          <div
            class="navbar-item has-dropdown is-active"
            v-for="category in categories.keys()"
            :key="category"
          >
            <div class="navbar-link">
              {{ category }}
            </div>

            <div
              class="navbar-dropdown"
              v-for="subcategory in categories.get(category)"
              :key="subcategory"
            >
              {{ subcategory }}
            </div>
          </div>

          <div class="navbar-item">
            <div class="buttons">
              <button class="button">
                Cart (5)
              </button>
              <button class="button is-info">
                Checkout
              </button>
            </div>
          </div>
        </div>
      </div>
    </nav>
  </div>
</template>

<script>
import Category from "~models/category.js";

export default {
  name: "Navbar",
  data() {
    return {
      isMenuActive: false
    };
  },
  computed: {
    navMenu() {
      if (this.isMenuActive) {
        return "navbar-menu is-active";
      } else {
        return "navbar-menu";
      }
    },
    categories() {
      const inventory = this.$store.getters.inventory;
      console.log(inventory);
      console.log(inventory.map(item => item.categories));

      //console.log(cats);
      return [];
    }
  },
  methods: {
    toggleNavMenu() {
      this.isMenuActive = !this.isMenuActive;
    }
  }
};
</script>
