SuperAdmin.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!--
  2. Super Admin bar : Barre qui s'affiche lorsque l'utilisateur est un super admin en mode switch
  3. -->
  4. <template>
  5. <UiSystemBar v-if="show" color="ot_danger">
  6. <template #bar.text>
  7. <v-icon small>
  8. fas fa-exclamation-triangle
  9. </v-icon>
  10. <span>{{ $t('super_admin_switch_account') }}</span>
  11. <a :href="url" class="ot_black--text text-decoration-none"><strong>{{ $t('click_here') }}</strong></a>
  12. </template>
  13. </UiSystemBar>
  14. </template>
  15. <script lang="ts">
  16. import { defineComponent, useStore, useContext } from '@nuxtjs/composition-api'
  17. import { State } from '@vuex-orm/core'
  18. import { AnyStore } from '~/types/interfaces'
  19. export default defineComponent({
  20. setup () {
  21. const { $config } = useContext()
  22. const baseLegacyUrl:string = $config.baseURL_adminLegacy
  23. const store:AnyStore = useStore<State>()
  24. const originalAccess = store.state.profile.access.originalAccess
  25. let show = false
  26. let url = ''
  27. if (originalAccess !== null) {
  28. show = originalAccess.isSuperAdminAccess
  29. url = `${baseLegacyUrl}/switch_user/${originalAccess.organization.id}/${originalAccess.id}/exit`
  30. }
  31. return { show, url }
  32. }
  33. })
  34. </script>
  35. <style scoped>
  36. </style>