CommonError.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { ErrorOptions } from '#shared/router/error.ts'
  5. import { ErrorStatusCodes } from '#shared/types/error.ts'
  6. export interface Props {
  7. options?: ErrorOptions | null
  8. authenticated?: boolean
  9. }
  10. const props = defineProps<Props>()
  11. const errorImage = computed(() => {
  12. switch (props.options?.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. <img width="540" class="max-h-96" :alt="$t('Error')" :src="errorImage" />
  25. <h1 class="text-center text-xl leading-snug text-black dark:text-white">
  26. {{ $t(options?.title) }}
  27. </h1>
  28. <CommonLabel class="mx-auto max-w-prose text-center" tag="p">
  29. {{ $t(options?.message, ...(options?.messagePlaceholder || [])) }}
  30. </CommonLabel>
  31. <CommonLabel
  32. v-if="options?.route"
  33. class="mx-auto max-w-prose text-center"
  34. tag="p"
  35. >
  36. {{ options.route }}
  37. </CommonLabel>
  38. <CommonLink v-if="!authenticated" link="/login" size="medium">
  39. {{ $t('Please proceed to login') }}
  40. </CommonLink>
  41. </template>