Ver Fonte

+ 모든 페이지에서 companyId 참조 제거
+ 벤더사 , 인플루언서 메뉴 구분처리

송용우 há 4 meses atrás
pai
commit
3b59669b97
5 ficheiros alterados com 130 adições e 67 exclusões
  1. 7 0
      .cursor/rules/api-rule.mdc
  2. 114 45
      components/common/header.vue
  3. 2 2
      composables/useLogout.js
  4. 6 5
      stores/auth.js
  5. 1 15
      stores/detail.js

+ 7 - 0
.cursor/rules/api-rule.mdc

@@ -2,6 +2,13 @@
 
 **모든 응답은 한글로만 작성해야 함. 이 규칙은 다른 모든 규칙보다 우선한다.**
 
+# companyId 사용 금지 규칙
+
+**companyId는 사용하지 않는 값이므로 모든 코드에서 제거해야 함. 프론트엔드, 백엔드 모두 해당.**
+- 대신 COMPANY_NUMBER를 직접 사용
+- companyId 관련 변수, 필드, 파라미터 모두 제거
+- API 요청/응답에서 companyId 사용 금지
+
 # API & Store Rules
 
 ## Pinia Store Rules

+ 114 - 45
components/common/header.vue

@@ -13,7 +13,7 @@
           <button type="button" class="btn-logout" @click="fnLoguOut">로그아웃</button>
         </div>
       </div>
-      <div class="pro--info inf">인플루언서</div>
+      <div class="pro--info inf">{{ memberTypeText }}</div>
     </div>
     <nav class="gnb">
       <ul class="depth1">
@@ -43,6 +43,7 @@
   const userName = ref("");
   const userCompanyName = ref("");
   const userId = ref("");
