<template>
  <div class="h-6" />
  <el-menu
    :default-active="activeIndex2"
    class="el-menu-demo"
    mode="horizontal"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    @select="handleSelect"
  >

    <el-menu-item index="1" v-on:click="redirect('/login-main-page')">Main</el-menu-item>
    <el-menu-item index="2" v-on:click="redirect('/offer-page')">Offer Page</el-menu-item>
    <el-menu-item index="3" v-on:click="redirect('/wishlist-page')">Wish List</el-menu-item>
    <el-menu-item index="4" v-on:click="redirect('/flight')">Flight Ticket</el-menu-item>
    <el-menu-item index="5" v-on:click="redirect('/profile')">Profile</el-menu-item>
    <notification></notification>
    <el-menu-item index="6" class="dock-right" @click="hanldeLogOut()">Log Out</el-menu-item>
  </el-menu>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { mapActions, mapGetters } from "vuex";
import Notification from "@/components/Notification.vue";
import { OfferNotification } from "@/models/OfferNotification";
export default defineComponent({
  components: { Notification },
  props: ["offers"],
  data() {
    return {
      hasToken: document.cookie.length > 0
    };
  },
  name: "LoginMainPage",
  methods: {
    redirect(url: string) {
      this.$router.push(url);
    },
    ...mapActions("auth", {
      logOut: "logOutApi",
    }),
    hanldeLogOut() {
      this.logOut()
      document.cookie = 'userId=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
      document.cookie = 'token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
      this.$router.push("/");
    },
  },
});
</script>

<style scoped>
.el-menu-demo > .el-menu-item.dock-right {
  margin-left: auto;
}
</style>