diff --git a/frontend/src/router.js b/frontend/src/router.js index a95100babd..1358d671eb 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -379,7 +379,7 @@ export default new Router({ default: () => import('./views/activity/Activity.vue'), aside: () => import('./views/activity/SideBarProgram.vue'), }, - beforeEnter: requireAuth, + beforeEnter: all([requireAuth, requireCamp, requireScheduleEntry]), props: { navigation: (route) => ({ camp: campFromRoute(route) }), default: (route) => ({ scheduleEntry: scheduleEntryFromRoute(route) }), @@ -450,6 +450,21 @@ async function requireCamp(to, from, next) { }) } +async function requireScheduleEntry(to, from, next) { + await scheduleEntryFromRoute(to) + .call({ api: { get: apiStore.get } }) + ._meta.load.then(() => { + next() + }) + .catch(() => { + next({ + name: 'PageNotFound', + params: [to.fullPath, ''], + replace: true, + }) + }) +} + async function requirePeriod(to, from, next) { await periodFromRoute(to) .call({ api: { get: apiStore.get } })