1
0
Fork 0
forked from TWS/kalkutago

Add logout button

This commit is contained in:
D. Scott Boggs 2023-08-26 06:08:49 -04:00
parent dd2c2e7021
commit 168289335b

View file

@ -1,5 +1,14 @@
<script setup lang="ts">
import { RouterLink } from 'vue-router';
import { error } from '../error'
import router from "../router";
async function logOut() {
const result = await fetch('/api/v1/auth', {method: 'DELETE'})
if(!result.ok) return error('failed to log out')
console.debug('logged out')
router.push('/login')
}
</script>
<template>
<nav class="navbar" role="navigation" aria-label="main navigation">
@ -9,20 +18,27 @@ import { RouterLink } from 'vue-router';
<div class="navbar-menu"></div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<RouterLink to="/" v-if="$route.path === '/new-track'">
<button class="button is-info">
Go Back
</button>
</RouterLink>
<RouterLink to="/" v-if="$route.path === '/new-track'">
<button class="button is-info">
Go Back
</button>
</RouterLink>
<RouterLink to="/new-track" v-else>
<button class="button is-primary">
Add Track
</button>
</RouterLink>
</div>
<RouterLink to="/new-track" v-else>
<button class="button is-primary">
Add Track
</button>
</RouterLink>
</div>
<div class="navbar-item">
<button class="button is-info" @click="logOut">
Log Out
</button>
</div>
<div class="navbar-item">
<!-- spacer -->
&nbsp;
</div>
</div>
</nav>
</template>
</template>