<template>
  <q-page class="login-page column items-center justify-center page">
    <q-card flat bordered class="card col-6">
      <q-card-section class="column items-center">
        <q-img class="login-logo" src="../assets/logo/loginLogo.png" />
      </q-card-section>
      <q-card-section class="form column items-center">
        <q-input v-model="username" color="orange" placeholder="Login">
          <template v-slot:prepend>
            <q-icon name="person" />
          </template>
        </q-input>
        <q-input v-model="password" color="orange" placeholder="Senha" type="password">
          <template v-slot:prepend>
            <q-icon name="vpn_key" />
          </template>
        </q-input>
      </q-card-section>
      <q-card-section class="column items-center">
        <q-btn @click="logInto" class="login-btn" label="Entrar" no-caps />
        <router-link class="forget-password" to="cadastrar">
          Esqueceu a Senha?
        </router-link>
      </q-card-section>
    </q-card>
  </q-page>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import LoginService from "src/services/LoginService";

@Component
export default class Login extends Vue{
  username: string = '';
  password: string = '';
  loginService = new LoginService();

  async logInto() {
    const logged = await this.loginService.login(this.username, this.password);

    if (logged) {
      this.$router.push('/');
    }
  }
}
</script>
