profileShare

rasmusjy / splitapp-frontend-vue

Read-only snapshot

No repository description.

main default branch 96 files Expires Sep 13, 2026, 9:06 AM
index.ts 3,881 bytes
1 import { createRouter, createWebHistory } from 'vue-router'
2 import { useAuthStore } from '@/stores/auth'
3 import HomeView from '@/views/HomeView.vue'
4
5 const router = createRouter({
6 history: createWebHistory(import.meta.env.BASE_URL),
7 routes: [
8 {
9 path: '/',
10 name: 'Home',
11 component: HomeView,
12 },
13 {
14 path: '/login',
15 name: 'Login',
16 component: () => import('@/views/LoginView.vue'),
17 },
18 {
19 path: '/register',
20 name: 'Register',
21 component: () => import('@/views/RegisterView.vue'),
22 },
23 {
24 path: '/trips',
25 name: 'TripsIndex',
26 component: () => import('@/views/trips/IndexView.vue'),
27 meta: { requiresAuth: true },
28 },
29 {
30 path: '/trips/create',
31 name: 'TripsCreate',
32 component: () => import('@/views/trips/CreateView.vue'),
33 meta: { requiresAuth: true },
34 },
35 {
36 path: '/trips/:tripId',
37 component: () => import('@/views/trips/DetailView.vue'),
38 meta: { requiresAuth: true },
39 children: [
40 {
41 path: '',
42 name: 'TripDetail',
43 component: () => import('@/views/expenses/IndexView.vue'),
44 },
45 {
46 path: 'edit',
47 name: 'TripsEdit',
48 component: () => import('@/views/trips/EditView.vue'),
49 },
50 {
51 path: 'expenses',
52 name: 'ExpensesIndex',
53 component: () => import('@/views/expenses/IndexView.vue'),
54 },
55 {
56 path: 'expenses/create',
57 name: 'ExpensesCreate',
58 component: () => import('@/views/expenses/CreateView.vue'),
59 },
60 {
61 path: 'expenses/:id/edit',
62 name: 'ExpensesEdit',
63 component: () => import('@/views/expenses/EditView.vue'),
64 },
65 {
66 path: 'budget',
67 name: 'BudgetIndex',
68 component: () => import('@/views/budget-categories/IndexView.vue'),
69 },
70 {
71 path: 'budget/create',
72 name: 'BudgetCreate',
73 component: () => import('@/views/budget-categories/CreateView.vue'),
74 },
75 {
76 path: 'budget/:id/edit',
77 name: 'BudgetEdit',
78 component: () => import('@/views/budget-categories/EditView.vue'),
79 },
80 {
81 path: 'wishlist',
82 name: 'WishlistIndex',
83 component: () => import('@/views/wishlist/IndexView.vue'),
84 },
85 {
86 path: 'wishlist/create',
87 name: 'WishlistCreate',
88 component: () => import('@/views/wishlist/CreateView.vue'),
89 },
90 {
91 path: 'wishlist/:id/edit',
92 name: 'WishlistEdit',
93 component: () => import('@/views/wishlist/EditView.vue'),
94 },
95 {
96 path: 'polls',
97 name: 'PollsIndex',
98 component: () => import('@/views/polls/IndexView.vue'),
99 },
100 {
101 path: 'polls/create',
102 name: 'PollsCreate',
103 component: () => import('@/views/polls/CreateView.vue'),
104 },
105 {
106 path: 'polls/:id',
107 name: 'PollDetail',
108 component: () => import('@/views/polls/DetailView.vue'),
109 },
110 {
111 path: 'members',
112 name: 'MembersView',
113 component: () => import('@/views/members/MembersView.vue'),
114 },
115 {
116 path: 'settlement',
117 name: 'SettlementView',
118 component: () => import('@/views/settlements/SettlementView.vue'),
119 },
120 ],
121 },
122 {
123 path: '/invitations/:token',
124 name: 'AcceptInvitation',
125 component: () => import('@/views/invitations/AcceptView.vue'),
126 meta: { requiresAuth: true },
127 },
128 ],
129 })
130
131 router.beforeEach((to) => {
132 const authStore = useAuthStore()
133 if (to.meta.requiresAuth && !authStore.isAuthenticated) {
134 return { name: 'Login' }
135 }
136 })
137
138 export default router
139