fixed room listing and added logout button
This commit is contained in:
@@ -12,21 +12,31 @@
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<button class="logout" @click="logout()">Logout</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { initAuth } from '../stores/auth.ts'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { initAuth, logout as authLogout } from '../stores/auth.ts'
|
||||
import { fetchRooms } from '../api/rooms'
|
||||
import type { Room } from '../types/api'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const rooms = ref<Room[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
const auth = await initAuth()
|
||||
rooms.value = await fetchRooms(auth.uuid!)
|
||||
})
|
||||
|
||||
function logout() {
|
||||
authLogout()
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -80,4 +90,11 @@ export default { components: { CreateRoomForm } }
|
||||
.room-link:hover {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
|
||||
.logout {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
margin: 30px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user