Home.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <template>
  3. <div>
  4. <h1>{{ i18n.t('Home') }}</h1>
  5. <p>{{ userData?.firstname }} {{ userData?.lastname }}</p>
  6. <br />
  7. <p v-on:click="logout">{{ i18n.t('Logout') }}</p>
  8. <br />
  9. <p v-on:click="goToTickets">Go to Tickets</p>
  10. <br />
  11. <p v-on:click="refetchConfig">refetchConfig</p>
  12. <br />
  13. <p v-on:click="fetchCurrentUser">fetchCurrentUser</p>
  14. <br /><br />
  15. <h1 class="mb-4 text-lg">Configs:</h1>
  16. <template v-if="config.value">
  17. <p v-for="(value, key) in config.value" v-bind:key="(key as string)">
  18. Key: {{ key }}<br />
  19. Value: {{ value }} <br /><br />
  20. </p>
  21. </template>
  22. </div>
  23. </template>
  24. <script setup lang="ts">
  25. import useNotifications from '@common/composables/useNotifications'
  26. import useAuthenticatedStore from '@common/stores/authenticated'
  27. import useSessionUserStore from '@common/stores/session/user'
  28. import { storeToRefs } from 'pinia'
  29. import { useRouter } from 'vue-router'
  30. import useApplicationConfigStore from '@common/stores/application/config'
  31. import { useCurrentUserQuery } from '@common/graphql/api'
  32. import { NotificationTypes } from '@common/types/notification'
  33. import useViewTransition from '@mobile/composables/useViewTransition'
  34. import ViewTransitions from '@mobile/types/transition'
  35. // TODO: Only testing for the notifications...
  36. const { notify, clearAllNotifications } = useNotifications()
  37. notify({
  38. message: __('Hello Home!!!'),
  39. type: NotificationTypes.WARN,
  40. duration: 10000,
  41. })
  42. const sessionUser = useSessionUserStore()
  43. const { value: userData } = storeToRefs(sessionUser)
  44. const authenticated = useAuthenticatedStore()
  45. const router = useRouter()
  46. const logout = (): void => {
  47. clearAllNotifications()
  48. authenticated.logout().then(() => {
  49. router.push('/login')
  50. })
  51. }
  52. const config = useApplicationConfigStore()
  53. const refetchConfig = async (): Promise<void> => {
  54. await config.getConfig()
  55. }
  56. const fetchCurrentUser = () => {
  57. const { result } = useCurrentUserQuery({ fetchPolicy: 'no-cache' })
  58. console.log('result', result)
  59. }
  60. const goToTickets = () => {
  61. const { setViewTransition } = useViewTransition()
  62. setViewTransition(ViewTransitions.NEXT)
  63. router.push('/tickets')
  64. }
  65. </script>