<template>
  <main class="landing-page">
    <div class="container-fluid main-wrp">
      <nav class="navbar navbar-expand-sm spotLight-nav">
        <a class="navbar-brand" href="#"
          ><img src="../assets/images/logo.png"
        /></a>
        <button
          class="navbar-toggler"
          type="button"
          data-toggle="collapse"
          data-target="#navbarsExample03"
          aria-controls="navbarsExample03"
          aria-expanded="false"
          aria-label="Toggle navigation"
        >
          <span class="navbar-toggler-icon"></span>
          <span class="navbar-toggler-icon"></span>
          <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarsExample03">
          <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
              <a class="nav-link" href="#">About</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Masterclass</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Stories</a>
            </li>
            <li class="nav-item spotLight-img">
              <a class="nav-link" href="#"
                ><img src="../assets/images/SPOTLight.svg"
              /></a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Library</a>
            </li>
          </ul>
        </div>
      </nav>
      <!-- menu wrapper -->
         <div class="sign-wrp">
      <div class="row col-reverse">
        <div class="col-sm-3 col-md-1 col-lg-1 col-xl-3"></div>
        <!-- users land image -->
        <div class="col-sm-5 col-md-6 col-lg-7 col-xl-4 wc-spc-lf-tp">
          <h1 class="welcome-hd-back">
            Welcome <br />
            back
          </h1>
        </div>
        <!-- users land image -->
        <div class="col-sm-4 col-md-4 col-lg-4 col-xl-4">
          <div class="form-layout signup-frm-spc">
            <form>
              <h5> LogIn with email</h5>
              <div class="fill-form">
                <label for="inputEmail" class="sr-only">Email address</label>
                <input
                  type="email"
                  id="inputEmail"
                  class="form-control"
                  placeholder="Your Email ID"
                  v-model="userData.email"
                />
                <label for="inputPassword" class="sr-only">Password</label>
                <input
                  type="password"
                  id="inputPassword"
                  class="form-control"
                  placeholder="Password"
                  v-model="userData.password"
                />

                <a href="javascript:void(0);" class="btn btn-lg sb-button" type="submit" @click="loginWIthEmail">
                  <img src="../assets/images/key.svg" /> Log In to your account
                </a>
              </div>
            </form>
          </div>
        </div>
        <!-- sign up -->
      </div>  </div>
      <!-- body wrapper -->
    </div>
  </main>
</template>

<script>

import Vue from "vue";
import router from "../router";
import $ from "jquery";
import axios from "axios";

export default {
  name: "LandingPage",

  data() {
    return {
      loggedinFlag: false,
      userData:{},
    };
  },
   mounted() {
    localStorage.removeItem("spotlight_usertoken");
    localStorage.removeItem("spotlight_email");
  },
  methods: {
     loginWIthEmail(){
         axios
        .post("/superAdmin/login", this.userData)
        .then((response) => {
           console.log("login- response",response)
           this.$toaster.success(response.data.message)
            if(response.data.status == 'success'){
                localStorage.setItem('spotlight_usertoken', JSON.stringify(response.data.data))
                this.$router.push("/profile");
            }
        })
        .catch( (error) =>{
          if (error.response) {
            this.$toaster.error(error.response.data.message)
            if(error.response.data.message == 'Email Not Verified'){
               localStorage.setItem('spotlight_email', this.userData.email);
                this.$router.push({ name: 'Otp', params: { flag: true }});
            }
          }
        });
    }
  },
};
</script>
<style>
.light-font-weight {
  font-weight: 400 !important;
}


</style>
