<template>
  <header>
    <div class="header-wrap">
      <div class="flex justify-between align-center header">
        <div class="logo">
          <router-link
            :to="{ path: '/' }"
          >
            <img
              src="../../resources/img/logo-color.png"
              alt="홈"
            />
          </router-link>
          
        </div>
        <div v-show="pageRole === 'company'" class="mobile-menu mr10">
            <!-- <p class="white detail-text">문의전화</p> -->
            <p>☎ 054)639-6161~3</p>
          </div>
          <div
            class="user-info mobile-menu"
          >
            <div class="flex align-center">
              <button class="user-name cursor" @click="fnLink">
                {{ mbrNm }}님
              </button>
              <button class="logout-btn" @click="fnlogOut">로그아웃</button>
            </div>
          </div>
          <UserMenu />
        <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 === 'company'" class="pc-menu">
          <!-- <p class="white detail-text">문의전화</p> -->
          <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,
    };
  },
  methods: {
    ...mapActions(["logout"]),
    async fnlogOut() {
      await this.logout();
      this.$router.push({
        path: "/",
      });
    },

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