<template>
  <div class="container">
    <!-- eslint-disable max-len -->
    <div class="login-page">
      <form id="signIn">
        <div class="form">
          <div>
            <h4>Login</h4>
          </div>
          <div class="row">
            <div class="col-md-11" style="margin-bottom: 1em">
              <div class="input-group mb-3">
                <div class="input-group-prepend">
                  <span class="input-group-text">
                    <eva-icon name="person-outline" fill="#60CBEB"></eva-icon>
                  </span>
                  <input
                    class="form-control"
                    type="text"
                    name="username"
                    placeholder="Username"
                    value
                  />
                </div>
              </div>
              <div class="input-group mb-3">
                <div class="input-group-prepend">
                  <span class="input-group-text">
                    <eva-icon name="lock-outline" fill="#60CBEB"></eva-icon>
                  </span>
                  <input
                    class="form-control"
                    :type="isPasswordShown"
                    v-model="password"
                    id="password"
                    placeholder="Password"
                    name="password"
                    value
                  />
                  <div class="input-group-append">
                    <span class="input-group-text">
                      <eva-icon
                        v-if="!showPassword"
                        name="eye-off-outline"
                        fill="#60CBEB"
                        @click="togglePassword()"
                      ></eva-icon>
                      <eva-icon v-else name="eye-outline" fill="#60CBEB" @click="passwordToggled()"></eva-icon>
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="form-group row"></div>
          <button @click="Login()" class="btn btn-b-n" type="submit">Sign In</button>
          <p v-if="user !== null">{{ user }}</p>
        </div>
      </form>

      <form id="forgot">
        <div class="form">
          <h5>Trouble signing in?</h5>
          <div>
            <div class="row">
              <div class="input-group-prepend">
                <span class="input-group-text">
                  <eva-icon name="email-outline" fill="#60CBEB"></eva-icon>
                </span>
                <input class="form-control" placeholder="Your Email" type="text" name="email" value />
              </div>
            </div>
          </div>
          <div class="form-group row"></div>
          <div class="offset-md-3 col-md-5">
            <button @click="SendMail()" class="btn btn-b-n" type="submit">Get Help</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
const axios = require('axios');

export default {
  name: 'Login',
  data() {
    return {
      username: '',
      user: null,
      isPasswordShown: 'password',
      selectItems: [{ text: 'password', value: 0 }],
      selectErrors: 'Some error with the field',
      select: null,
      textErrors: 'Some error with the field',
      text: '',
      showPassword: false,
      password: '',
    };
  },
  methods: {
    Login() {
      axios
        .post('/api/register/authenticate', {
          username: this.username,
          password: this.password,
        })
        .then(response => console.log(response.data))
        .catch(error => console.log(error.push));
      this.$router.push('/');
    },
    togglePassword() {
      this.showPassword = true;
      this.isPasswordShown = 'text';
    },
    passwordToggled() {
      this.showPassword = false;
      this.isPasswordShown = 'password';
    },
    SendMail() {},
  },
};
</script>

<style>
.goDown {
  margin-top: 150px;
}
</style>
