Merge manager tools into main cabinet
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery } from '@vue/apollo-composable';
|
||||
import { MeDocument } from '~/composables/graphql/generated';
|
||||
|
||||
type NavItem = {
|
||||
to: string;
|
||||
label: string;
|
||||
@@ -6,11 +9,23 @@ type NavItem = {
|
||||
|
||||
const route = useRoute();
|
||||
const { totalItems } = useClientCart();
|
||||
const meQuery = useQuery(MeDocument);
|
||||
|
||||
const centerCapsule: NavItem[] = [
|
||||
{ to: '/', label: 'Каталог' },
|
||||
{ to: '/orders', label: 'Мои заказы' },
|
||||
];
|
||||
const centerCapsule = computed<NavItem[]>(() => {
|
||||
const items: NavItem[] = [
|
||||
{ to: '/', label: 'Каталог' },
|
||||
{ to: '/orders', label: 'Мои заказы' },
|
||||
];
|
||||
|
||||
if (meQuery.result.value?.me?.role === 'MANAGER') {
|
||||
items.push(
|
||||
{ to: '/clients', label: 'Клиенты' },
|
||||
{ to: '/client-orders', label: 'Заказы клиентов' },
|
||||
);
|
||||
}
|
||||
|
||||
return items;
|
||||
});
|
||||
|
||||
const rightCapsule: NavItem[] = [
|
||||
{ to: '/cart', label: 'Корзина' },
|
||||
@@ -24,6 +39,12 @@ function isActive(path: string) {
|
||||
if (path === '/orders') {
|
||||
return route.path === '/orders' || route.path.startsWith('/orders/');
|
||||
}
|
||||
if (path === '/clients') {
|
||||
return route.path === '/clients' || route.path.startsWith('/clients/');
|
||||
}
|
||||
if (path === '/client-orders') {
|
||||
return route.path === '/client-orders' || route.path.startsWith('/client-orders/');
|
||||
}
|
||||
return route.path === path;
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user