| 1 |
import type { RouteRecordRaw } from 'vue-router' |
| 2 |
import { createWebHashHistory, createRouter } from 'vue-router' |
| 3 |
import DashboardPage from '../views/admin/dashboard/dashboard-page/DashboardPage.vue' |
| 4 |
import FormsPage from '../views/admin/forms/forms-page/FormsPage.vue' |
| 5 |
import FormBuilderPage from '../views/admin/form-builder/form-builder-page/FormBuilderPage.vue' |
| 6 |
import FormBuilderSettingsPage from '../views/admin/form-builder/form-builder-page/FormBuilderSettingsPage.vue' |
| 7 |
import FormBuilderManageNotification from '../views/admin/form-builder/form-builder-page/form-settings-notification/FormBuilderManageNotification.vue' |
| 8 |
import FormBuilderSettings from '../views/admin/form-builder/form-builder-page/form-settings/FormBuilderSettings.vue' |
| 9 |
import FormBuilderNotificationTable from '../views/admin/form-builder/form-builder-page/form-settings-notification/FormBuilderNotificationTable.vue' |
| 10 |
import FormBuilderConfirmation from '../views/admin/form-builder/form-builder-page/form-settings-confirmations/FormBuilderConfirmation.vue' |
| 11 |
import { IVYFORMS_FORM_BUILDER_PAGE } from '@/constants/pages.ts' |
| 12 |
import { IVYFORMS_ALLFORMS_PAGE } from '@/constants/pages.ts' |
| 13 |
import { IVYFORMS_DASHBOARD_PAGE } from '@/constants/pages.ts' |
| 14 |
|
| 15 |
const currentPage = new URLSearchParams(window.location.search).get('page') |
| 16 |
|
| 17 |
let routes: RouteRecordRaw[] = [] |
| 18 |
|
| 19 |
if (currentPage === IVYFORMS_DASHBOARD_PAGE) { |
| 20 |
routes = [ |
| 21 |
{ |
| 22 |
path: '/', |
| 23 |
name: 'Dashboard', |
| 24 |
component: DashboardPage, |
| 25 |
}, |
| 26 |
] |
| 27 |
} |
| 28 |
|
| 29 |
if (currentPage === IVYFORMS_ALLFORMS_PAGE) { |
| 30 |
routes = [ |
| 31 |
{ |
| 32 |
path: '/', |
| 33 |
name: 'AllForms', |
| 34 |
component: FormsPage, |
| 35 |
}, |
| 36 |
] |
| 37 |
} |
| 38 |
|
| 39 |
if (currentPage === IVYFORMS_FORM_BUILDER_PAGE) { |
| 40 |
routes = [ |
| 41 |
{ |
| 42 |
path: '/', |
| 43 |
name: 'AddForm', |
| 44 |
component: FormBuilderPage, |
| 45 |
children: [ |
| 46 |
{ |
| 47 |
path: '/manage/:id(\\d+)', |
| 48 |
name: 'EditForm', |
| 49 |
component: FormBuilderPage, |
| 50 |
}, |
| 51 |
], |
| 52 |
}, |
| 53 |
|
| 54 |
{ |
| 55 |
path: '/settings', |
| 56 |
name: 'Settings', |
| 57 |
component: FormBuilderSettingsPage, |
| 58 |
children: [ |
| 59 |
{ |
| 60 |
path: 'general', |
| 61 |
name: 'FormSettings', |
| 62 |
component: FormBuilderSettings, |
| 63 |
}, |
| 64 |
{ |
| 65 |
path: 'general/manage/:id(\\d+)', |
| 66 |
name: 'FormSetting', |
| 67 |
component: FormBuilderSettings, |
| 68 |
}, |
| 69 |
{ |
| 70 |
path: 'notification/:id(\\d+)', |
| 71 |
name: 'FormNotifications', |
| 72 |
component: FormBuilderNotificationTable, |
| 73 |
}, |
| 74 |
{ |
| 75 |
path: 'notification/manage', |
| 76 |
name: 'NewNotifications', |
| 77 |
component: FormBuilderManageNotification, |
| 78 |
}, |
| 79 |
{ |
| 80 |
path: 'notification/manage/:id(\\d+)?', |
| 81 |
name: 'EditNotifications', |
| 82 |
component: FormBuilderManageNotification, |
| 83 |
}, |
| 84 |
{ |
| 85 |
path: 'confirmation/manage/:id(\\d+)', |
| 86 |
name: 'FormConfirmation', |
| 87 |
component: FormBuilderConfirmation, |
| 88 |
}, |
| 89 |
], |
| 90 |
}, |
| 91 |
] |
| 92 |
} |
| 93 |
|
| 94 |
// if (currentPage === 'ivyforms-settings') { |
| 95 |
// routes = [{ path: '/', name: 'Settings', component: SettingsPage }] |
| 96 |
// } |
| 97 |
// |
| 98 |
// if (currentPage === 'ivyforms-testing') { |
| 99 |
// routes = [{ path: '/', name: 'Testing', component: TestingPage }] |
| 100 |
// } |
| 101 |
|
| 102 |
const router = createRouter({ |
| 103 |
history: createWebHashHistory(), |
| 104 |
routes, |
| 105 |
}) |
| 106 |
export default router |
| 107 |
|