<template>
  <header
    :class="
      pageRole === 'company' && $route.path === '/company/main.page'
        ? 'company-header'
        : ''
    "
  >
    <div class="header-wrap">
      <div class="flex justify-between align-center header">
        <div class="logo">
          <router-link
            :to="{ path: '/company/main.page' }"
            v-if="pageRole === 'company'"
          >
            <img
              src="/client/resources/img/logo_w.png"
              alt=""
              v-if="$route.path === '/company/main.page'"
            />
            <img src="/client/resources/img/logo.png" alt="" v-else />
          </router-link>
          <router-link :to="{ path: '/government/main.page' }" v-else>
            <img src="/client/resources/img/logo.png" alt="" />
          </router-link>
        </div>
        <div v-show="pageRole === 'company'" class="mobile-menu mr10">
            <!-- <p class="white detail-text">문의전화</p> -->
            <p
              :class="
                pageRole === 'company' &&
                $route.path === '/company/main.page'
                  ? 'call white'
                  : 'call green'
              "
            >
              ☎ 054)639-6161~3
            </p>
          </div>
          <div
            class="user-info mobile-menu"
            v-if="this.$store.state.userType === 'government'"
          >
            <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"
            v-if="this.$store.state.userType === 'government'"
          >
            <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
            :class="
              pageRole === 'company' &&
              $route.path === '/company/main.page'
                ? 'call white'
                : 'call green'
            "
          >
            ☎ 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>