diff --git a/frontend/src/router.js b/frontend/src/router.js index 8f1db2ea76..1101697414 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -704,6 +704,9 @@ async function requireChecklist(to, from, next) { } export function campFromRoute(route) { + if (!route.params.campId) { + return undefined + } return apiStore.get().camps({ id: route.params.campId }) } @@ -712,24 +715,39 @@ export function invitationFromInviteKey(inviteKey) { } export function periodFromRoute(route) { + if (!route.params.periodId) { + return undefined + } return apiStore.get().periods({ id: route.params.periodId }) } function scheduleEntryFromRoute(route) { + if (!route.params.scheduleEntryId) { + return undefined + } return apiStore.get().scheduleEntries({ id: route.params.scheduleEntryId }) } function categoryFromRoute(route) { + if (!route.params.categoryId) { + return undefined + } return campFromRoute(route) .categories() .allItems.find((c) => c.id === route.params.categoryId) } export function materialListFromRoute(route) { + if (!route.params.materialId) { + return undefined + } return apiStore.get().materialLists({ id: route.params.materialId }) } export function checklistFromRoute(route) { + if (!route.params.checklistId) { + return undefined + } return campFromRoute(route) .checklists() .allItems.find((c) => c.id === route.params.checklistId) @@ -755,6 +773,9 @@ function getContentLayout(route) { } function dayFromScheduleEntryInRoute(route) { + if (!route.params.scheduleEntryId) { + return undefined + } return apiStore.get().scheduleEntries({ id: route.params.scheduleEntryId }).day() } @@ -934,6 +955,9 @@ export function checklistOverviewRoute(camp, checklist, query = {}) { } async function firstFuturePeriod(route) { + if (!route.params.campId) { + return undefined + } const periods = await apiStore.get().camps({ id: route.params.campId }).periods()._meta .load // Return the first period that hasn't ended, or if no such period exists, return the first period