9999 </v-menu >
100100
101101 <template v-if =" $user .id " >
102- <v-btn
103- v-if =" $user.profile.side === 'ppa'"
104- depressed
105- color =" primary"
106- :to =" {
107- name: 'ddt-departement-collectivites',
108- params: {
109- departement: $user.profile.departement,
110- }
111- }"
112- >
113- Tableau de bord
114- </v-btn >
115- <v-btn
116- v-else-if =" $user.profile.side === 'etat'"
117- depressed
118- color =" primary"
119- :to =" {
120- name: $user.profile.poste === 'ddt' ? 'ddt-departement-collectivites' : 'trames-githubRef',
121- params: {
122- departement: $user.profile.departement,
123- githubRef: trameRef
124- }
125- }"
126- >
127- {{ $user.profile.poste === 'ddt' ? 'Tableau de bord' : 'Trame regionale' }}
128- </v-btn >
129- <v-btn
130- v-else-if =" $user.profile.side === 'collectivite'"
131- depressed
132- color =" primary"
133- :to =" `/collectivites/${$user.profile.collectivite_id}`"
134- >
135- Ma collectivité
136- </v-btn >
137-
138102 <v-menu offset-y >
139- <template #activator =" { on } " >
103+ <template #activator =" { on , attrs } " >
140104 <v-btn
141- depressed
142- icon
143- small
105+ outlined
106+ color =" primary"
107+ class =" no-text-transform"
108+ v-bind =" attrs"
144109 v-on =" on"
145110 >
146- <v-icon >{{ icons.mdiDotsVertical }}</v-icon >
111+ <v-icon
112+ left
113+ size =" 20"
114+ >
115+ {{ icons.mdiAccountCircleOutline }}
116+ </v-icon >
117+ <span style =" line-height : 1 ;" >{{ $user.profile.firstname || 'Mon compte' }}</span >
118+ <v-icon
119+ right
120+ size =" 18"
121+ >
122+ {{ icons.mdiChevronDown }}
123+ </v-icon >
147124 </v-btn >
148125 </template >
149126 <v-list >
150- <v-list-item link @click =" signOut" >
151- <v-list-item-title >
152- Déconnexion
127+ <v-list-item
128+ v-if =" dashboardRoute"
129+ :to =" dashboardRoute"
130+ >
131+ <v-icon
132+ size =" 18"
133+ class =" mr-3"
134+ >
135+ {{ icons.mdiViewDashboardOutline }}
136+ </v-icon >
137+ <v-list-item-title class =" text-body-2" >
138+ {{ dashboardLabel }}
139+ </v-list-item-title >
140+ </v-list-item >
141+ <v-list-item @click =" signOut" >
142+ <v-icon
143+ size =" 18"
144+ color =" error"
145+ class =" mr-3"
146+ >
147+ {{ icons.mdiLogout }}
148+ </v-icon >
149+ <v-list-item-title class =" error--text text-body-2" >
150+ Se déconnecter
153151 </v-list-item-title >
154152 </v-list-item >
155153 </v-list >
158156 <AuthResetPasswordDialog />
159157 </template >
160158
161- <v-btn v-else depressed color =" primary" :to =" { name: 'login' }" >
162- Connexion
159+ <v-btn
160+ v-else
161+ outlined
162+ color =" primary"
163+ class =" no-text-transform"
164+ :to =" { name: 'login' }"
165+ >
166+ <v-icon left >
167+ {{ icons.mdiAccountCircleOutline }}
168+ </v-icon >
169+ Me connecter
163170 </v-btn >
164171 </div >
165172 </client-only >
170177</template >
171178
172179<script >
173- import { mdiDotsVertical , mdiChevronDown } from ' @mdi/js'
180+ import { mdiChevronDown , mdiAccountCircleOutline , mdiViewDashboardOutline , mdiLogout } from ' @mdi/js'
174181
175182export default {
176183 props: {
@@ -186,26 +193,56 @@ export default {
186193 data () {
187194 return {
188195 icons: {
189- mdiDotsVertical,
190- mdiChevronDown
196+ mdiChevronDown,
197+ mdiAccountCircleOutline,
198+ mdiViewDashboardOutline,
199+ mdiLogout
191200 }
192201 }
193202 },
194203 computed: {
195204 trameRef () {
196- const scopes = { ddt: ' dept' , dreal: ' region' }
197205 const poste = this .$user .profile .poste
206+ if (! poste) { return null }
207+ const scopes = { ddt: ' dept' , dreal: ' region' }
198208 const code = poste === ' ddt' ? this .$user .profile .departement : this .$user .profile .region
209+ if (! code) { return null }
199210
200211 return ` ${ scopes[poste]} -${ this .$options .filters .deptToRef (code)} `
212+ },
213+ dashboardRoute () {
214+ if (! this .$user .id ) { return null }
215+ const { side , poste , departement , collectivite_id: collectiviteId } = this .$user .profile
216+ if (side === ' ppa' ) {
217+ return { name: ' ddt-departement-collectivites' , params: { departement } }
218+ }
219+ if (side === ' etat' ) {
220+ return {
221+ name: poste === ' ddt' ? ' ddt-departement-collectivites' : ' trames-githubRef' ,
222+ params: { departement, githubRef: this .trameRef }
223+ }
224+ }
225+ if (side === ' collectivite' ) {
226+ return ` /collectivites/${ collectiviteId} `
227+ }
228+ return null
229+ },
230+ dashboardLabel () {
231+ const { side , poste } = this .$user .profile
232+ if (side === ' collectivite' ) { return ' Ma collectivité' }
233+ if (side === ' etat' && poste !== ' ddt' ) { return ' Trame régionale' }
234+ return ' Tableau de bord'
201235 }
202236 },
203237 async mounted () {
204238 await this .$user .isReady
205239 },
206240 methods: {
207241 async signOut () {
208- await this .$supabase .auth .signOut ()
242+ const { error } = await this .$supabase .auth .signOut ()
243+ if (error) {
244+ return console .error (' signOut error:' , error)
245+ }
209246 this .$router .push (' /' )
210247 }
211248 }
0 commit comments