-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.js
99 lines (95 loc) · 2.49 KB
/
router.js
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
import { createRouter, createWebHistory } from "vue-router";
import Home from "./pages/home.js";
import { useStore } from "vuex";
import {
getAuth,
signOut,
onAuthStateChanged,
} from "https://www.gstatic.com/firebasejs/9.22.1/firebase-auth.js";
const auth = getAuth();
const isAuthCheck = () => auth.currentUser;
const router = createRouter({
history: createWebHistory(),
routes: [
// Twoje trasy
{ path: "/", component: Home, name: "home" },
{
path: "/katalog",
component: () => import("./pages/katalog.js"),
name: "katalog",
},
{
path: "/cennik",
component: () => import("./pages/cennik.js"),
name: "cennik",
},
{
path: "/tablica",
component: () => import("./pages/tablica.js"),
name: "tablica",
children: [
{
// Stock will be rendered inside User's <router-view>
// when /tablica/stock is matched
path: "sample",
name: "sample",
component: () => import(""),
},
],
},
{
// Stock will be rendered inside User's <router-view>
// when /tablica/stock is matched
path: "/komercja",
name: "komercja",
component: () => import("./pages/stock.js"),
beforeEnter: async (to, from, next) => {
const isAuth = await isAuthCheck();
if (!isAuth) next({ name: "logowanie" });
else next();
},
},
{
// Stock will be rendered inside User's <router-view>
// when /tablica/stock is matched
path: "/proby",
name: "proby",
component: () => import("./pages/sample.js"),
beforeEnter: async (to, from, next) => {
const isAuth = isAuthCheck();
if (!isAuth) next({ name: "logowanie" });
else next();
},
},
{
path: "/katalog/:family",
component: () => import("./pages/family.js"),
name: "family",
props: true,
},
{
path: "/katalog/odmiana/:name",
component: () => import("./pages/crop.js"),
name: "crop",
props: true,
},
{
path: "/update",
component: () => import("./pages/update.js"),
name: "update",
props: false,
beforeEnter: async (to, from, next) => {
const isAuth = isAuthCheck();
if (!isAuth) next({ name: "logowanie" });
else next();
},
},
{
path: "/logowanie",
component: () => import("./pages/login.js"),
name: "logowanie",
props: false,
},
],
});
export default router;