Skip to content

Commit

Permalink
React to errors from before each nav guard
Browse files Browse the repository at this point in the history
RISDEV-5821
  • Loading branch information
leonie-koch committed Dec 17, 2024
1 parent dbc75f1 commit e89bc4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions frontend/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ export async function beforeEach(to: RouteLocationNormalized) {
const editionStore = useEditionStore()
const editionId = to.params.editionId as string
if (editionId) {
try {
await editionStore.loadEdition(editionId as UUID)
} catch (error) {
console.error("Failed to load edition:", error)
const response = await editionStore.loadEdition(editionId as UUID)
if (response.error) {
to.meta.error = response.error.title
}
}
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ onBeforeUnmount(() => {
onMounted(async () => {
window.addEventListener("keydown", handleKeyDown)
if (route.meta.error) {
responseError.value = { title: route.meta.error as string }
}
})
</script>

Expand Down

0 comments on commit e89bc4c

Please sign in to comment.