<script setup >

const { login } = useStrapiAuth()
const router = useRouter()

const username = ref("flfeders")
const password = ref("Open@all4me!")


const onSubmit = async () => {
  try {
    await login({identifier: username.value, password: password.value})
    console.log("Successfully Logged In")
    router.push("/tasks")

  } catch(e) {
    console.log(e)
  }
}

const user = useStrapiUser()
console.log(user)



</script>

<template>
  <div id="loginSite">
    <div id="loginForm">
      <UFormGroup
          label="Username:"
      >
        <UInput
            v-model="username"
        />
      </UFormGroup>
      <UFormGroup
          label="Passwort:"
      >
        <UInput
            v-model="password"
            type="password"
        />
      </UFormGroup>
      <UButton
          @click="onSubmit"
          class="mt-3"
      >
        Einloggen
      </UButton>
    </div>

  </div>
</template>

<style scoped>
#loginSite {
  display: flex;
  align-content: center;
  justify-content: center;

}

#loginForm {
  width: 30vw;
  height: 30vh;
}
</style>