Error.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { storeToRefs } from 'pinia'
  4. import { computed } from 'vue'
  5. import { errorOptions } from '#shared/router/error.ts'
  6. import { useAuthenticationStore } from '#shared/stores/authentication.ts'
  7. import { ErrorStatusCodes } from '#shared/types/error.ts'
  8. import LayoutMain from '#desktop/components/layout/LayoutMain.vue'
  9. import LayoutPage from '#desktop/components/layout/LayoutPage.vue'
  10. const { authenticated } = storeToRefs(useAuthenticationStore())
  11. const errorImage = computed(() => {
  12. switch (errorOptions.value.statusCode) {
  13. case ErrorStatusCodes.Forbidden:
  14. return '/assets/error/error-403.svg'
  15. case ErrorStatusCodes.NotFound:
  16. return '/assets/error/error-404.svg'
  17. case ErrorStatusCodes.InternalError:
  18. default:
  19. return '/assets/error/error-500.svg'
  20. }
  21. })
  22. </script>
  23. <template>
  24. <component
  25. :is="authenticated ? LayoutPage : 'div'"
  26. :class="{ 'h-full': !authenticated }"
  27. >
  28. <LayoutMain
  29. class="flex grow flex-col items-center justify-center gap-4 bg-blue-50 dark:bg-gray-800"
  30. >
  31. <img width="540" :alt="$t('Error')" :src="errorImage" />
  32. <h1 class="text-center text-xl leading-snug text-black dark:text-white">
  33. {{ $t(errorOptions.title) }}
  34. </h1>
  35. <CommonLabel class="mx-auto max-w-prose text-center" tag="p">
  36. {{
  37. $t(errorOptions.message, ...(errorOptions.messagePlaceholder || []))
  38. }}
  39. </CommonLabel>
  40. <CommonLabel
  41. v-if="errorOptions.route"
  42. class="mx-auto max-w-prose text-center"
  43. tag="p"
  44. >
  45. {{ errorOptions.route }}
  46. </CommonLabel>
  47. <CommonLink v-if="!authenticated" link="/login" size="medium">
  48. {{ $t('Please proceed to login') }}
  49. </CommonLink>
  50. </LayoutMain>
  51. </component>
  52. </template>