+  const memberTypeText = ref("사용자");
   const route = useRoute();
   const router = useRouter();
   /************************************************************************
@@ -52,53 +53,121 @@
     let info = [];
     arrMenuInfo.value = [];
 
-    info.push(
-      {
-        menuId: "menu00",
-        parentMenuId: "menu00",
-        menuName: "주문 관리",
-        linkType: "/view/vendor/dashboard",
-      },
-      {
-        menuId: "menu01",
-        parentMenuId: "menu01",
-        menuName: "제품 관리",
-        linkType: "/view/common/item",
-      },
-      {
-        menuId: "menu02",
-        parentMenuId: "menu02",
-        menuName: "배송 관리",
-        linkType: "/view/common/deli",
-      },
-      {
-        menuId: "menu03",
-        parentMenuId: "menu03",
-        menuName: "벤더 관리",
-        linkType: "/view/vendor",
-      },
-      {
-        menuId: "menu04",
-        parentMenuId: "menu04",
-        menuName: "정산 관리",
-        linkType: "/view/common/settle",
-      },
-      {
-        menuId: "menu05",
-        parentMenuId: "menu05",
-        menuName: "고객센터",
-        linkType: "/view/common/cs",
+    // 사용자 타입 확인 (memberType으로 구분)
+    const snsUser = useStoreAuth.getSnsTempData?.user;
+    const authUser = JSON.parse(localStorage.getItem("authStore"))?.auth;
+    const currentUser = snsUser || authUser;
+    let memberType = currentUser?.memberType || currentUser?.MEMBER_TYPE;
+
+    // memberType이 없으면 URL로 판단
+    if (!memberType) {
+      const currentPath = route.path;
+      const companyNumber = currentUser?.COMPANY_NUMBER;
+
+      // 벤더 대시보드 경로이거나 COMPANY_NUMBER가 있으면 벤더사로 판단
+      if (currentPath.includes("/vendor/dashboard") || companyNumber) {
+        memberType = "VENDOR";
+      } else {
+        memberType = "INFLUENCER";
       }
-      // {
-      //   menuId: "menu06",
-      //   parentMenuId: "menu06",
-      //   menuName: "AI 채팅",
-      //   linkType: "/view/chat",
-      // }
-    );
+    }
+
+    console.log("=== 헤더 메뉴 디버깅 ===");
+    console.log("SNS 사용자:", snsUser);
+    console.log("Auth 사용자:", authUser);
+    console.log("현재 사용자:", currentUser);
+    console.log("원본 memberType:", currentUser?.memberType);
+    console.log("원본 MEMBER_TYPE:", currentUser?.MEMBER_TYPE);
+    console.log("최종 memberType:", memberType);
+    console.log("현재 경로:", route.path);
+    console.log("COMPANY_NUMBER:", currentUser?.COMPANY_NUMBER);
+
+    if (memberType === "VENDOR") {
+      // 벤더사 메뉴
+      memberTypeText.value = "벤더사";
+      info.push(
+        {
+          menuId: "menu00",
+          parentMenuId: "menu00",
+          menuName: "주문 관리",
+          linkType: "/view/vendor/dashboard",
+        },
+        {
+          menuId: "menu01",
+          parentMenuId: "menu01",
+          menuName: "제품 관리",
+          linkType: "/view/common/item",
+        },
+        {
+          menuId: "menu02",
+          parentMenuId: "menu02",
+          menuName: "배송 관리",
+          linkType: "/view/common/deli",
+        },
+        {
+          menuId: "menu03",
+          parentMenuId: "menu03",
+          menuName: "인플루언서 관리",
+          linkType: "/view/vendor/dashboard/influencer-requests",
+        },
+        {
+          menuId: "menu04",
+          parentMenuId: "menu04",
+          menuName: "정산 관리",
+          linkType: "/view/common/settle",
+        },
+        {
+          menuId: "menu05",
+          parentMenuId: "menu05",
+          menuName: "고객센터",
+          linkType: "/view/common/cs",
+        }
+      );
+    } else {
+      // 인플루언서 메뉴
+      memberTypeText.value = "인플루언서";
+      info.push(
+        {
+          menuId: "menu00",
+          parentMenuId: "menu00",
+          menuName: "주문 관리",
+          linkType: "/view/vendor/dashboard",
+        },
+        {
+          menuId: "menu01",
+          parentMenuId: "menu01",
+          menuName: "제품 관리",
+          linkType: "/view/common/item",
+        },
+        {
+          menuId: "menu02",
+          parentMenuId: "menu02",
+          menuName: "배송 관리",
+          linkType: "/view/common/deli",
+        },
+        {
+          menuId: "menu03",
+          parentMenuId: "menu03",
+          menuName: "벤더 관리",
+          linkType: "/view/vendor/search",
+        },
+        {
+          menuId: "menu04",
+          parentMenuId: "menu04",
+          menuName: "정산 관리",
+          linkType: "/view/common/settle",
+        },
+        {
+          menuId: "menu05",
+          parentMenuId: "menu05",
+          menuName: "고객센터",
+          linkType: "/view/common/cs",
+        }
+      );
+    }
 
     arrMenuInfo.value = info;
-    $log.debug("[header][fnSetMenu][success]");
+    $log.debug("[header][fnSetMenu][success] - MEMBER_TYPE:", memberType);
   };
 
   const menuAction = (__MENUID, _MENUROOTNAME, __URL) => {

+ 2 - 2
composables/useLogout.js

@@ -22,8 +22,8 @@ export const useLogout = () => {
       case 'INFLUENCER':
         return 'influence'
       default:
-        // 3. 마지막으로 companyId 존재 여부로 판단
-        return authStore.auth.companyId ? 'vendor' : 'influence'
+        // 3. 기본값은 인플루언서
+        return 'influence'
     }
   }
 

+ 6 - 5
stores/auth.js

@@ -6,14 +6,13 @@ export const useAuthStore = defineStore('authStore', () => {
     email: '',        // 이메일
     companyName: '',  // 회사명
     phone: '',      // 전화번호
-    companyId: '',        // 아이디
+    memberType: '',   // 사용자 타입 (VENDOR, INFLUENCER)
     accessToken: '',      // 토큰
     refreshToken: '',     // 갱신토큰   
     snsTempData : '', // sns 임시데이터
   })
 
   // 전체 조회
-  const getCompanyId = computed(() => auth.value.companyId)             // 아이디 조회
   const getSeq = computed(() => auth.value.seq)             // 시퀀스 조회
   const getUserId = computed(() => auth.value.id)             // 아이디 조회
   const getUserName = computed(() => auth.value.name)             // 이름 조회
@@ -25,13 +24,16 @@ export const useAuthStore = defineStore('authStore', () => {
   const getSnsTempData = computed(() => auth.value.snsTempData)       // sns 임시데이터 조회
 
   function setAuth(payload){
-    auth.value.companyId = payload.user.COMPANY_NUMBER || ''
     auth.value.seq = payload.user.SEQ
     auth.value.id = payload.user.ID
     auth.value.name = payload.user.NAME
     auth.value.email = payload.user.EMAIL
     auth.value.companyName = payload.user.companyName || payload.user.COMPANY_NAME || ''
     auth.value.phone = payload.user.PHONE
+    
+    // 사용자 타입 설정 (COMPANY_NUMBER가 있으면 벤더사, 없으면 인플루언서)
+    auth.value.memberType = (payload.user.COMPANY_NUMBER) ? 'VENDOR' : 'INFLUENCER'
+    
     auth.value.accessToken = payload.accessToken
     auth.value.refreshToken = payload.refreshToken        
   }
@@ -58,7 +60,7 @@ export const useAuthStore = defineStore('authStore', () => {
       email: '',
       companyName: '',
       phone: '',
-      companyId: '',
+      memberType: '',
       accessToken: '',
       refreshToken: '',
       snsTempData: ''
@@ -67,7 +69,6 @@ export const useAuthStore = defineStore('authStore', () => {
 
   return { 
     auth, 
-    getCompanyId, 
     getSnsTempData, 
     getAccessToken, 
     getRefreshToken, 

+ 1 - 15
stores/detail.js

@@ -1,5 +1,4 @@
 export const useDetailStore = defineStore('detailStore', () => {
-  const companyId = ref('')
   const menuInfo = ref({
     menuIndex : '0',
     menuId : 'menu02',
@@ -7,9 +6,6 @@ export const useDetailStore = defineStore('detailStore', () => {
     pageStatus : '0',
   })
 
-  
-  
-
   const boardInfo = ref({
     seq : '',
     pageType : '',
@@ -21,17 +17,7 @@ export const useDetailStore = defineStore('detailStore', () => {
     pageType : ''
   })
 
-
-  const getCompanyId = computed(()=>companyId.value)  
-
-
-
-  function setAccountId(payload){
-    getCompanyId.value = payload
-  }
-
   function reset() {
-    companyId.value = ''
     menuInfo.value = {
       menuIndex : '0',
       menuId : 'menu02',
@@ -49,5 +35,5 @@ export const useDetailStore = defineStore('detailStore', () => {
     }
   }
 
-  return {companyId, getCompanyId, menuInfo, boardInfo, setAccountId, adminInfo, reset}
+  return {menuInfo, boardInfo, adminInfo, reset}
 }, {persist: { storage: persistedState.sessionStorage,}})