Skip to content
Snippets Groups Projects
AppHeader.vue 2.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • Zhengbo Wang's avatar
    Zhengbo Wang committed
    <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"
      >
    
    zhengbo's avatar
    zhengbo committed
        <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
        >
    
    zhengbo's avatar
    zhengbo committed
        <el-dropdown
          class="notification"
          v-show="this.$route.name === 'LoginMainPage'"
        >
          <el-button type="primary">
            <font-awesome-icon icon="fa-solid fa-envelope" />
            Notification<el-icon class="el-icon--right"><arrow-down /></el-icon>
          </el-button>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item v-for="offer in offers" :key="offer.offerId">
                <router-link
                  :to="
                    '/matched-result/' + offer.offerId + '/' + offer.wishlistItemId
                  "
                >
                  You have a offer matched (click to check details)
                </router-link>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
    
    zhengbo's avatar
    zhengbo committed
        <el-menu-item index="5" class="dock-right" @click="hanldeLogOut()"
          >Log Out</el-menu-item
        >
    
      </el-menu>
    
    Zhengbo Wang's avatar
    Zhengbo Wang committed
    </template>
    
    
    Bart Chou's avatar
    Bart Chou committed
    <script lang="ts">
    import { defineComponent } from "vue";
    import { mapActions, mapGetters } from "vuex";
    
    zhengbo's avatar
    zhengbo committed
    import { OfferNotification } from "@/models/OfferNotification";
    
    Bart Chou's avatar
    Bart Chou committed
    export default defineComponent({
    
    zhengbo's avatar
    zhengbo committed
      props: ["offers"],
    
    Bart Chou's avatar
    Bart Chou committed
      data() {
        return {};
      },
    
    fz2907's avatar
    fz2907 committed
      name: "LoginMainPage",
    
    Bart Chou's avatar
    Bart Chou committed
      methods: {
    
    fz2907's avatar
    fz2907 committed
        redirect(url: string) {
    
    Bart Chou's avatar
    Bart Chou committed
        ...mapActions("auth", {
          logOut: "logOutApi",
        }),
        hanldeLogOut() {
    
    zhengbo's avatar
    zhengbo committed
          this.logOut();
          document.cookie =
            "userId=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";
    
    Bart Chou's avatar
    Bart Chou committed
          this.$router.push("/");
    
    fz2907's avatar
    fz2907 committed
      },
    });
    
    Bart Chou's avatar
    Bart Chou committed
    </script>
    
    <style scoped>
    .el-menu-demo > .el-menu-item.dock-right {
    
    zhengbo's avatar
    zhengbo committed
      margin-left: auto;
    
    Bart Chou's avatar
    Bart Chou committed
    }
    
    zhengbo's avatar
    zhengbo committed
    .notification {
      margin: auto;
      justify-content: space-between;
    }
    .example-showcase .el-dropdown + .el-dropdown {
      margin-left: 15px;
    }
    .example-showcase .el-dropdown-link {
      cursor: pointer;
      color: var(--el-color-primary);
      display: flex;
      align-items: center;
    }
    
    Bart Chou's avatar
    Bart Chou committed
    </style>