added child routes and dynamic routes

This commit is contained in:
Fran Jurmanović
2021-06-03 09:03:39 +02:00
parent 47218c9b83
commit 671e98ea13
2 changed files with 146 additions and 15 deletions

View File

@@ -42,17 +42,28 @@ class AppMainElement extends BaseComponentElement {
layout: "menu-layout",
middleware: this.isAuth,
},
{
path: "/wallet",
component: "history-page",
layout: "menu-layout",
middleware: this.isAuth,
children: [
{
path: "/:walletId",
component: "history-page",
layout: "menu-layout",
},
],
},
{
path: "/register",
component: "register-page",
layout: "menu-layout",
middleware: this.isAuth,
},
{
path: "/login",
component: "login-page",
layout: "menu-layout",
middleware: this.isAuth,
},
{
path: "/unauthorized",
@@ -64,6 +75,11 @@ class AppMainElement extends BaseComponentElement {
component: "login-page",
layout: "menu-layout",
},
{
path: "/not-found",
component: "not-found",
layout: "menu-layout",
},
{
path: "/logout",
component: "logout-page",
@@ -81,6 +97,7 @@ class AppMainElement extends BaseComponentElement {
createModal = (element: string) => {
this.closeModal();
this.appMain.addEventListener("routechanged", this.closeModal);
const _appModal = this.createAppModal();
const _modalContent = this.createModalContent(element);
@@ -131,6 +148,7 @@ class AppMainElement extends BaseComponentElement {
closeModal = () => {
if (this.appModal) this.removeChild(this.appModal);
this.appMain.removeEventListener("routechanged", this.closeModal);
};
isAuth = (): boolean => {