Navbar-Rework #50
@@ -1,4 +1,5 @@
|
|||||||
import pool from '../db';
|
import pool from '../db';
|
||||||
|
import { Role } from '@app/shared/types/roles'
|
||||||
|
|
||||||
export async function assignUserGroup(userID: number, roleID: number) {
|
export async function assignUserGroup(userID: number, roleID: number) {
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ export async function createGroup(name: string, color: string, description: stri
|
|||||||
return { id: result.insertId, name, color, description };
|
return { id: result.insertId, name, color, description };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserRoles(userID: number) {
|
export async function getUserRoles(userID: number): Promise<Role[]> {
|
||||||
const sql = `SELECT r.id, r.name
|
const sql = `SELECT r.id, r.name
|
||||||
FROM members_roles mr
|
FROM members_roles mr
|
||||||
INNER JOIN roles r ON mr.role_id = r.id
|
INNER JOIN roles r ON mr.role_id = r.id
|
||||||
|
|||||||
6
shared/types/roles.ts
Normal file
6
shared/types/roles.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface Role {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
color?: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
8
ui/package-lock.json
generated
8
ui/package-lock.json
generated
@@ -22,7 +22,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"lucide-vue-next": "^0.539.0",
|
"lucide-vue-next": "^0.539.0",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"reka-ui": "^2.6.0",
|
"reka-ui": "^2.6.1",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tailwindcss": "^4.1.11",
|
"tailwindcss": "^4.1.11",
|
||||||
"tw-animate-css": "^1.3.6",
|
"tw-animate-css": "^1.3.6",
|
||||||
@@ -3333,9 +3333,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/reka-ui": {
|
"node_modules/reka-ui": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.6.1.tgz",
|
||||||
"integrity": "sha512-NrGMKrABD97l890mFS3TNUzB0BLUfbL3hh0NjcJRIUSUljb288bx3Mzo31nOyUcdiiW0HqFGXJwyCBh9cWgb0w==",
|
"integrity": "sha512-XK7cJDQoNuGXfCNzBBo/81Yg/OgjPwvbabnlzXG2VsdSgNsT6iIkuPBPr+C0Shs+3bb0x0lbPvgQAhMSCKm5Ww==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@floating-ui/dom": "^1.6.13",
|
"@floating-ui/dom": "^1.6.13",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"lucide-vue-next": "^0.539.0",
|
"lucide-vue-next": "^0.539.0",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"reka-ui": "^2.6.0",
|
"reka-ui": "^2.6.1",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tailwindcss": "^4.1.11",
|
"tailwindcss": "^4.1.11",
|
||||||
"tw-animate-css": "^1.3.6",
|
"tw-animate-css": "^1.3.6",
|
||||||
|
|||||||
BIN
ui/public/17RBN_Logo.png
Normal file
BIN
ui/public/17RBN_Logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
107
ui/src/App.vue
107
ui/src/App.vue
@@ -1,41 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { RouterLink, RouterView } from 'vue-router';
|
import { RouterView } from 'vue-router';
|
||||||
import Separator from './components/ui/separator/Separator.vue';
|
|
||||||
import Button from './components/ui/button/Button.vue';
|
import Button from './components/ui/button/Button.vue';
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover';
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from './components/ui/dropdown-menu';
|
|
||||||
import { onMounted } from 'vue';
|
|
||||||
import { useUserStore } from './stores/user';
|
import { useUserStore } from './stores/user';
|
||||||
import Alert from './components/ui/alert/Alert.vue';
|
import Alert from './components/ui/alert/Alert.vue';
|
||||||
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
||||||
|
import Navbar from './components/Navigation/Navbar.vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// onMounted(async () => {
|
|
||||||
// const res = await fetch(`${import.meta.env.VITE_APIHOST}/members/me`, {
|
|
||||||
// credentials: 'include',
|
|
||||||
// });
|
|
||||||
// const data = await res.json();
|
|
||||||
// console.log(data);
|
|
||||||
// userStore.user = data;
|
|
||||||
// });
|
|
||||||
const APIHOST = import.meta.env.VITE_APIHOST;
|
|
||||||
|
|
||||||
async function logout() {
|
|
||||||
// await fetch(`${APIHOST}/logout`, {
|
|
||||||
// method: 'GET',
|
|
||||||
// credentials: 'include',
|
|
||||||
// });
|
|
||||||
|
|
||||||
userStore.user = null;
|
|
||||||
window.location.href = APIHOST + "/logout";
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(dateStr) {
|
function formatDate(dateStr) {
|
||||||
if (!dateStr) return "";
|
if (!dateStr) return "";
|
||||||
return new Date(dateStr).toLocaleDateString("en-US", {
|
return new Date(dateStr).toLocaleDateString("en-US", {
|
||||||
@@ -49,77 +21,8 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="flex flex-col min-h-screen">
|
||||||
<div class="flex items-center justify-between px-10">
|
<Navbar class="flex"></Navbar>
|
||||||
<div></div>
|
|
||||||
<div class="h-15 flex items-center justify-center gap-20">
|
|
||||||
<RouterLink to="/">
|
|
||||||
<Button variant="link">Home</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/calendar">
|
|
||||||
<Button variant="link">Calendar</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/members">
|
|
||||||
<Button variant="link">Members</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger as-child>
|
|
||||||
<Button variant="link">Forms</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent class="flex flex-col gap-4 items-center w-min">
|
|
||||||
<RouterLink to="/transfer">
|
|
||||||
<Button variant="link">Transfer Request</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/trainingReport">
|
|
||||||
<Button variant="link">Training Report</Button>
|
|
||||||
</RouterLink>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger as-child>
|
|
||||||
<Button variant="link">Administration</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent class="flex flex-col gap-4 items-center w-min">
|
|
||||||
<RouterLink to="/administration/rankChange">
|
|
||||||
<Button variant="link">Promotions</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/loa">
|
|
||||||
<Button variant="link">Leave of Absence</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/transfer">
|
|
||||||
<Button variant="link">Transfer Requests</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/applications">
|
|
||||||
<Button variant="link">Recruitment</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/roles">
|
|
||||||
<Button variant="link">Role Management</Button>
|
|
||||||
</RouterLink>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<DropdownMenu v-if="userStore.isLoggedIn">
|
|
||||||
<DropdownMenuTrigger class="cursor-pointer">
|
|
||||||
<p>{{ userStore.user.name }}</p>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
|
||||||
<DropdownMenuItem>My Profile</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem>Settings</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem>
|
|
||||||
<RouterLink to="/loa">
|
|
||||||
Submit LOA
|
|
||||||
</RouterLink>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem :variant="'destructive'" @click="logout()">Logout</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
<a v-else :href="APIHOST + '/login'">Login</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Separator></Separator>
|
|
||||||
<Alert v-if="environment == 'dev'" class="m-2 mx-auto w-5xl" variant="info">
|
<Alert v-if="environment == 'dev'" class="m-2 mx-auto w-5xl" variant="info">
|
||||||
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
||||||
<p>This is a development build of the application. Some features will be unavailable or unstable.</p>
|
<p>This is a development build of the application. Some features will be unavailable or unstable.</p>
|
||||||
@@ -132,7 +35,7 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
|||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
<RouterView class=""></RouterView>
|
<RouterView class="flex-1 min-h-0"></RouterView>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
--secondary-foreground: oklch(0.9219 0 0);
|
--secondary-foreground: oklch(0.9219 0 0);
|
||||||
--muted: oklch(0.2686 0 0);
|
--muted: oklch(0.2686 0 0);
|
||||||
--muted-foreground: oklch(0.7155 0 0);
|
--muted-foreground: oklch(0.7155 0 0);
|
||||||
--accent: oklch(0.4732 0.1247 46.2007);
|
--accent: oklch(100% 0.00011 271.152 / 0.253);
|
||||||
--accent-foreground: oklch(0.9243 0.1151 95.7459);
|
--accent-foreground: oklch(100% 0.00011 271.152);
|
||||||
--destructive: oklch(0.6368 0.2078 25.3313);
|
--destructive: oklch(0.6368 0.2078 25.3313);
|
||||||
--destructive-foreground: oklch(1.0000 0 0);
|
--destructive-foreground: oklch(1.0000 0 0);
|
||||||
--success: oklch(66.104% 0.16937 144.153);
|
--success: oklch(66.104% 0.16937 144.153);
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
/* .dark {
|
||||||
--background: oklch(0.2046 0 0);
|
--background: oklch(0.2046 0 0);
|
||||||
--foreground: oklch(0.9219 0 0);
|
--foreground: oklch(0.9219 0 0);
|
||||||
--card: oklch(23.075% 0.00003 271.152);
|
--card: oklch(23.075% 0.00003 271.152);
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
--shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 4px 6px -2px hsl(0 0% 0% / 0.14);
|
--shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 4px 6px -2px hsl(0 0% 0% / 0.14);
|
||||||
--shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 8px 10px -2px hsl(0 0% 0% / 0.14);
|
--shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 8px 10px -2px hsl(0 0% 0% / 0.14);
|
||||||
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
||||||
}
|
} */
|
||||||
|
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
|
|||||||
180
ui/src/components/Navigation/Navbar.vue
Normal file
180
ui/src/components/Navigation/Navbar.vue
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { RouterLink } from 'vue-router';
|
||||||
|
import Separator from '../ui/separator/Separator.vue';
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from '../ui/dropdown-menu';
|
||||||
|
import { useUserStore } from '@/stores/user';
|
||||||
|
import Button from '../ui/button/Button.vue';
|
||||||
|
import NavigationMenu from '../ui/navigation-menu/NavigationMenu.vue';
|
||||||
|
import NavigationMenuList from '../ui/navigation-menu/NavigationMenuList.vue';
|
||||||
|
import NavigationMenuItem from '../ui/navigation-menu/NavigationMenuItem.vue';
|
||||||
|
import NavigationMenuLink from '../ui/navigation-menu/NavigationMenuLink.vue';
|
||||||
|
import NavigationMenuTrigger from '../ui/navigation-menu/NavigationMenuTrigger.vue';
|
||||||
|
import NavigationMenuContent from '../ui/navigation-menu/NavigationMenuContent.vue';
|
||||||
|
import { navigationMenuTriggerStyle } from '../ui/navigation-menu/'
|
||||||
|
import { useAuth } from '@/composables/useAuth';
|
||||||
|
import { CircleArrowOutUpRight } from 'lucide-vue-next';
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const auth = useAuth();
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
const APIHOST = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
|
async function logout() {
|
||||||
|
userStore.user = null;
|
||||||
|
window.location.href = APIHOST + "/logout";
|
||||||
|
}
|
||||||
|
|
||||||
|
function blurAfter() {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
(document.activeElement as HTMLElement)?.blur();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="w-full border-b">
|
||||||
|
<div class="max-w-screen-3xl w-full mx-auto flex items-center justify-between pr-10 pl-7">
|
||||||
|
<!-- left side -->
|
||||||
|
<div class="flex items-center gap-7">
|
||||||
|
<RouterLink to="/">
|
||||||
|
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
||||||
|
</RouterLink>
|
||||||
|
<!-- Member navigation -->
|
||||||
|
<div v-if="auth.accountStatus.value == 'member'" class="h-15 flex items-center justify-center">
|
||||||
|
<NavigationMenu>
|
||||||
|
<NavigationMenuList class="gap-3">
|
||||||
|
|
||||||
|
<!-- Calendar -->
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/calendar" @click="blurAfter">Calendar</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Members -->
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/" @click="blurAfter">Documents</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Forms (Dropdown) -->
|
||||||
|
<NavigationMenuItem class="bg-none !focus:bg-none !active:bg-none">
|
||||||
|
<NavigationMenuTrigger>Forms</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent
|
||||||
|
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/loa" @click="blurAfter">
|
||||||
|
Leave of Absence
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/transfer" @click="blurAfter">
|
||||||
|
Transfer Request
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/trainingReport" @click="blurAfter">
|
||||||
|
Training Report
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Administration (Dropdown) -->
|
||||||
|
<NavigationMenuItem
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command', 'Recruiter'])">
|
||||||
|
<NavigationMenuTrigger>Administration</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent
|
||||||
|
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
||||||
|
|
||||||
|
<NavigationMenuLink
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/rankChange" @click="blurAfter">
|
||||||
|
Promotions
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/loa" @click="blurAfter">
|
||||||
|
Leave of Absence
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/transfer" @click="blurAfter">
|
||||||
|
Transfer Requests
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink v-if="auth.hasRole('Recruiter')" as-child
|
||||||
|
:class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/applications" @click="blurAfter">
|
||||||
|
Recruitment
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink v-if="auth.hasRole('17th Administrator')" as-child
|
||||||
|
:class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/roles" @click="blurAfter">
|
||||||
|
Role Management
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<NavigationMenuItem as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/members" @click="blurAfter">
|
||||||
|
Members (debug)
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
</NavigationMenuList>
|
||||||
|
</NavigationMenu>
|
||||||
|
</div>
|
||||||
|
<!-- Guest navigation -->
|
||||||
|
<div v-else class="h-15 flex items-center justify-center">
|
||||||
|
<NavigationMenu>
|
||||||
|
<NavigationMenuList>
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/join" @click="blurAfter">Join</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
</NavigationMenuList>
|
||||||
|
</NavigationMenu>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- right side -->
|
||||||
|
<div>
|
||||||
|
<DropdownMenu v-if="userStore.isLoggedIn">
|
||||||
|
<DropdownMenuTrigger class="cursor-pointer">
|
||||||
|
<p>{{ userStore.user.name }}</p>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent>
|
||||||
|
<DropdownMenuItem>My Profile</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem>Settings</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem :variant="'destructive'" @click="logout()">Logout</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
<a v-else :href="APIHOST + '/login'">Login</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <Separator></Separator> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -101,7 +101,7 @@ function toMariaDBDatetime(date: Date): string {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-row-reverse gap-6 mx-auto " :class="!adminMode ? 'max-w-5xl' : 'max-w-5xl'">
|
<div class="flex flex-row-reverse gap-6 mx-auto w-full" :class="!adminMode ? 'max-w-5xl' : 'max-w-5xl'">
|
||||||
<div v-if="!adminMode" class="flex-1 flex space-x-4 rounded-md border p-4">
|
<div v-if="!adminMode" class="flex-1 flex space-x-4 rounded-md border p-4">
|
||||||
<div class="flex-2 space-y-1">
|
<div class="flex-2 space-y-1">
|
||||||
<p class="text-sm font-medium leading-none">
|
<p class="text-sm font-medium leading-none">
|
||||||
|
|||||||
45
ui/src/components/ui/navigation-menu/NavigationMenu.vue
Normal file
45
ui/src/components/ui/navigation-menu/NavigationMenu.vue
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuRoot, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import NavigationMenuViewport from "./NavigationMenuViewport.vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: { type: String, required: false },
|
||||||
|
defaultValue: { type: String, required: false },
|
||||||
|
dir: { type: String, required: false },
|
||||||
|
orientation: { type: String, required: false },
|
||||||
|
delayDuration: { type: Number, required: false },
|
||||||
|
skipDelayDuration: { type: Number, required: false },
|
||||||
|
disableClickTrigger: { type: Boolean, required: false },
|
||||||
|
disableHoverTrigger: { type: Boolean, required: false },
|
||||||
|
disablePointerLeaveClose: { type: Boolean, required: false },
|
||||||
|
unmountOnHide: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
viewport: { type: Boolean, required: false, default: true },
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "viewport");
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuRoot
|
||||||
|
v-slot="slotProps"
|
||||||
|
data-slot="navigation-menu"
|
||||||
|
:data-viewport="viewport"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
<NavigationMenuViewport v-if="viewport" />
|
||||||
|
</NavigationMenuRoot>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuContent, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
forceMount: { type: Boolean, required: false },
|
||||||
|
disableOutsidePointerEvents: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
const emits = defineEmits([
|
||||||
|
"escapeKeyDown",
|
||||||
|
"pointerDownOutside",
|
||||||
|
"focusOutside",
|
||||||
|
"interactOutside",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuContent
|
||||||
|
data-slot="navigation-menu-content"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto',
|
||||||
|
'group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuIndicator, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
forceMount: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuIndicator
|
||||||
|
data-slot="navigation-menu-indicator"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md"
|
||||||
|
/>
|
||||||
|
</NavigationMenuIndicator>
|
||||||
|
</template>
|
||||||
24
ui/src/components/ui/navigation-menu/NavigationMenuItem.vue
Normal file
24
ui/src/components/ui/navigation-menu/NavigationMenuItem.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuItem } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
value: { type: String, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuItem
|
||||||
|
data-slot="navigation-menu-item"
|
||||||
|
v-bind="delegatedProps"
|
||||||
|
:class="cn('relative', props.class)"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuItem>
|
||||||
|
</template>
|
||||||
31
ui/src/components/ui/navigation-menu/NavigationMenuLink.vue
Normal file
31
ui/src/components/ui/navigation-menu/NavigationMenuLink.vue
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuLink, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
active: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["select"]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuLink
|
||||||
|
data-slot="navigation-menu-link"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'data-active:focus:bg-accent data-active:hover:bg-accent data-active:bg-accent/50 data-active:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 [&_svg:not([class*=\'text-\'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*=\'size-\'])]:size-4',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</template>
|
||||||
30
ui/src/components/ui/navigation-menu/NavigationMenuList.vue
Normal file
30
ui/src/components/ui/navigation-menu/NavigationMenuList.vue
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuList, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuList
|
||||||
|
data-slot="navigation-menu-list"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'group flex flex-1 list-none items-center justify-center gap-1',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuList>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { ChevronDown } from "lucide-vue-next";
|
||||||
|
import { NavigationMenuTrigger, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { navigationMenuTriggerStyle } from ".";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
disabled: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuTrigger
|
||||||
|
data-slot="navigation-menu-trigger"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="cn(navigationMenuTriggerStyle(), 'group', props.class)"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
<ChevronDown
|
||||||
|
class="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</NavigationMenuTrigger>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuViewport, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
forceMount: { type: Boolean, required: false },
|
||||||
|
align: { type: String, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="absolute top-full left-0 isolate z-50 flex justify-center">
|
||||||
|
<NavigationMenuViewport
|
||||||
|
data-slot="navigation-menu-viewport"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--reka-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--reka-navigation-menu-viewport-width)] left-[var(--reka-navigation-menu-viewport-left)]',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
14
ui/src/components/ui/navigation-menu/index.js
Normal file
14
ui/src/components/ui/navigation-menu/index.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { cva } from "class-variance-authority";
|
||||||
|
|
||||||
|
export { default as NavigationMenu } from "./NavigationMenu.vue";
|
||||||
|
export { default as NavigationMenuContent } from "./NavigationMenuContent.vue";
|
||||||
|
export { default as NavigationMenuIndicator } from "./NavigationMenuIndicator.vue";
|
||||||
|
export { default as NavigationMenuItem } from "./NavigationMenuItem.vue";
|
||||||
|
export { default as NavigationMenuLink } from "./NavigationMenuLink.vue";
|
||||||
|
export { default as NavigationMenuList } from "./NavigationMenuList.vue";
|
||||||
|
export { default as NavigationMenuTrigger } from "./NavigationMenuTrigger.vue";
|
||||||
|
export { default as NavigationMenuViewport } from "./NavigationMenuViewport.vue";
|
||||||
|
|
||||||
|
export const navigationMenuTriggerStyle = cva(
|
||||||
|
"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1",
|
||||||
|
);
|
||||||
36
ui/src/composables/useAuth.ts
Normal file
36
ui/src/composables/useAuth.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { useUserStore } from "@/stores/user"
|
||||||
|
import { computed } from "vue";
|
||||||
|
import { Role } from "@shared/types/roles"
|
||||||
|
|
||||||
|
export function useAuth() {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// Account status control
|
||||||
|
const accountStatus = computed(() => userStore.state);
|
||||||
|
|
||||||
|
// RBAC
|
||||||
|
const roles = computed<string[]>(() => {
|
||||||
|
return userStore.user?.roleData?.map((r: Role) => r.name) ?? [];
|
||||||
|
});
|
||||||
|
|
||||||
|
function isDev() {
|
||||||
|
return roles.value.includes('Dev');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasRole(roleName: string): boolean {
|
||||||
|
if (isDev()) return true;
|
||||||
|
return roles.value.includes(roleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasAnyRole(roleNames: string[]): boolean {
|
||||||
|
if (isDev()) return true;
|
||||||
|
return roles.value.some(name => roleNames.includes(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasAllRoles(roleNames: string[]): boolean {
|
||||||
|
if (isDev()) return true;
|
||||||
|
return roles.value.every(name => roleNames.includes(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
return { hasRole, hasAnyRole, hasAllRoles, accountStatus }
|
||||||
|
}
|
||||||
@@ -13,8 +13,8 @@ function goToApplication() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="user.state == 'guest'"
|
<div>
|
||||||
class="min-h-screen flex flex-col items-center justify-center text-center bg-neutral-950 text-white px-4">
|
<div v-if="user.state == 'guest'" class="flex flex-col items-center justify-center">
|
||||||
<h1 class="text-4xl font-bold mb-4">Welcome to the 17th</h1>
|
<h1 class="text-4xl font-bold mb-4">Welcome to the 17th</h1>
|
||||||
<p class="text-neutral-400 mb-8 max-w-md">
|
<p class="text-neutral-400 mb-8 max-w-md">
|
||||||
To join our unit, please fill out an application to continue.
|
To join our unit, please fill out an application to continue.
|
||||||
@@ -26,4 +26,5 @@ function goToApplication() {
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
HOMEPAGEEEEEEEEEEEEEEEEEEE
|
HOMEPAGEEEEEEEEEEEEEEEEEEE
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto max-w-5xl">
|
<div class="mx-auto w-full max-w-5xl">
|
||||||
<h1 class="my-4">Manage Applications</h1>
|
<h1 class="my-4">Manage Applications</h1>
|
||||||
<Table>
|
<Table>
|
||||||
<!-- <TableCaption>A list of your recent invoices.</TableCaption> -->
|
<!-- <TableCaption>A list of your recent invoices.</TableCaption> -->
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ onMounted(async () => {
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
<div class="max-w-5xl mx-auto">
|
<div class="max-w-5xl w-full mx-auto">
|
||||||
Active
|
Active
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ onMounted(async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="px-20 mx-auto max-w-[100rem] flex mt-5">
|
<div class="px-20 mx-auto max-w-[100rem] w-full flex mt-5">
|
||||||
<!-- training report list -->
|
<!-- training report list -->
|
||||||
<div class="px-4 my-3" :class="sidePanel == sidePanelState.closed ? 'w-full' : 'w-2/5'">
|
<div class="px-4 my-3" :class="sidePanel == sidePanelState.closed ? 'w-full' : 'w-2/5'">
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
|
|||||||
@@ -63,15 +63,15 @@ router.beforeEach(async (to) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // Must be a member
|
// Must be a member
|
||||||
// if (to.meta.memberOnly && user.state !== 'member') {
|
if (to.meta.memberOnly && user.state !== 'member') {
|
||||||
// return '/unauthorized'
|
return '/unauthorized'
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // Must have specific role
|
// Must have specific role
|
||||||
// if (to.meta.roles && !user.hasRole('Dev') && !user.hasAnyRole(to.meta.roles)) {
|
if (to.meta.roles && !user.hasRole('Dev') && !user.hasAnyRole(to.meta.roles)) {
|
||||||
// return '/unauthorized'
|
return '/unauthorized'
|
||||||
// }
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
@@ -5,7 +5,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
const user = ref(null)
|
const user = ref(null)
|
||||||
const roles = computed(() => new Set(user.value?.roleData?.map(r => r.name) ?? []));
|
const roles = computed(() => new Set(user.value?.roleData?.map(r => r.name) ?? []));
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
const state = computed(() => user.value.state);
|
const state = computed<string | undefined>(() => user.value?.state || undefined);
|
||||||
const isLoggedIn = computed(() => user.value !== null)
|
const isLoggedIn = computed(() => user.value !== null)
|
||||||
|
|
||||||
async function loadUser() {
|
async function loadUser() {
|
||||||
@@ -16,6 +16,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
console.log(data);
|
||||||
user.value = data;
|
user.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user