79 lines
2.7 KiB
Vue
79 lines
2.7 KiB
Vue
<script setup>
|
|
/**
|
|
* AppHeader.vue
|
|
*
|
|
* Top app bar, full width, above the sidebar/content row - modeled on
|
|
* docs/sample_ui.png's own header (brand mark + breadcrumb on the left,
|
|
* an account menu on the right). Only real, functional elements are
|
|
* included (no decorative "Ask AI"/"Support" buttons that do nothing) -
|
|
* the account menu is the one piece of chrome this app actually has to
|
|
* offer there (email + sign out), same as the account-bar it replaces.
|
|
*/
|
|
import { ref, onMounted, onUnmounted } from 'vue'
|
|
import { useAuthStore } from '../stores/authStore'
|
|
import { useProjectsStore } from '../stores/projectsStore'
|
|
import * as authService from '../services/authService'
|
|
|
|
const authStore = useAuthStore()
|
|
const projectsStore = useProjectsStore()
|
|
|
|
const menuOpen = ref(false)
|
|
const menuRef = ref(null)
|
|
|
|
function toggleMenu() {
|
|
menuOpen.value = !menuOpen.value
|
|
}
|
|
|
|
function handleOutsideClick(e) {
|
|
if (menuOpen.value && menuRef.value && !menuRef.value.contains(e.target)) {
|
|
menuOpen.value = false
|
|
}
|
|
}
|
|
|
|
onMounted(() => window.addEventListener('click', handleOutsideClick))
|
|
onUnmounted(() => window.removeEventListener('click', handleOutsideClick))
|
|
|
|
function handleSignOut() {
|
|
menuOpen.value = false
|
|
authService.logout()
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<header class="app-header">
|
|
<div class="app-header-left">
|
|
<div class="app-logo">
|
|
<i class="fa-solid fa-file-invoice-dollar"></i>
|
|
</div>
|
|
<nav class="app-breadcrumb" aria-label="Breadcrumb">
|
|
<span class="app-breadcrumb-root">Bettersight</span>
|
|
<i class="fa-solid fa-chevron-right"></i>
|
|
<span>Statement Extractor</span>
|
|
<template v-if="projectsStore.activeProjectId">
|
|
<i class="fa-solid fa-chevron-right"></i>
|
|
<span class="app-breadcrumb-current">
|
|
{{ projectsStore.projects.find((p) => p.id === projectsStore.activeProjectId)?.name }}
|
|
</span>
|
|
</template>
|
|
</nav>
|
|
</div>
|
|
|
|
<div class="app-header-right">
|
|
<div ref="menuRef" class="app-account">
|
|
<button type="button" class="app-account-trigger" @click="toggleMenu">
|
|
<span class="app-avatar"><i class="fa-solid fa-user"></i></span>
|
|
<span class="app-account-email">{{ authStore.user?.email }}</span>
|
|
<i class="fa-solid fa-chevron-down app-account-caret" :class="{ open: menuOpen }"></i>
|
|
</button>
|
|
<div v-if="menuOpen" class="app-account-menu">
|
|
<div class="app-account-menu-email">{{ authStore.user?.email }}</div>
|
|
<button type="button" class="app-account-menu-item" @click="handleSignOut">
|
|
<i class="fa-solid fa-arrow-right-from-bracket"></i>
|
|
Sign out
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
</template>
|