46 lines
1.8 KiB
Vue
46 lines
1.8 KiB
Vue
<script setup lang="ts">
|
|
const { data: session } = await useSession();
|
|
if (!session.value.user) {
|
|
await navigateTo('/login?next=/admin');
|
|
} else if (session.value.user.role !== 'admin') {
|
|
await navigateTo('/dashboard');
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex min-h-screen flex-col">
|
|
<header class="border-b">
|
|
<div class="page flex h-16 items-center justify-between">
|
|
<NuxtLink to="/" class="text-lg font-bold">
|
|
{{ t('brand.name') }} <span class="muted font-normal">/ {{ t('admin.title') }}</span>
|
|
</NuxtLink>
|
|
<span class="muted text-sm">{{ session.user?.email }}</span>
|
|
</div>
|
|
</header>
|
|
<div class="page flex flex-1 flex-col gap-6 py-8 md:flex-row">
|
|
<aside class="md:w-52 md:shrink-0">
|
|
<nav class="flex gap-1 md:flex-col" aria-label="Admin">
|
|
<NuxtLink to="/admin" class="rounded-lg px-3 py-2 text-sm font-medium hover:bg-black/5 dark:hover:bg-white/10">
|
|
{{ t('admin.overview') }}
|
|
</NuxtLink>
|
|
<NuxtLink to="/admin/products" class="rounded-lg px-3 py-2 text-sm font-medium hover:bg-black/5 dark:hover:bg-white/10">
|
|
Products
|
|
</NuxtLink>
|
|
<NuxtLink to="/admin/orders" class="rounded-lg px-3 py-2 text-sm font-medium hover:bg-black/5 dark:hover:bg-white/10">
|
|
Orders
|
|
</NuxtLink>
|
|
<NuxtLink to="/admin/users" class="rounded-lg px-3 py-2 text-sm font-medium hover:bg-black/5 dark:hover:bg-white/10">
|
|
{{ t('admin.users') }}
|
|
</NuxtLink>
|
|
<NuxtLink to="/admin/audit" class="rounded-lg px-3 py-2 text-sm font-medium hover:bg-black/5 dark:hover:bg-white/10">
|
|
{{ t('admin.audit') }}
|
|
</NuxtLink>
|
|
</nav>
|
|
</aside>
|
|
<main class="min-w-0 flex-1">
|
|
<slot />
|
|
</main>
|
|
</div>
|
|
</div>
|
|
</template>
|