aboutsummaryrefslogtreecommitdiff
path: root/src/components/navbar.vue
blob: 0956d30571c11c87fe20bcd5d1f2e52dfecd2b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<script setup lang="js">
import { watch, ref } from 'vue'
import { RouterLink, useRoute } from 'vue-router'

const requiresAuth = ref(true)
const route = useRoute()
watch(
  () => route.name,
  async () => {
    requiresAuth.value = route.meta.isAuth
  }
)
</script>

<template>
  <nav class="navbar navbar-expand-lg">
    <div class="container-fluid">
      <RouterLink class="navbar-brand" to="/">OpenBills</RouterLink>

      <button
        class="navbar-toggler"
        type="button"
        data-bs-toggle="collapse"
        data-bs-target="#navbarSupportedContent"
        aria-controls="navbarSupportedContent"
        aria-expanded="false"
        aria-label="Toggle navigation"
      >
        <i class="bi bi-list" id="nav-toggler-icon"></i>
      </button>

      <div v-if="requiresAuth" class="collapse navbar-collapse" id="navbarSupportedContent">
        <span class="me-auto"></span>
        <ul class="navbar-nav mb-2 mb-lg-0">
          <li class="nav-item">
            <RouterLink to="/" class="nav-link">Home</RouterLink>
          </li>
          <li class="nav-item dropdown">
            <a
              class="nav-link dropdown-toggle"
              href="#"
              role="button"
              data-bs-toggle="dropdown"
              aria-expanded="false"
            >
              View
            </a>
            <ul class="dropdown-menu">
              <li><RouterLink to="/customer" class="dropdown-item">Customers</RouterLink></li>
              <li><RouterLink to="/brand" class="dropdown-item">Brands</RouterLink></li>
              <li><RouterLink to="/item" class="dropdown-item">Items</RouterLink></li>
            </ul>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Link</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Link</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>
</template>

<style>
#nav-toggler-icon {
  font-size: 1.5rem;
}
</style>