-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
112 lines (105 loc) · 2.75 KB
/
index.ts
File metadata and controls
112 lines (105 loc) · 2.75 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { useCommonStore } from '@/stores';
import { isPositiveInteger, SessionManager } from '@/utils/utils';
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import { callTrackPageView } from '@/utils/snowplowUtils';
async function authGuard(to: any, from: any, next: any) {
const commonStore = useCommonStore();
const results = await SessionManager.getSettings();
if (
!isPositiveInteger(commonStore?.userInfo?.roles?.length) ||
commonStore?.userInfo?.isActive === false ||
!commonStore?.userInfo?.judgeId
) {
if (to.name === 'RequestAccess') {
next();
} else {
next({ path: '/request-access' });
}
} else if (results) {
if (
isPositiveInteger(commonStore?.userInfo?.roles?.length) &&
commonStore?.userInfo?.isActive === true &&
commonStore?.userInfo?.judgeId &&
to.name === 'RequestAccess'
) {
next({ path: '/' });
} else {
next();
}
}
}
const routes: RouteRecordRaw[] = [
{
path: '/',
redirect: '/dashboard',
name: 'HomeView',
},
{
path: '/court-list',
name: 'CourtList',
component: () => import('@/components/courtlist/CourtList.vue'),
props: true,
children: [
{
path: 'location/:location/room/:room/date/:date',
name: 'CourtListResult',
component: () => import('@/components/courtlist/CourtList.vue'),
props: true,
},
],
},
{
path: '/civil-file/:fileNumber/:section?',
name: 'CivilCaseDetails',
component: () => import('@/components/civil/CivilCaseDetails.vue'),
props: true,
},
{
path: '/criminal-file/:fileNumber',
name: 'CriminalCaseDetails',
component: () => import('@/components/criminal/CriminalCaseDetails.vue'),
props: true,
},
{
path: '/dashboard',
name: 'DashboardView',
component: () => import('@/components/dashboard/Dashboard.vue'),
props: true,
},
{
path: '/court-file-search',
name: 'CourtFileSearchView',
component: () =>
import('@/components/courtfilesearch/CourtFileSearchView.vue'),
},
{
path: '/file-viewer',
name: 'NutrientContainer',
component: () => import('@/components/documents/NutrientContainer.vue'),
},
{
path: '/request-access',
name: 'RequestAccess',
component: () => import('@/components/dashboard/RequestAccess.vue'),
},
{
path: '/orders',
name: 'Orders',
component: () => import('@/components/orders/Orders.vue'),
},
];
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
});
router.beforeEach((to, from, next) => {
if (to.path === '/') {
next();
} else {
authGuard(to, from, next);
}
});
router.afterEach(() => {
callTrackPageView();
});
export default router;