TicketSidebarCustomerContent.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import CommonUserAvatar from '#shared/components/CommonUserAvatar/CommonUserAvatar.vue'
  5. import ObjectAttributes from '#shared/components/ObjectAttributes/ObjectAttributes.vue'
  6. import type {
  7. ObjectManagerFrontendAttribute,
  8. Organization,
  9. UserQuery,
  10. } from '#shared/graphql/types.ts'
  11. import { normalizeEdges } from '#shared/utils/helpers.ts'
  12. import type { MenuItem } from '#desktop/components/CommonPopoverMenu/types.ts'
  13. import CommonSectionCollapse from '#desktop/components/CommonSectionCollapse/CommonSectionCollapse.vue'
  14. import CommonSimpleEntityList from '#desktop/components/CommonSimpleEntityList/CommonSimpleEntityList.vue'
  15. import { EntityType } from '#desktop/components/CommonSimpleEntityList/types.ts'
  16. import NavigationMenuList from '#desktop/components/NavigationMenu/NavigationMenuList.vue'
  17. import { NavigationMenuDensity } from '#desktop/components/NavigationMenu/types.ts'
  18. import { useChangeCustomerMenuItem } from '#desktop/pages/ticket/components/TicketDetailView/actions/TicketChangeCustomer/useChangeCustomerMenuItem.ts'
  19. import {
  20. type TicketSidebarContentProps,
  21. TicketSidebarScreenType,
  22. } from '#desktop/pages/ticket/types/sidebar.ts'
  23. import TicketSidebarContent from '../TicketSidebarContent.vue'
  24. interface Props extends TicketSidebarContentProps {
  25. customer: UserQuery['user']
  26. secondaryOrganizations: ReturnType<
  27. typeof normalizeEdges<Partial<Organization>>
  28. >
  29. objectAttributes: ObjectManagerFrontendAttribute[]
  30. }
  31. const props = defineProps<Props>()
  32. defineEmits<{
  33. 'load-more-secondary-organizations': []
  34. }>()
  35. const actions = computed<MenuItem[]>(() => {
  36. const availableActions: MenuItem[] = []
  37. // :TODO find a way to provide the ticket via prop
  38. if (props.context.screenType === TicketSidebarScreenType.TicketDetailView) {
  39. const { customerChangeMenuItem } = useChangeCustomerMenuItem()
  40. availableActions.push(customerChangeMenuItem)
  41. }
  42. return availableActions // ADD the rest available menu actions
  43. })
  44. </script>
  45. <template>
  46. <TicketSidebarContent
  47. :title="sidebarPlugin.title"
  48. :icon="sidebarPlugin.icon"
  49. :entity="customer"
  50. :actions="actions"
  51. >
  52. <div class="flex gap-2">
  53. <CommonUserAvatar v-if="customer" :entity="customer" size="normal" />
  54. <div class="flex flex-col justify-center gap-px">
  55. <CommonLabel size="large" class="text-gray-300 dark:text-neutral-400">
  56. {{ customer?.fullname }}
  57. </CommonLabel>
  58. <CommonLink
  59. v-if="customer?.organization"
  60. :link="`/organizations/${customer.organization?.internalId}`"
  61. class="text-sm leading-snug"
  62. >
  63. {{ customer?.organization.name }}
  64. </CommonLink>
  65. </div>
  66. </div>
  67. <ObjectAttributes
  68. :attributes="objectAttributes"
  69. :object="customer"
  70. :skip-attributes="['firstname', 'lastname']"
  71. />
  72. <CommonSimpleEntityList
  73. v-if="secondaryOrganizations.totalCount"
  74. id="customer-secondary-organizations"
  75. :type="EntityType.Organization"
  76. :label="__('Secondary organizations')"
  77. :entity="secondaryOrganizations"
  78. @load-more="$emit('load-more-secondary-organizations')"
  79. />
  80. <CommonSectionCollapse id="customer-tickets" :title="__('Tickets')">
  81. <NavigationMenuList
  82. class="mt-1"
  83. :density="NavigationMenuDensity.Dense"
  84. :items="[
  85. {
  86. label: __('open tickets'),
  87. icon: 'check-circle-no',
  88. iconColor: 'fill-yellow-500',
  89. count: customer?.ticketsCount?.open || 0,
  90. route: '/search/ticket/open',
  91. },
  92. {
  93. label: __('closed tickets'),
  94. icon: 'check-circle-outline',
  95. iconColor: 'fill-green-400',
  96. count: customer?.ticketsCount?.closed || 0,
  97. route: '/search/ticket/closed',
  98. },
  99. ]"
  100. />
  101. </CommonSectionCollapse>
  102. </TicketSidebarContent>
  103. </template>