61 lines
1.6 KiB
Vue
Raw Normal View History

2024-12-02 23:19:00 +04:00
<script setup lang="ts">
2024-12-03 03:46:46 +04:00
import { inject } from 'vue';
import { useUserStore } from '../../store';
import { AuthService } from '../../core/services/auth-service';
import router from '../../router';
import { HomeOutlined, BlockOutlined } from '@ant-design/icons-vue';
2024-12-03 03:46:46 +04:00
const store = useUserStore();
const authService = inject(AuthService.name) as AuthService;
2024-12-03 03:46:46 +04:00
function logout() {
authService.logout();
router.push({ name: 'login' });
}
2024-12-02 23:19:00 +04:00
</script>
<template>
2024-12-03 03:46:46 +04:00
<a-layout-header class="header">
<div class="base-nav">
<div>ДомБюдж</div>
<nav>
<RouterLink :to="{ name: 'home' }"><HomeOutlined /> Главная</RouterLink>
<RouterLink :to="{ name: 'groups' }"><BlockOutlined /> Группы расходов</RouterLink>
2024-12-03 03:46:46 +04:00
</nav>
</div>
<div v-if="!store.user.id">
<RouterLink :to="{ name: 'login' }">Войти</RouterLink>
</div>
<div v-else>
<label for="logout">Привет, {{ store.user.name }}! Ваш текущий баланс: {{ store.user.balance }}</label>
2024-12-03 03:46:46 +04:00
<a-button
name="logout"
@click="logout()"
danger
style="margin-left: 30px"
2024-12-03 03:46:46 +04:00
>
Выйти
</a-button>
</div>
</a-layout-header>
2024-12-02 23:19:00 +04:00
</template>
<style scoped>
2024-12-03 03:46:46 +04:00
.header {
background-color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.base-nav {
display: inline-flex;
justify-content: left;
}
.base-nav a {
margin-left: 30px;
2024-12-03 03:46:46 +04:00
}
2024-12-02 23:19:00 +04:00
</style>