From b50576f3059cd1f4f4f3334b5038af3e14601feb Mon Sep 17 00:00:00 2001 From: Margarita Golubeva Date: Fri, 10 May 2024 04:18:18 +0300 Subject: [PATCH] feat: implement routing for all pages --- src/app/App/model/AppModel.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/app/App/model/AppModel.ts b/src/app/App/model/AppModel.ts index 628ff41c..08ec96f8 100644 --- a/src/app/App/model/AppModel.ts +++ b/src/app/App/model/AppModel.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines-per-function */ import type { Page } from '@/shared/types/common.ts'; import RouterModel from '@/app/Router/model/RouterModel.ts'; @@ -22,10 +23,26 @@ class AppModel { private createRoutes(): Promise Promise>> { const routesMap = { + [PAGE_ID.ABOUT_US_PAGE]: async (): Promise => { + const { default: AbooutUsPageModel } = await import('@/pages/AboutUsPage/model/AboutUsPageModel.ts'); + return new AbooutUsPageModel(this.appView.getHTML()); + }, + [PAGE_ID.CART_PAGE]: async (): Promise => { + const { default: CartPageModel } = await import('@/pages/CartPage/model/CartPageModel.ts'); + return new CartPageModel(this.appView.getHTML()); + }, + [PAGE_ID.CATALOG_PAGE]: async (): Promise => { + const { default: CatalogPageModel } = await import('@/pages/CatalogPage/model/CatalogPageModel.ts'); + return new CatalogPageModel(this.appView.getHTML()); + }, [PAGE_ID.DEFAULT_PAGE]: async (): Promise => { const { default: MainPageModel } = await import('@/pages/MainPage/model/MainPageModel.ts'); return new MainPageModel(this.appView.getHTML()); }, + [PAGE_ID.ITEM_PAGE]: async (): Promise => { + const { default: ItemPageModel } = await import('@/pages/ItemPage/model/ItemPageModel.ts'); + return new ItemPageModel(this.appView.getHTML()); + }, [PAGE_ID.LOGIN_PAGE]: async (): Promise => { const { default: LoginPageModel } = await import('@/pages/LoginPage/model/LoginPageModel.ts'); return new LoginPageModel(this.appView.getHTML(), this.router); @@ -44,6 +61,10 @@ class AppModel { ); return new RegistrationPageModel(this.appView.getHTML(), this.router); }, + [PAGE_ID.USER_PROFILE_PAGE]: async (): Promise => { + const { default: UserProfilePageModel } = await import('@/pages/UserProfilePage/model/UserProfilePageModel.ts'); + return new UserProfilePageModel(this.appView.getHTML()); + }, }; const routes = new Map Promise>();