<template>
  <div class="login-wrapper">
    <form @submit.prevent="goLogin">
      <panel>
        <input v-model="password" type="password" autofocus />
        <button @clicked="goLogin" type="submit">Authenticate</button>
      </panel>
    </form>
  </div>
</template>

<script>
import axios from "axios";
import Panel from "../components/Panel.vue";

export default {
  name: "Login",
  components: {
    Panel
  },
  data() {
    return {
      password: "",
    };
  },
  methods: {
    async goLogin() {
      const response = await axios.post("/api/authorize", {
        password: this.password,
      });
      localStorage.setItem("token", response.data.token);
      this.$router.push("/");
    },
  },
};
</script>

<style scoped>
.login-wrapper {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 100vh;
  align-items: center;
  justify-items: center; /* adjusted */
}
input {
  background: #333;
  font-size: 40px;
  color: #fff;
  background: #121212;
  font-weight: bold;
  padding: 12px 22px;
  border-radius: 4px;
  border: 1px solid #777;
  margin-bottom: 15px;
}
button {
  transition: all 0.2s;
  padding: 10px 18px;
  background: #333;
  color: #fff;
  font-weight: bold;
  border: 1px solid #000;
  background: #121212;
  box-shadow: none;
}
button:hover {
  transition: all 0.2s;
  box-shadow: rgba(0, 0, 0, 0.25) 0px 14px 28px,
    rgba(0, 0, 0, 0.22) 0px 10px 10px;
}
</style>>
