frontend/src/views/PersonalView/PersonalSessionBlock.vue

61 lines
1.2 KiB
Vue
Raw Normal View History

<script setup>
import { useAuthStore } from '@/stores/authStore.js'
import { computed, onMounted, ref } from 'vue'
import { convertIso } from '@/services/convertTime.js'
const store = useAuthStore()
const currentSession = ref(null)
onMounted(() => {
store.currentSession().then((data) => {
currentSession.value = data
})
})
const formattedDate = computed(() => {
const expires = currentSession?.value?.expires
if (!expires) {
return '---'
}
try {
return convertIso(expires)
} catch (error) {
console.log(error, expires);
return '---';
}
});
2025-09-16 19:59:29 +03:00
const onLogout = () => {
store.logout()
}
</script>
<template>
<n-card :bordered="false" title="Session">
<n-list hoverable clickable>
<n-list-item>
<n-thing title="Session id" content-style="margin-top: 10px;">
{{ currentSession?.uuid || '---' }}
</n-thing>
</n-list-item>
<n-list-item>
<n-thing title="Expires at" content-style="margin-top: 10px;">
{{ formattedDate }}
</n-thing>
</n-list-item>
2025-10-19 17:30:22 +03:00
<div class="button-container-center">
2025-09-22 19:29:59 +03:00
<n-button type="info" class="center-button" @click="onLogout">Log out</n-button>
2025-09-16 19:59:29 +03:00
</div>
</n-list>
</n-card>
</template>
2025-09-16 19:59:29 +03:00
<style scoped>
</style>