TicketSidebarCustomerContent.vue 4.0 KB

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