<template>
  <div class="flex flex-center">
    <LoginForm v-on:update-close="forwardToPage" />
  </div>
</template>

<script setup lang="ts">
import LoginForm from 'src/vueLib/login/LoginForm.vue';
import { useUserStore } from 'src/vueLib/login/userStore';
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();
const userStore = useUserStore();

onMounted(() => {
  const user = userStore.getUser();
  if (user?.username !== '' && user?.role !== '') {
    forwardToPage().catch((err) => console.error(err));
  }
});

const forwardToPage = () => router.push('/members');
</script>
