<template>
  <div class="min-h-screen flex items-center justify-center">
    <div class="max-w-md w-full py-12 px-6">
      <img class="mx-auto h-24 w-auto" src="/favicon.png" alt="" />
      <h1 class="sm:text-3xl text-2xl font-medium title-font mb-4 text-center">Lauf für Kaya! - Registrieren</h1>
      <p
        class="mx-auto leading-relaxed text-base text-center"
      >Bitte anmelden...</p>
      <div class="mt-5">
        <div class="rounded-md shadow-sm">
          <div>
            <input
              aria-label="E-Mail Adresse"
              name="email"
              type="email"
              required
              class="border-gray-300 placeholder-gray-500 appearance-none rounded-none relative block w-full px-3 py-2 border text-gray-900 rounded-t-md focus:outline-none focus:shadow-outline-blue focus:border-blue-300 focus:z-10 sm:text-sm"
              placeholder="E-Mail Adresse"
              v-model="mail"
            />
          </div>
          <div class="-mt-px relative">
            <input
              aria-label="Passwort"
              name="password"
              type="password"
              required
              class="border-gray-300 placeholder-gray-500 appearance-none rounded-none relative block w-full px-3 py-2 border text-gray-900 rounded-b-md focus:outline-none focus:shadow-outline-blue focus:border-blue-300 focus:z-10 sm:text-sm"
              placeholder="Passwort"
            />
            <div class="absolute inset-y-0 right-0 pr-3 flex items-center text-sm">
              <a href="./reset" class="text-gray-900 underline">Passwort vergessen?</a>
            </div>
          </div>
        </div>
        <div class="mt-5">
          <button
            v-if="loading === false"
            @click="login"
            type="submit"
            class="relative block w-full py-2 px-3 border border-transparent rounded-md font-semibold bg-gray-800 hover:bg-gray-700 focus:bg-gray-900 focus:outline-none focus:shadow-outline sm:text-sm text-white"
          >
            <span class="absolute left-0 inset-y pl-3">
              <svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
                <path
                  fill-rule="evenodd"
                  d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z"
                  clip-rule="evenodd"
                />
              </svg>
            </span>
            Log in
          </button>
          <button
            v-if="loading === true"
            type="submit"
            class="relative block w-full py-2 px-3 border border-transparent rounded-md font-semibold bg-yellow-500 sm:text-sm text-black"
          >
            <span class="absolute left-0 inset-y pl-3">
              <svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
                <path
                  fill-rule="evenodd"
                  d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z"
                  clip-rule="evenodd"
                />
              </svg>
            </span>
            Logging in...
          </button>
        </div>
      </div>
      <div class="mt-6">
        <div class="relative">
          <div class="absolute inset-0 flex items-center">
            <div class="w-full border-t border-gray-300"></div>
          </div>
          <div class="relative flex justify-center text-sm">
            <span class="px-2 bg-white dark:bg-gray-900">Sie haben noch keinen Account?</span>
          </div>
        </div>
        <div class="mt-6">
          <a
            href="./register"
            class="block w-full text-center py-2 px-3 border border-gray-300 rounded-md font-medium hover:border-gray-400 focus:outline-none focus:border-gray-400 sm:text-sm"
          >Account erstellen</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import axios from "redaxios";
import Toastify from "toastify-js";

let mail = ref("");
let loading = ref(false);
function login() {
  console.log("ihi");
  console.log(mail.value);
  loading.value = true;
  axios.get("").then((res) => {
    console.log(res.data);
    loading.value = false;
    Toastify({
      text: "This is a toast",
      duration: 3000,
    }).showToast();
  });
}
</script>