Home.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import CommonInputSearch from '#shared/components/CommonInputSearch/CommonInputSearch.vue'
  5. import { useSessionStore } from '#shared/stores/session.ts'
  6. import CommonSectionMenu from '#mobile/components/CommonSectionMenu/CommonSectionMenu.vue'
  7. import type { MenuItem } from '#mobile/components/CommonSectionMenu/index.ts'
  8. import CommonTicketCreateLink from '#mobile/components/CommonTicketCreateLink/CommonTicketCreateLink.vue'
  9. import { useTicketOverviews } from '#mobile/entities/ticket/composables/useTicketOverviews.ts'
  10. const IS_DEV = import.meta.env.DEV
  11. const session = useSessionStore()
  12. const menu: MenuItem[] = [
  13. {
  14. type: 'link',
  15. link: '/tickets/view',
  16. label: __('Ticket Overviews'),
  17. icon: { name: 'all-tickets', size: 'base' },
  18. iconBg: 'bg-pink',
  19. permission: ['ticket.agent', 'ticket.customer'],
  20. },
  21. // Cannot inline import.meta here, Vite fails
  22. ...(IS_DEV
  23. ? [
  24. {
  25. type: 'link' as const,
  26. link: '/playground',
  27. label: 'Playground',
  28. icon: { name: 'settings', size: 'small' as const },
  29. iconBg: 'bg-orange',
  30. },
  31. ]
  32. : []),
  33. ]
  34. const overviews = useTicketOverviews()
  35. const ticketOverview = computed<MenuItem[]>(() => {
  36. if (overviews.loading) return []
  37. return overviews.includedOverviews.map((overview) => {
  38. return {
  39. type: 'link',
  40. link: `/tickets/view/${overview.link}`,
  41. label: overview.name,
  42. information: overview.ticketCount,
  43. }
  44. })
  45. })
  46. </script>
  47. <template>
  48. <div class="p-4">
  49. <CommonTicketCreateLink class="mb-3 mt-1.5" />
  50. <h1 class="mb-5 flex w-full items-center justify-center text-4xl font-bold">
  51. {{ $t('Home') }}
  52. </h1>
  53. <CommonLink :aria-label="$t('Search…')" link="/search">
  54. <CommonInputSearch
  55. aria-hidden="true"
  56. tabindex="-1"
  57. wrapper-class="mb-4"
  58. no-border
  59. />
  60. </CommonLink>
  61. <CommonSectionMenu :items="menu" />
  62. <CommonSectionMenu
  63. v-if="session.hasPermission(['ticket.agent', 'ticket.customer'])"
  64. :items="ticketOverview"
  65. :header-label="__('Ticket Overview')"
  66. :action-label="__('Edit')"
  67. action-link="/favorite/ticker-overviews/edit"
  68. >
  69. <template v-if="overviews.loading" #before-items>
  70. <div class="flex w-full justify-center">
  71. <CommonIcon name="loading" animation="spin" />
  72. </div>
  73. </template>
  74. </CommonSectionMenu>
  75. </div>
  76. </template>