All files / js/components AppSidebarHeader.vue

0% Statements 0/14
0% Branches 0/10
0% Functions 0/4
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                               
<script setup lang="ts">
import Breadcrumbs from '@/components/Breadcrumbs.vue';
import CompanySwitcher from '@/components/CompanySwitcher.vue';
import ListViewColumnsEditor from '@/components/ListViewColumnsEditor.vue';
import { SidebarTrigger } from '@/components/ui/sidebar';
import type { BreadcrumbItemType } from '@/types';
import { usePage } from '@inertiajs/vue3';
import { computed } from 'vue';
 
interface Company {
    id: number;
    name: string;
    logo_path: string | null;
    is_default: boolean;
}
 
const props = withDefaults(
    defineProps<{
        breadcrumbs?: BreadcrumbItemType[];
    }>(),
    {
        breadcrumbs: () => [],
    },
);
 
const page = usePage();
 
const currentCompany = computed(() => page.props.currentCompany as Company | null);
const companies = computed(() => page.props.companies as Company[] || []);
const userType = computed(() => (page.props.auth?.user as { user_type?: string } | null)?.user_type ?? 'standard');
const showCompanySwitcher = computed(() => userType.value !== 'client');
</script>
 
<template>
    <header
        class="flex h-16 shrink-0 items-center justify-between gap-2 border-b border-sidebar-border/70 px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4"
    >
        <div class="flex items-center gap-2">
            <SidebarTrigger class="-ml-1" />
            <template v-if="breadcrumbs && breadcrumbs.length > 0">
                <Breadcrumbs :breadcrumbs="breadcrumbs" />
            </template>
        </div>
        
        <!-- Company Switcher -->
        <div class="flex items-center gap-2">
            <ListViewColumnsEditor />
            <CompanySwitcher
                v-if="showCompanySwitcher"
                :current-company="currentCompany" 
                :companies="companies" 
            />
        </div>
    </header>
</template>