Skip to content

Commit

Permalink
feat(RSS-ECOMM-3_19): implement routing for all pages (#215)
Browse files Browse the repository at this point in the history
feat: implement routing for all pages
  • Loading branch information
stardustmeg authored May 10, 2024
1 parent 61fb5a8 commit 44a36fd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/App/model/AppModel.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -22,10 +23,26 @@ class AppModel {

private createRoutes(): Promise<Map<string, () => Promise<Page>>> {
const routesMap = {
[PAGE_ID.ABOUT_US_PAGE]: async (): Promise<Page> => {
const { default: AbooutUsPageModel } = await import('@/pages/AboutUsPage/model/AboutUsPageModel.ts');
return new AbooutUsPageModel(this.appView.getHTML());
},
[PAGE_ID.CART_PAGE]: async (): Promise<Page> => {
const { default: CartPageModel } = await import('@/pages/CartPage/model/CartPageModel.ts');
return new CartPageModel(this.appView.getHTML());
},
[PAGE_ID.CATALOG_PAGE]: async (): Promise<Page> => {
const { default: CatalogPageModel } = await import('@/pages/CatalogPage/model/CatalogPageModel.ts');
return new CatalogPageModel(this.appView.getHTML());
},
[PAGE_ID.DEFAULT_PAGE]: async (): Promise<Page> => {
const { default: MainPageModel } = await import('@/pages/MainPage/model/MainPageModel.ts');
return new MainPageModel(this.appView.getHTML());
},
[PAGE_ID.ITEM_PAGE]: async (): Promise<Page> => {
const { default: ItemPageModel } = await import('@/pages/ItemPage/model/ItemPageModel.ts');
return new ItemPageModel(this.appView.getHTML());
},
[PAGE_ID.LOGIN_PAGE]: async (): Promise<Page> => {
const { default: LoginPageModel } = await import('@/pages/LoginPage/model/LoginPageModel.ts');
return new LoginPageModel(this.appView.getHTML(), this.router);
Expand All @@ -44,6 +61,10 @@ class AppModel {
);
return new RegistrationPageModel(this.appView.getHTML(), this.router);
},
[PAGE_ID.USER_PROFILE_PAGE]: async (): Promise<Page> => {
const { default: UserProfilePageModel } = await import('@/pages/UserProfilePage/model/UserProfilePageModel.ts');
return new UserProfilePageModel(this.appView.getHTML());
},
};

const routes = new Map<string, () => Promise<Page>>();
Expand Down

0 comments on commit 44a36fd

Please sign in to comment.