Explorar el Código

fix SuperAdmin component

Olivier Massot hace 4 años
padre
commit
1dbbf507b4
Se han modificado 1 ficheros con 17 adiciones y 13 borrados
  1. 17 13
      components/Layout/AlertBar/SuperAdmin.vue

+ 17 - 13
components/Layout/AlertBar/SuperAdmin.vue

@@ -3,33 +3,37 @@ Super Admin bar : Barre qui s'affiche lorsque l'utilisateur est un super admin e
 -->
 
 <template>
-  <UiSystemBar color="ot_danger" v-if="show">
+  <UiSystemBar v-if="show" color="ot_danger">
     <template #bar.text>
-      <v-icon small>fas fa-exclamation-triangle</v-icon>
-      <span>{{$t('super_admin_switch_account')}}</span>
-      <a :href="url" class="ot_black--text text-decoration-none"><strong>{{$t('click_here')}}</strong></a>
+      <v-icon small>
+        fas fa-exclamation-triangle
+      </v-icon>
+      <span>{{ $t('super_admin_switch_account') }}</span>
+      <a :href="url" class="ot_black--text text-decoration-none"><strong>{{ $t('click_here') }}</strong></a>
     </template>
   </UiSystemBar>
 </template>
 
 <script lang="ts">
-import { defineComponent, useStore, useContext} from '@nuxtjs/composition-api'
-import {AnyStore} from "~/types/interfaces";
-import {State} from "@vuex-orm/core";
+import { defineComponent, useStore, useContext } from '@nuxtjs/composition-api'
+import { State } from '@vuex-orm/core'
+import { AnyStore } from '~/types/interfaces'
 
 export default defineComponent({
   setup () {
-    const {$config} = useContext()
+    const { $config } = useContext()
     const baseLegacyUrl:string = $config.baseURL_adminLegacy
     const store:AnyStore = useStore<State>()
     const originalAccess = store.state.profile.access.originalAccess
+    let show = false
+    let url = ''
 
-    const url = `${baseLegacyUrl}/switch_user/${originalAccess.organization.id}/${originalAccess.id}/exit`
-
-    return {
-      show: originalAccess.isSuperAdminAccess,
-      url
+    if (originalAccess !== null) {
+      show = originalAccess.isSuperAdminAccess
+      url = `${baseLegacyUrl}/switch_user/${originalAccess.organization.id}/${originalAccess.id}/exit`
     }
+
+    return { show, url }
   }
 })
 </script>