From 7e723cd0d46b5ed434bef83e87500df1820518b8 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 31 Jan 2023 17:53:02 +0300 Subject: [PATCH] refac: move router to pages --- src/infra/api/contact.ts | 2 +- src/main.ts | 2 +- .../{ => audience}/AudienceContactsPage.vue | 0 .../AudienceCreateContactPage.vue | 0 .../{ => audience}/AudienceCreateListPage.vue | 0 .../{ => audience}/AudienceListsPage.vue | 0 src/pages/{ => audience}/AudiencePage.vue | 0 src/pages/audience/router.ts | 32 +++++++++++ src/pages/router.ts | 29 ++++++++++ src/router.ts | 55 ------------------- 10 files changed, 63 insertions(+), 57 deletions(-) rename src/pages/{ => audience}/AudienceContactsPage.vue (100%) rename src/pages/{ => audience}/AudienceCreateContactPage.vue (100%) rename src/pages/{ => audience}/AudienceCreateListPage.vue (100%) rename src/pages/{ => audience}/AudienceListsPage.vue (100%) rename src/pages/{ => audience}/AudiencePage.vue (100%) create mode 100644 src/pages/audience/router.ts create mode 100644 src/pages/router.ts delete mode 100644 src/router.ts diff --git a/src/infra/api/contact.ts b/src/infra/api/contact.ts index 1740cde..e7f204e 100644 --- a/src/infra/api/contact.ts +++ b/src/infra/api/contact.ts @@ -3,8 +3,8 @@ import type { ContactFormApiCreateProps, ContactsTableApiFetchManyProps, } from "@/app/contacts"; -import type { EntityId } from "@/domain/common/entity"; import type { Contact } from "@/domain/entities/contact"; +import type { EntityId } from "@/shared/lib/entity"; import { delay } from "@/shared/lib/utils/promise"; import { faker } from "@faker-js/faker"; diff --git a/src/main.ts b/src/main.ts index 30a55ec..90c3dfc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import { createApp } from "vue"; import { createPinia } from "pinia"; import App from "./App.vue"; -import router from "./router"; +import router from "./pages/router"; import "./assets/main.css"; import { diff --git a/src/pages/AudienceContactsPage.vue b/src/pages/audience/AudienceContactsPage.vue similarity index 100% rename from src/pages/AudienceContactsPage.vue rename to src/pages/audience/AudienceContactsPage.vue diff --git a/src/pages/AudienceCreateContactPage.vue b/src/pages/audience/AudienceCreateContactPage.vue similarity index 100% rename from src/pages/AudienceCreateContactPage.vue rename to src/pages/audience/AudienceCreateContactPage.vue diff --git a/src/pages/AudienceCreateListPage.vue b/src/pages/audience/AudienceCreateListPage.vue similarity index 100% rename from src/pages/AudienceCreateListPage.vue rename to src/pages/audience/AudienceCreateListPage.vue diff --git a/src/pages/AudienceListsPage.vue b/src/pages/audience/AudienceListsPage.vue similarity index 100% rename from src/pages/AudienceListsPage.vue rename to src/pages/audience/AudienceListsPage.vue diff --git a/src/pages/AudiencePage.vue b/src/pages/audience/AudiencePage.vue similarity index 100% rename from src/pages/AudiencePage.vue rename to src/pages/audience/AudiencePage.vue diff --git a/src/pages/audience/router.ts b/src/pages/audience/router.ts new file mode 100644 index 0000000..5dad145 --- /dev/null +++ b/src/pages/audience/router.ts @@ -0,0 +1,32 @@ +const audienceRoutes = [ + { + path: "/audience", + name: "audience", + redirect: { name: "audience_contacts" }, + component: () => import("./AudiencePage.vue"), + children: [ + { + path: "contacts/new", + name: "audience_create_contact", + component: () => import("./AudienceCreateContactPage.vue"), + }, + { + path: "contacts/:listId?", + name: "audience_contacts", + component: () => import("./AudienceContactsPage.vue"), + }, + { + path: "lists/new", + name: "audience_create_list", + component: () => import("./AudienceCreateListPage.vue"), + }, + { + path: "lists", + name: "audience_lists", + component: () => import("./AudienceListsPage.vue"), + }, + ], + }, +]; + +export default audienceRoutes; diff --git a/src/pages/router.ts b/src/pages/router.ts new file mode 100644 index 0000000..64a8c60 --- /dev/null +++ b/src/pages/router.ts @@ -0,0 +1,29 @@ +import { createRouter, createWebHistory } from "vue-router"; +import audienceRoutes from "./audience/router"; + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes: [ + { + path: "/", + name: "dashboard", + redirect: { name: "audience" }, + }, + ...audienceRoutes, + { + path: "/files", + name: "email_files", + component: () => import("./FilesPage.vue"), + }, + { + path: "/:pathMatch(.*)*", + name: "not_found", + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import("./NotFoundPage.vue"), + }, + ], +}); + +export default router; diff --git a/src/router.ts b/src/router.ts deleted file mode 100644 index 112d724..0000000 --- a/src/router.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { createRouter, createWebHistory } from "vue-router"; - -const router = createRouter({ - history: createWebHistory(import.meta.env.BASE_URL), - routes: [ - { - path: "/", - name: "dashboard", - redirect: { name: "audience" }, - }, - { - path: "/audience", - name: "audience", - redirect: { name: "audience_contacts" }, - component: () => import("./pages/AudiencePage.vue"), - children: [ - { - path: "contacts/new", - name: "audience_create_contact", - component: () => import("./pages/AudienceCreateContactPage.vue"), - }, - { - path: "contacts/:listId?", - name: "audience_contacts", - component: () => import("./pages/AudienceContactsPage.vue"), - }, - { - path: "lists/new", - name: "audience_create_list", - component: () => import("./pages/AudienceCreateListPage.vue"), - }, - { - path: "lists", - name: "audience_lists", - component: () => import("./pages/AudienceListsPage.vue"), - }, - ], - }, - { - path: "/files", - name: "email_files", - component: () => import("./pages/FilesPage.vue"), - }, - { - path: "/:pathMatch(.*)*", - name: "not_found", - // route level code-splitting - // this generates a separate chunk (About.[hash].js) for this route - // which is lazy-loaded when the route is visited. - component: () => import("./pages/NotFoundPage.vue"), - }, - ], -}); - -export default router;