| 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 SettingsPage from '../views/admin/settings/settings-page/SettingsPage.vue' |
| 5 |
import GeneralSettingsPage from '../views/admin/settings/settings-page/section/general-settings/GeneralSettingsPage.vue' |
| 6 |
import SecuritySettingsPage from '../views/admin/settings/settings-page/section/security-settings/SecuritySettingsPage.vue' |
| 7 |
import FormsPage from '../views/admin/forms/forms-page/FormsPage.vue' |
| 8 |
import FormBuilderPage from '../views/admin/form-builder/form-builder-page/FormBuilderPage.vue' |
| 9 |
import FormBuilderSettingsPage from '../views/admin/form-builder/form-builder-page/FormBuilderSettingsPage.vue' |
| 10 |
import FormBuilderManageNotification from '../views/admin/form-builder/form-builder-page/form-settings-notification/FormBuilderManageNotification.vue' |
| 11 |
import FormBuilderSettings from '../views/admin/form-builder/form-builder-page/form-settings/FormBuilderSettings.vue' |
| 12 |
import FormBuilderNotificationTable from '../views/admin/form-builder/form-builder-page/form-settings-notification/FormBuilderNotificationTable.vue' |
| 13 |
import FormBuilderConfirmation from '../views/admin/form-builder/form-builder-page/form-settings-confirmations/FormBuilderConfirmation.vue' |
| 14 |
import EntriesPage from '@/views/admin/entries/entries-page/EntriesPage.vue' |
| 15 |
import EntryPage from '@/views/admin/entries/entry-page/EntryPage.vue' |
| 16 |
import FormBuilderResultsEntries from '@/views/admin/form-builder/form-builder-page/form-results/FormBuilderResultsEntries.vue' |
| 17 |
import FormBuilderResultsPage from '@/views/admin/form-builder/form-builder-page/FormBuilderResultsPage.vue' |
| 18 |
import { |
| 19 |
IVYFORMS_FORM_BUILDER_PAGE, |
| 20 |
IVYFORMS_ALLFORMS_PAGE, |
| 21 |
IVYFORMS_DASHBOARD_PAGE, |
| 22 |
IVYFORMS_SETTINGS, |
| 23 |
IVYFORMS_DASHBOARD, |
| 24 |
IVYFORMS_ALL_FORMS, |
| 25 |
IVYFORMS_ADD_FORM, |
| 26 |
IVYFORMS_EDIT_FORM, |
| 27 |
IVYFORMS_FORM_SETTING, |
| 28 |
IVYFORMS_FORM_NOTIFICATIONS, |
| 29 |
IVYFORMS_NEW_NOTIFICATIONS, |
| 30 |
IVYFORMS_EDIT_NOTIFICATIONS, |
| 31 |
IVYFORMS_FORM_CONFIRMATION, |
| 32 |
IVYFORMS_ENTRIES, |
| 33 |
IVYFORMS_ENTRY_DETAILS, |
| 34 |
IVYFORMS_RESULTS_ENTRY_DETAILS, |
| 35 |
IVYFORMS_FORM_RESULTS, |
| 36 |
IVYFORMS_RESULTS, |
| 37 |
IVYFORMS_ENTRIES_PAGE, |
| 38 |
IVYFORMS_SETTINGS_PAGE, |
| 39 |
IVYFORMS_GLOBAL_SETTINGS, |
| 40 |
IVYFORMS_GENERAL_SETTINGS, |
| 41 |
IVYFORMS_SECURITY_SETTINGS, |
| 42 |
} from '@/constants/pages.ts' |
| 43 |
|
| 44 |
const currentPage = new URLSearchParams(window.location.search).get('page') |
| 45 |
|
| 46 |
let routes: RouteRecordRaw[] = [] |
| 47 |
|
| 48 |
if (currentPage === IVYFORMS_DASHBOARD_PAGE) { |
| 49 |
routes = [ |
| 50 |
{ |
| 51 |
path: '/', |
| 52 |
name: IVYFORMS_DASHBOARD, |
| 53 |
component: DashboardPage, |
| 54 |
}, |
| 55 |
] |
| 56 |
} |
| 57 |
|
| 58 |
if (currentPage === IVYFORMS_ALLFORMS_PAGE) { |
| 59 |
routes = [ |
| 60 |
{ |
| 61 |
path: '/', |
| 62 |
name: IVYFORMS_ALL_FORMS, |
| 63 |
component: FormsPage, |
| 64 |
}, |
| 65 |
] |
| 66 |
} |
| 67 |
|
| 68 |
if (currentPage === IVYFORMS_FORM_BUILDER_PAGE) { |
| 69 |
routes = [ |
| 70 |
{ |
| 71 |
path: '/', |
| 72 |
name: IVYFORMS_ADD_FORM, |
| 73 |
component: FormBuilderPage, |
| 74 |
}, |
| 75 |
{ |
| 76 |
path: '/manage/:formId(\\d+)', |
| 77 |
redirect: { name: IVYFORMS_EDIT_FORM }, |
| 78 |
children: [ |
| 79 |
{ |
| 80 |
path: '', |
| 81 |
name: IVYFORMS_EDIT_FORM, |
| 82 |
component: FormBuilderPage, |
| 83 |
}, |
| 84 |
{ |
| 85 |
path: 'settings', |
| 86 |
name: IVYFORMS_SETTINGS, |
| 87 |
component: FormBuilderSettingsPage, |
| 88 |
children: [ |
| 89 |
{ |
| 90 |
path: 'general', |
| 91 |
name: IVYFORMS_FORM_SETTING, |
| 92 |
component: FormBuilderSettings, |
| 93 |
}, |
| 94 |
{ |
| 95 |
path: 'notification', |
| 96 |
name: IVYFORMS_FORM_NOTIFICATIONS, |
| 97 |
component: FormBuilderNotificationTable, |
| 98 |
}, |
| 99 |
{ |
| 100 |
path: 'notification/manage', |
| 101 |
name: IVYFORMS_NEW_NOTIFICATIONS, |
| 102 |
component: FormBuilderManageNotification, |
| 103 |
}, |
| 104 |
{ |
| 105 |
path: 'notification/manage/:notificationId(\\d+)', |
| 106 |
name: IVYFORMS_EDIT_NOTIFICATIONS, |
| 107 |
component: FormBuilderManageNotification, |
| 108 |
}, |
| 109 |
{ |
| 110 |
path: 'confirmation/manage/:confirmationId(\\d+)', |
| 111 |
name: IVYFORMS_FORM_CONFIRMATION, |
| 112 |
component: FormBuilderConfirmation, |
| 113 |
}, |
| 114 |
], |
| 115 |
}, |
| 116 |
{ |
| 117 |
path: 'results', |
| 118 |
name: IVYFORMS_RESULTS, |
| 119 |
component: FormBuilderResultsPage, |
| 120 |
children: [ |
| 121 |
{ |
| 122 |
path: 'entries', |
| 123 |
name: IVYFORMS_FORM_RESULTS, |
| 124 |
component: FormBuilderResultsEntries, |
| 125 |
}, |
| 126 |
], |
| 127 |
}, |
| 128 |
{ |
| 129 |
path: 'results/entries/details/:entryId(\\d+)', |
| 130 |
name: IVYFORMS_RESULTS_ENTRY_DETAILS, |
| 131 |
component: EntryPage, |
| 132 |
}, |
| 133 |
], |
| 134 |
}, |
| 135 |
] |
| 136 |
} |
| 137 |
|
| 138 |
if (currentPage === IVYFORMS_ENTRIES_PAGE) { |
| 139 |
routes = [ |
| 140 |
{ |
| 141 |
path: '/', |
| 142 |
name: IVYFORMS_ENTRIES, |
| 143 |
component: EntriesPage, |
| 144 |
}, |
| 145 |
{ |
| 146 |
path: '/details/:id(\\d+)', |
| 147 |
name: IVYFORMS_ENTRY_DETAILS, |
| 148 |
component: EntryPage, |
| 149 |
}, |
| 150 |
] |
| 151 |
} |
| 152 |
if (currentPage === IVYFORMS_SETTINGS_PAGE) { |
| 153 |
routes = [ |
| 154 |
{ |
| 155 |
path: '/', |
| 156 |
name: IVYFORMS_GLOBAL_SETTINGS, |
| 157 |
component: SettingsPage, |
| 158 |
children: [ |
| 159 |
{ |
| 160 |
path: 'general', |
| 161 |
name: IVYFORMS_GENERAL_SETTINGS, |
| 162 |
component: GeneralSettingsPage, |
| 163 |
}, |
| 164 |
{ |
| 165 |
path: 'security', |
| 166 |
redirect: 'security/recaptcha', |
| 167 |
}, |
| 168 |
{ |
| 169 |
path: 'security/:provider(recaptcha|hcaptcha|turnstile|honeypot)', |
| 170 |
name: IVYFORMS_SECURITY_SETTINGS, |
| 171 |
component: SecuritySettingsPage, |
| 172 |
}, |
| 173 |
], |
| 174 |
}, |
| 175 |
] |
| 176 |
} |
| 177 |
|
| 178 |
const router = createRouter({ |
| 179 |
history: createWebHashHistory(), |
| 180 |
routes, |
| 181 |
}) |
| 182 |
export default router |
| 183 |
|