Skip to content

Commit

Permalink
chore: Kepala only has access list contracts/reports
Browse files Browse the repository at this point in the history
  • Loading branch information
newarifrh committed Jun 28, 2024
1 parent 14e2641 commit 86ff110
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/components/sidebar/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<el-icon><DocumentCopy /></el-icon>BAST
</template>
<el-menu-item index="/bast">Daftar BAST</el-menu-item>
<el-menu-item index="/bast/buat">Buat BAST</el-menu-item>
<el-menu-item v-if="!['KEPALA'].includes(user.position)" index="/bast/buat">Buat BAST</el-menu-item>
</el-sub-menu>
<el-sub-menu index="3" v-if="['TU'].includes(user.team)">
<template #title>
Expand Down
63 changes: 37 additions & 26 deletions src/router/reportRoute.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
import ListReportView from '@/views/report/ListReportView.vue';
import CreateReportView from '@/views/report/CreateReportView.vue';
import ListReportView from "@/views/report/ListReportView.vue";
import CreateReportView from "@/views/report/CreateReportView.vue";
import type { NavigationGuardNext, RouteLocationNormalized } from "vue-router";
import { useUserStore } from "@/stores/user";

const reportRoutes = [
{
path: '/bast',
{
path: "/bast",
meta: {
layout: "LayoutDashboard",
requiresAuth: true,
},
children: [
{
path: "",
name: "listReport",
component: ListReportView,
meta: {
layout: 'LayoutDashboard',
requiresAuth: true
title: "Daftar BAST",
},
children: [
{
path: '',
name: 'listReport',
component: ListReportView,
meta: {
title: "Daftar BAST"
}
},
{
path: 'buat',
name: 'createReport',
component: CreateReportView,
meta: {
title: "Buat BAST"
}
}
]
}
},
{
path: "buat",
name: "createReport",
component: CreateReportView,
meta: {
title: "Buat BAST",
},
beforeEnter: (
to: RouteLocationNormalized,
from: RouteLocationNormalized,
next: NavigationGuardNext
) => {
const user = useUserStore();
if (["KEPALA"].includes(user.position)) next({ name: "unauthorized" });
else next();
},
},
],
},
];

export default reportRoutes;
export default reportRoutes;

0 comments on commit 86ff110

Please sign in to comment.