46 lines
No EOL
917 B
Vue
46 lines
No EOL
917 B
Vue
<script setup lang="ts">
|
|
import {useRouter} from "vue-router";
|
|
import {useAuthStore} from "@/stores/auth.store.ts";
|
|
import axios from "axios";
|
|
|
|
const router = useRouter();
|
|
const auth = useAuthStore();
|
|
const userName = auth.userData.login;
|
|
|
|
const emit = defineEmits([
|
|
'userProfilePage'
|
|
])
|
|
|
|
const userProfilePage = () => {
|
|
emit('userProfilePage')
|
|
}
|
|
const logout = async () => {
|
|
try {
|
|
await axios.get('/logout');
|
|
auth.resetUser();
|
|
router.push('/login');
|
|
} catch (error) {
|
|
console.error('Error logging out:', error);
|
|
}
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<v-sheet
|
|
:width="150"
|
|
>
|
|
<v-btn color="info" @click="userProfilePage">{{ userName }} {{ $t('header.userinfo.info') }}</v-btn>
|
|
<v-btn color="" @click="logout">{{ $t('header.userinfo.logout') }}</v-btn>
|
|
</v-sheet>
|
|
</template>
|
|
|
|
<style scoped>
|
|
div button {
|
|
width: 100%;
|
|
}
|
|
|
|
div button:not(:first-child) {
|
|
margin-top: 2px;
|
|
}
|
|
</style> |