<template>
  <header>
    <div class="header-wrap">
      <div class="flex justify-between align-center header">
        <div class="logo">
          <router-link :to="{ path: this.$filters.ctxPath('/') }">
            <img src="../../resources/img/logo-color.png" alt="홈" />
          </router-link>

        </div>
        <div v-show="pageRole === 'potal'" class="mobile-menu mr10">
          <!-- <p class="white detail-text">문의전화</p> -->
          <p>☎ 054)639-6161~3</p>
        </div>
        <UserMenu />
        <div class="user-info ">
          <div v-if="mbrId" class="flex align-center">
            <button class="user-name cursor" @click="fnLink">
              {{ mbrNm }}님
            </button>
            <button class="logout-btn" @click="fnlogOut">로그아웃</button>
          </div>
          <div v-else class="flex align-center">
            <button class="login-btn" @click="fnlogin">로그인</button>
          </div>
        </div>
        <!-- <div class="flex justify-end align-center user-info-wrap">

          <div class="user-info pc-menu">
            <div class="flex align-center">
              <button class="user-name cursor" @click="fnLink">
                {{ mbrNm }}님
              </button>
              <button class="logout-btn" @click="fnlogOut">로그아웃</button>
            </div>
          </div>
        </div>
        <div v-show="pageRole === 'potal'" class="pc-menu">
          <p>
            ☎ 054)639-6161~3
          </p>
        </div> -->
      </div>
    </div>
  </header>
</template>

<script>
import UserMenu from "./UserMenu.vue";
import { mapActions } from "vuex";

export default {
  props: {},
  components: {
    UserMenu: UserMenu,
  },
  data() {
    return {
      mbrId: this.$store.state.mbrId,
      mbrNm: this.$store.state.mbrNm,
      pageRole: this.$store.state.userType,
    };
  },
  created() {
  },
  methods: {
    ...mapActions(["logout"]),
    // 로그아웃
    async fnlogOut() {
      await this.logout();
    },

    // 로그인
    fnlogin() {
      this.$router.push({
        path: this.$filters.ctxPath("/login.page"),
      })
    },

    // 사용자 정보 보기로 이동
    fnLink() {
      this.$router.push({
        path: this.$filters.ctxPath("/portal/myInfo/view.page"),
      });
    },
  },
};
</script>