diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index bcc6ddc6..cbeceb2c 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -71,6 +71,8 @@ import { sendLogTotalRecommend } from "../actions/logActions"; // } from "../utils/focus-monitor"; // import { PanelHoc } from "../components/TPanel/TPanel"; + + let foreGroundChangeTimer = null; // 기존 콘솔 메서드를 백업 @@ -147,15 +149,15 @@ function AppBase(props) { (state) => state.common.appStatus.cursorVisible ); const introTermsAgree = useSelector((state) => state.common.introTermsAgree); - const deviceRegistered = useSelector( - (state) => state.common.deviceRegistered - ); + const deviceRegistered = useSelector((state) => state.common.deviceRegistered); // const optionalTermsAgree = useSelector((state) => state.common.optionalTermsAgree); const termsLoading = useSelector((state) => state.common.termsLoading); // termsFlag 전체 상태 확인 // const termsFlag = useSelector((state) => state.common.termsFlag); const termsData = useSelector((state) => state.home.termsData); + + useEffect(() => { // Chromium68 호환성을 위해 Optional Chaining 제거 if (termsData && termsData.data && termsData.data.terms) { @@ -171,8 +173,7 @@ function AppBase(props) { // const macAddress = useSelector((state) => state.common.macAddress); // Chromium68 호환성을 위해 Optional Chaining 제거 - const deviceCountryCode = - (httpHeader && httpHeader["X-Device-Country"]) || ""; + const deviceCountryCode = httpHeader && httpHeader["X-Device-Country"] || ""; useEffect(() => { if (!cursorVisible && !Spotlight.getCurrent()) { @@ -219,67 +220,32 @@ function AppBase(props) { // }, [dispatch]); // called by [receive httpHeader, launch, relaunch] - const initService = useCallback( + (haveyInit = true) => { + // console.log( // "<<<<<<<<<<<<< appinfo >>>>>>>>>>>>{heavyInit, appinfo} ", // haveyInit, // appinfo // ); - console.log("[DEBUG] httpHeaderRef.current:", httpHeaderRef.current); - console.log("[DEBUG] httpHeader state:", httpHeader); console.log( "[App.js] initService,httpHeaderRef.current", httpHeaderRef.current ); console.log("[App.js] haveyInit", haveyInit); - // 🔍 DEEPLINK DEBUG: HTTP Header 상태 상세 확인 - console.log("🔍 [DEEPLINK DEBUG] ===== HTTP Header 상태 ====="); - console.log( - "🔍 [DEEPLINK DEBUG] httpHeaderRef.current:", - httpHeaderRef.current - ); - console.log("🔍 [DEEPLINK DEBUG] httpHeader state:", httpHeader); - console.log("🔍 [DEEPLINK DEBUG] deviceCountryCode:", deviceCountryCode); - console.log( - "🔍 [DEEPLINK DEBUG] httpHeader null 여부:", - httpHeaderRef.current === null - ); - - if (httpHeaderRef.current) { - console.log( - "🔍 [DEEPLINK DEBUG] ✅ httpHeaderRef.current 존재 - 딥링크 실행 가능" - ); - console.log( - "🔍 [DEEPLINK DEBUG] Country Code:", - httpHeaderRef.current["X-Device-Country"] - ); - console.log( - "🔍 [DEEPLINK DEBUG] Language Code:", - httpHeaderRef.current["X-Device-Language"] - ); - } else { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ httpHeaderRef.current가 null - 딥링크 실행 불가" - ); - } - if (httpHeaderRef.current) { if (haveyInit) { dispatch(changeAppStatus({ connectionFailed: false })); if (typeof window === "object" && window.PalmSystem) { - dispatch( - changeAppStatus({ - // Chromium68 호환성을 위해 Optional Chaining 제거 - cursorVisible: - window.PalmSystem && - window.PalmSystem.cursor && - window.PalmSystem.cursor.visibility, - }) - ); + dispatch( + changeAppStatus({ + // Chromium68 호환성을 위해 Optional Chaining 제거 + cursorVisible: window.PalmSystem && window.PalmSystem.cursor && window.PalmSystem.cursor.visibility, + }) + ); } dispatch(getHomeMenu()); dispatch(getMyRecommandedKeyword()); @@ -294,38 +260,14 @@ function AppBase(props) { JSON.stringify(launchParams) ); - // 🔍 DEEPLINK DEBUG: Launch Parameters 상세 확인 - console.log("🔍 [DEEPLINK DEBUG] ===== Launch Parameters 상태 ====="); - console.log("🔍 [DEEPLINK DEBUG] launchParams:", launchParams); - console.log( - "🔍 [DEEPLINK DEBUG] contentTarget:", - launchParams?.contentTarget - ); - console.log("🔍 [DEEPLINK DEBUG] bypass:", launchParams?.bypass); - console.log( - "🔍 [DEEPLINK DEBUG] contentTarget 존재 여부:", - !!launchParams?.contentTarget - ); - // pyh TODO: edit or delete later (line 196 ~ 198) // Chromium68 호환성을 위해 Optional Chaining 제거 if (launchParams && launchParams.bypass) { - console.log( - "🔍 [DEEPLINK DEBUG] ✅ Bypass 링크 실행:", - launchParams.bypass - ); dispatch(handleBypassLink(launchParams.bypass)); } if (launchParams && launchParams.contentTarget) { - console.log( - "🔍 [DEEPLINK DEBUG] ✅ 딥링크 실행:", - launchParams.contentTarget - ); dispatch(handleDeepLink(launchParams.contentTarget)); } else { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ contentTarget 없음 - 딥링크 실행하지 않음" - ); dispatch( sendLogTotalRecommend({ contextName: Config.LOG_CONTEXT_NAME.ENTRY, @@ -369,15 +311,11 @@ function AppBase(props) { // set foreground flag using delay time. clearTimeout(foreGroundChangeTimer); foreGroundChangeTimer = setTimeout(() => { - console.log( - "visibility changed !!! ==> set to foreground cursorVisible", - // Chromium68 호환성을 위해 Optional Chaining 제거 - JSON.stringify( - window.PalmSystem && - window.PalmSystem.cursor && - window.PalmSystem.cursor.visibility - ) - ); // eslint-disable-line no-console + console.log( + "visibility changed !!! ==> set to foreground cursorVisible", + // Chromium68 호환성을 위해 Optional Chaining 제거 + JSON.stringify(window.PalmSystem && window.PalmSystem.cursor && window.PalmSystem.cursor.visibility) + ); // eslint-disable-line no-console if (platform.platformName !== "webos") { //for debug dispatch( @@ -391,10 +329,7 @@ function AppBase(props) { changeAppStatus({ isAppForeground: true, // Chromium68 호환성을 위해 Optional Chaining 제거 - cursorVisible: - window.PalmSystem && - window.PalmSystem.cursor && - window.PalmSystem.cursor.visibility, + cursorVisible: window.PalmSystem && window.PalmSystem.cursor && window.PalmSystem.cursor.visibility, }) ); } @@ -523,7 +458,6 @@ function AppBase(props) { ? launchParmas.contentTarget.split("_")[1] || "" : "1000"; - console.log("###launchParmas.contentTarget", launchParmas.contentTarget); if (launchParmas.contentTarget) { dispatch( setDeepLink({ diff --git a/com.twin.app.shoptime/src/App/deepLinkHandler.js b/com.twin.app.shoptime/src/App/deepLinkHandler.js index d1bfcecb..8c7eaa94 100644 --- a/com.twin.app.shoptime/src/App/deepLinkHandler.js +++ b/com.twin.app.shoptime/src/App/deepLinkHandler.js @@ -13,16 +13,6 @@ import { sendLogTotalRecommend } from "../actions/logActions"; //V2_진입경로코드_진입경로명_MT_노출순번 export const handleDeepLink = (contentTarget) => (dispatch, getState) => { console.log("[handleDeepLink] ~ contentTarget: ", contentTarget); - - // 🔍 DEEPLINK DEBUG: 딥링크 핸들러 시작 - console.log("🔍 [DEEPLINK DEBUG] ===== handleDeepLink 실행 ====="); - console.log("🔍 [DEEPLINK DEBUG] contentTarget:", contentTarget); - console.log("🔍 [DEEPLINK DEBUG] contentTarget 타입:", typeof contentTarget); - console.log( - "🔍 [DEEPLINK DEBUG] contentTarget null/undefined 여부:", - contentTarget === null || contentTarget === undefined - ); - let linkTpCd; // 진입경로코드 let linkTpNm; // 진입경로명 let type; // 링크 타입 @@ -39,22 +29,11 @@ export const handleDeepLink = (contentTarget) => (dispatch, getState) => { let tabType; // 카테고리 탭명 if (contentTarget === null || contentTarget === undefined) { - console.log( - "🔍 [DEEPLINK DEBUG] ⚠️ contentTarget이 null/undefined - 기본값 설정" - ); linkTpCd = "1000"; linkTpNm = LOG_MENU.APP; } else { - console.log("🔍 [DEEPLINK DEBUG] ✅ contentTarget 존재 - 파싱 시작"); const tokens = contentTarget.split("_"); - console.log("🔍 [DEEPLINK DEBUG] 토큰 분리 결과:", tokens); - console.log("🔍 [DEEPLINK DEBUG] 버전:", tokens[0]); - console.log("🔍 [DEEPLINK DEBUG] 진입경로코드:", tokens[1]); - console.log("🔍 [DEEPLINK DEBUG] 진입경로명:", tokens[2]); - console.log("🔍 [DEEPLINK DEBUG] 타입:", tokens[3]); - if (tokens[0] === "V2" || tokens[0] === "V3") { - console.log("🔍 [DEEPLINK DEBUG] ✅ 유효한 딥링크 버전:", tokens[0]); linkTpCd = tokens[1]; linkTpNm = tokens[2]; type = tokens[3]; @@ -64,34 +43,19 @@ export const handleDeepLink = (contentTarget) => (dispatch, getState) => { let panelInfo = {}; if (tokens[0] === "V2") { - console.log( - "🔍 [DEEPLINK DEBUG] ⚠️ V2 버전 - HOME_PANEL로 이동 후 종료" - ); panelName = panel_names.HOME_PANEL; return; } - console.log("🔍 [DEEPLINK DEBUG] V3 버전 - 타입별 처리 시작"); - if (parseInt(linkTpCd) < 2000 || parseInt(linkTpCd) > 8999) { - console.log( - "🔍 [DEEPLINK DEBUG] ⚠️ 유효하지 않은 진입경로코드:", - linkTpCd, - "-> 9999로 변경" - ); linkTpCd = "9999"; linkTpNm = LOG_MENU.UNKNOWN; } - console.log("🔍 [DEEPLINK DEBUG] 최종 linkTpCd:", linkTpCd); - console.log("🔍 [DEEPLINK DEBUG] 최종 linkTpNm:", linkTpNm); - console.log("🔍 [DEEPLINK DEBUG] 처리할 타입:", type); - switch (type) { case "MT": // "MT": Main TOP // V3_진입경로코드_진입경로명_MT_노출순번 - console.log("🔍 [DEEPLINK DEBUG] ✅ MT 타입: Main TOP 처리"); panelName = panel_names.HOME_PANEL; deeplinkPanel = "Main TOP"; break; @@ -305,45 +269,17 @@ export const handleDeepLink = (contentTarget) => (dispatch, getState) => { }) ); - // 🔍 DEEPLINK DEBUG: 패널 이동 처리 - console.log("🔍 [DEEPLINK DEBUG] ===== 패널 이동 처리 ====="); - console.log("🔍 [DEEPLINK DEBUG] panelName:", panelName); - console.log("🔍 [DEEPLINK DEBUG] deeplinkPanel:", deeplinkPanel); - console.log("🔍 [DEEPLINK DEBUG] panelInfo:", panelInfo); - if (panelName) { - console.log("🔍 [DEEPLINK DEBUG] ✅ 패널 이동 실행"); const action = panelName === panel_names.HOME_PANEL ? updateHomeInfo : pushPanel; - console.log( - "🔍 [DEEPLINK DEBUG] 사용할 액션:", - panelName === panel_names.HOME_PANEL ? "updateHomeInfo" : "pushPanel" - ); - console.log("🔍 [DEEPLINK DEBUG] 최종 액션 파라미터:", { - name: panelName, - panelInfo: { ...panelInfo, linkTpCd }, - }); - dispatch( action({ name: panelName, panelInfo: { ...panelInfo, linkTpCd }, }) ); - console.log("🔍 [DEEPLINK DEBUG] ✅ 패널 이동 디스패치 완료"); - } else { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ panelName이 없음 - 패널 이동하지 않음" - ); } - } else { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ 유효하지 않은 딥링크 버전:", - tokens[0] - ); } } - - console.log("🔍 [DEEPLINK DEBUG] ===== handleDeepLink 종료 ====="); }; diff --git a/com.twin.app.shoptime/src/actions/commonActions.js b/com.twin.app.shoptime/src/actions/commonActions.js index 8d70ba65..84f1f9b1 100644 --- a/com.twin.app.shoptime/src/actions/commonActions.js +++ b/com.twin.app.shoptime/src/actions/commonActions.js @@ -32,7 +32,7 @@ export const gnbOpened = (status) => ({ }); export const setShowPopup = (config) => { - const payload = typeof config === "string" ? { activePopup: config } : config; + const payload = typeof config === 'string' ? { activePopup: config } : config; return { type: types.SET_SHOW_POPUP, payload, @@ -193,80 +193,44 @@ export const getHttpHeaderForServiceRequest = convertedRes["os_ver"] = version; convertedRes["dvc_auth"] = res["X-Authentication"]; - // 🔍 DEEPLINK DEBUG: 국가 코드 설정 상세 확인 - console.log("🔍 [DEEPLINK DEBUG] ===== 국가 코드 설정 ====="); - console.log("🔍 [DEEPLINK DEBUG] serverType:", serverType); - console.log("🔍 [DEEPLINK DEBUG] ricCodeSetting:", ricCodeSetting); - console.log("🔍 [DEEPLINK DEBUG] languageSetting:", languageSetting); - console.log( - "🔍 [DEEPLINK DEBUG] 원본 X-Device-Country:", - res["X-Device-Country"] - ); - if (serverType !== "system") { if (ricCodeSetting === "eic") { - console.log("🔍 [DEEPLINK DEBUG] EIC 지역 설정 중..."); if (languageSetting === "GB") { - console.log("🔍 [DEEPLINK DEBUG] ✅ GB 설정 적용"); convertedRes["cntry_cd"] = "GB"; convertedRes["X-Device-Country"] = "GB"; res["HOST"] = "GB.nextlgsdp.com"; } if (languageSetting === "DE") { - console.log("🔍 [DEEPLINK DEBUG] ✅ DE 설정 적용"); convertedRes["cntry_cd"] = "DE"; convertedRes["X-Device-Country"] = "DE"; res["HOST"] = "DE.nextlgsdp.com"; } } if (ricCodeSetting === "aic") { - console.log("🔍 [DEEPLINK DEBUG] ✅ AIC 지역 설정 중... US 적용"); convertedRes["cntry_cd"] = "US"; convertedRes["X-Device-Country"] = "US"; res["HOST"] = "US.nextlgsdp.com"; } if (ricCodeSetting === "ruc") { - console.log("🔍 [DEEPLINK DEBUG] ✅ RUC 지역 설정 중... RU 적용"); convertedRes["cntry_cd"] = "RU"; convertedRes["X-Device-Country"] = "RU"; res["HOST"] = "RU.nextlgsdp.com"; } - } else { - console.log( - "🔍 [DEEPLINK DEBUG] ⚠️ serverType이 system - 국가 설정 변경 안함" - ); } - // 🔍 DEEPLINK DEBUG: 언어 코드 설정 확인 - console.log("🔍 [DEEPLINK DEBUG] ===== 언어 코드 설정 ====="); - console.log( - "🔍 [DEEPLINK DEBUG] 최종 cntry_cd:", - convertedRes["cntry_cd"] - ); - if (convertedRes["cntry_cd"] === "US") { convertedRes["lang_cd"] = "en-US"; - console.log("🔍 [DEEPLINK DEBUG] ✅ US 언어 설정: en-US"); } if (convertedRes["cntry_cd"] === "DE") { convertedRes["lang_cd"] = "de-DE"; - console.log("🔍 [DEEPLINK DEBUG] ✅ DE 언어 설정: de-DE"); } if (convertedRes["cntry_cd"] === "GB") { convertedRes["lang_cd"] = "en-GB"; - console.log("🔍 [DEEPLINK DEBUG] ✅ GB 언어 설정: en-GB"); } if (convertedRes["cntry_cd"] === "RU") { convertedRes["lang_cd"] = "ru-RU"; - console.log("🔍 [DEEPLINK DEBUG] ✅ RU 언어 설정: ru-RU"); } - console.log( - "🔍 [DEEPLINK DEBUG] 최종 lang_cd:", - convertedRes["lang_cd"] - ); - console.log("🔍 [DEEPLINK DEBUG] 최종 HOST:", res["HOST"]); - dispatch({ type: types.GET_HTTP_HEADER, payload: convertedRes }); dispatch( changeAppStatus({ @@ -325,28 +289,25 @@ export const getDeviceId = (onComplete) => (dispatch, getState) => { export const getTermsAgreeYn = () => (dispatch, getState) => { dispatch({ type: types.GET_TERMS_AGREE_YN_START }); - + try { const { terms } = getState().home.termsData.data; - console.log( - "getTermsAgreeYn", - terms.map((term) => ({ - trmsId: term.trmsId, - trmsTpCd: term.trmsTpCd, - trmsAgrFlag: term.trmsAgrFlag, - trmsPopFlag: term.trmsPopFlag, - })) - ); + console.log("getTermsAgreeYn", terms.map(term => ({ + trmsId: term.trmsId, + trmsTpCd: term.trmsTpCd, + trmsAgrFlag: term.trmsAgrFlag, + trmsPopFlag: term.trmsPopFlag, + }))); // MST00405 선택약관 정보만 따로 출력 - const optionalTerm = terms.find((term) => term.trmsTpCd === "MST00405"); + const optionalTerm = terms.find(term => term.trmsTpCd === 'MST00405'); if (optionalTerm) { console.log("getTermsAgreeYn MST00405 선택약관:", { trmsId: optionalTerm.trmsId, trmsTpCd: optionalTerm.trmsTpCd, trmsAgrFlag: optionalTerm.trmsAgrFlag, - trmsPopFlag: optionalTerm.trmsPopFlag, + trmsPopFlag: optionalTerm.trmsPopFlag }); } else { console.log("getTermsAgreeYn MST00405 선택약관을 찾을 수 없습니다."); @@ -373,7 +334,7 @@ export const getTermsAgreeYn = () => (dispatch, getState) => { break; } return acc; - }, {}); + }, {}); dispatch({ type: types.GET_TERMS_AGREE_YN_SUCCESS, @@ -797,37 +758,35 @@ export const resetOptionalTermsSession = () => ({ // 선택약관 동의 처리를 위한 헬퍼 함수 export const handleOptionalTermsAgree = () => (dispatch) => { - console.log("[CommonActions] 선택약관 동의 처리"); - dispatch(setOptionalTermsUserDecision("agreed")); + console.log('[CommonActions] 선택약관 동의 처리'); + dispatch(setOptionalTermsUserDecision('agreed')); dispatch(setOptionalTermsPopupShown(true)); }; // 선택약관 거절 처리를 위한 헬퍼 함수 export const handleOptionalTermsDecline = () => (dispatch) => { - console.log("[CommonActions] 선택약관 거절 처리"); - dispatch(setOptionalTermsUserDecision("declined")); + console.log('[CommonActions] 선택약관 거절 처리'); + dispatch(setOptionalTermsUserDecision('declined')); dispatch(setOptionalTermsPopupShown(true)); }; // 선택약관 상태 통합 업데이트 (TV 환경 최적화 - API 호출 없이 즉시 반영) -export const updateOptionalTermsAgreement = - (agreed = true) => - (dispatch) => { - console.log(`[CommonActions] 선택약관 통합 상태 업데이트: ${agreed}`); - - // 1. optionalTermsPopupFlow 업데이트 (TV 환경용) - dispatch(setOptionalTermsUserDecision(agreed ? "agreed" : "declined")); - dispatch(setOptionalTermsPopupShown(true)); - - // 2. 기본 optionalTermsAgree 상태 직접 업데이트 (API 호출 없이) - dispatch({ - type: types.UPDATE_OPTIONAL_TERMS_AGREE_DIRECT, - payload: agreed, - }); - - // 3. termsAgreementStatus도 동기화 - dispatch({ - type: types.UPDATE_TERMS_AGREEMENT_STATUS_DIRECT, - payload: { MST00405: agreed }, - }); - }; +export const updateOptionalTermsAgreement = (agreed = true) => (dispatch) => { + console.log(`[CommonActions] 선택약관 통합 상태 업데이트: ${agreed}`); + + // 1. optionalTermsPopupFlow 업데이트 (TV 환경용) + dispatch(setOptionalTermsUserDecision(agreed ? 'agreed' : 'declined')); + dispatch(setOptionalTermsPopupShown(true)); + + // 2. 기본 optionalTermsAgree 상태 직접 업데이트 (API 호출 없이) + dispatch({ + type: types.UPDATE_OPTIONAL_TERMS_AGREE_DIRECT, + payload: agreed + }); + + // 3. termsAgreementStatus도 동기화 + dispatch({ + type: types.UPDATE_TERMS_AGREEMENT_STATUS_DIRECT, + payload: { MST00405: agreed } + }); +}; diff --git a/com.twin.app.shoptime/src/api/TAxios.js b/com.twin.app.shoptime/src/api/TAxios.js index 203e8739..f288da42 100644 --- a/com.twin.app.shoptime/src/api/TAxios.js +++ b/com.twin.app.shoptime/src/api/TAxios.js @@ -1,11 +1,11 @@ -import axios from "axios"; +import axios from 'axios'; -import Spotlight from "@enact/spotlight"; -import { useDispatch } from "react-redux"; -import { useState } from "react"; -import { fetchCurrentUserHomeTermsSafe } from "../actions/homeActions"; +import Spotlight from '@enact/spotlight'; +import { useDispatch } from 'react-redux'; +import { useState } from 'react'; +import { fetchCurrentUserHomeTermsSafe } from '../actions/homeActions'; -import { types } from "../actions/actionTypes"; +import { types } from '../actions/actionTypes'; import { changeAppStatus, changeLocalSettings, @@ -13,16 +13,22 @@ import { setSystemNotice, setSystemTermination, showError, -} from "../actions/commonActions"; +} from '../actions/commonActions'; import { getAuthenticationCode, getReAuthenticationCode, -} from "../actions/deviceActions"; -import { pushPanel, resetPanels } from "../actions/panelActions"; -import * as Config from "../utils/Config"; -import { ACTIVE_POPUP } from "../utils/Config"; -import * as HelperMethods from "../utils/helperMethods"; -import { getUrl, URLS } from "./apiConfig"; +} from '../actions/deviceActions'; +import { + pushPanel, + resetPanels, +} from '../actions/panelActions'; +import * as Config from '../utils/Config'; +import { ACTIVE_POPUP } from '../utils/Config'; +import * as HelperMethods from '../utils/helperMethods'; +import { + getUrl, + URLS, +} from './apiConfig'; let tokenRefreshing = false; const axiosQueue = []; @@ -201,23 +207,8 @@ export const TAxios = ( if (onFail) onFail(res); return; } - // 🔍 DEEPLINK DEBUG: API 에러 코드 확인 - if ( - res?.data?.retCode === 602 || - res?.data?.retCode === 603 || - res?.data?.retCode === 604 - ) { - console.log("🔍 [DEEPLINK DEBUG] ===== API 에러 발생 ====="); - console.log("🔍 [DEEPLINK DEBUG] 에러 코드:", res?.data?.retCode); - console.log("🔍 [DEEPLINK DEBUG] API URL:", url); - console.log("🔍 [DEEPLINK DEBUG] 응답 데이터:", res?.data); - } - // 602 요청 국가 불일치 if (res?.data?.retCode === 602) { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ 602 에러: 요청 국가 불일치 - 국가 변경 팝업 표시" - ); dispatch( setShowPopup(ACTIVE_POPUP.changeCountyPopup, { data: res.data.retCode, @@ -227,9 +218,6 @@ export const TAxios = ( } // 603 서비스 국가 아님 if (res?.data?.retCode === 603) { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ 603 에러: 서비스 지원 안하는 국가 - 지원 안함 팝업 표시" - ); dispatch( setShowPopup(ACTIVE_POPUP.unSupportedCountryPopup, { data: res.data.retCode, @@ -239,9 +227,6 @@ export const TAxios = ( } if (res?.data?.retCode === 604) { - console.log( - "🔍 [DEEPLINK DEBUG] ❌ 604 에러: 서비스 지원 안하는 언어" - ); //todo "NotServiceLanguage" return; } @@ -291,7 +276,7 @@ export const TAxiosPromise = ( success: true, data: response.data, response: response, - error: null, + error: null }); }, // onFail - 에러도 resolve로 처리하여 throw 방지 @@ -301,7 +286,7 @@ export const TAxiosPromise = ( success: false, data: null, response: null, - error: error, + error: error }); }, noTokenRefresh @@ -333,14 +318,10 @@ export const TAxiosAdvancedPromise = ( const attemptRequest = () => { attempts++; - console.log( - `TAxiosPromise attempt ${attempts}/${maxAttempts} for ${baseUrl}` - ); + console.log(`TAxiosPromise attempt ${attempts}/${maxAttempts} for ${baseUrl}`); const timeoutId = setTimeout(() => { - const timeoutError = new Error( - `Request timeout after ${timeout}ms for ${baseUrl}` - ); + const timeoutError = new Error(`Request timeout after ${timeout}ms for ${baseUrl}`); if (throwOnError) { reject(timeoutError); } else { @@ -348,7 +329,7 @@ export const TAxiosAdvancedPromise = ( success: false, data: null, response: null, - error: timeoutError, + error: timeoutError }); } }, timeout); @@ -363,29 +344,22 @@ export const TAxiosAdvancedPromise = ( // onSuccess (response) => { clearTimeout(timeoutId); - console.log( - `TAxiosPromise success on attempt ${attempts} for ${baseUrl}` - ); + console.log(`TAxiosPromise success on attempt ${attempts} for ${baseUrl}`); resolve({ success: true, data: response.data, response: response, - error: null, + error: null }); }, // onFail (error) => { clearTimeout(timeoutId); - console.error( - `TAxiosPromise error on attempt ${attempts} for ${baseUrl}:`, - error - ); - + console.error(`TAxiosPromise error on attempt ${attempts} for ${baseUrl}:`, error); + // 재시도 로직 if (attempts < maxAttempts) { - console.log( - `Retrying in ${retryDelay}ms... (${attempts}/${maxAttempts})` - ); + console.log(`Retrying in ${retryDelay}ms... (${attempts}/${maxAttempts})`); setTimeout(() => { attemptRequest(); }, retryDelay); @@ -398,7 +372,7 @@ export const TAxiosAdvancedPromise = ( success: false, data: null, response: null, - error: error, + error: error }); } } @@ -412,51 +386,23 @@ export const TAxiosAdvancedPromise = ( }; // HTTP 메소드별 편의 함수들 (안전한 버전) -export const TAxiosGet = async ( - dispatch, - getState, - baseUrl, - urlParams = {}, - options = {} -) => { - return await TAxiosPromise( - dispatch, - getState, - "get", - baseUrl, - urlParams, - {}, - options.noTokenRefresh - ); +export const TAxiosGet = async (dispatch, getState, baseUrl, urlParams = {}, options = {}) => { + return await TAxiosPromise(dispatch, getState, 'get', baseUrl, urlParams, {}, options.noTokenRefresh); }; -export const TAxiosPost = async ( - dispatch, - getState, - baseUrl, - params = {}, - options = {} -) => { - return await TAxiosPromise( - dispatch, - getState, - "post", - baseUrl, - {}, - params, - options.noTokenRefresh - ); +export const TAxiosPost = async (dispatch, getState, baseUrl, params = {}, options = {}) => { + return await TAxiosPromise(dispatch, getState, 'post', baseUrl, {}, params, options.noTokenRefresh); }; // 안전한 다중 요청 처리 export const TAxiosAll = async (requests) => { try { const results = await Promise.all(requests); - + // 모든 결과를 안전하게 처리 const successResults = []; const failedResults = []; - + results.forEach((result, index) => { if (result.success) { successResults.push({ index, result: result.data }); @@ -464,20 +410,20 @@ export const TAxiosAll = async (requests) => { failedResults.push({ index, error: result.error }); } }); - + return { success: failedResults.length === 0, successResults, failedResults, - allResults: results, + allResults: results }; } catch (error) { - console.error("TAxiosAll unexpected error:", error); + console.error('TAxiosAll unexpected error:', error); return { success: false, successResults: [], failedResults: [{ index: -1, error }], - allResults: [], + allResults: [] }; } }; @@ -486,7 +432,7 @@ export const TAxiosAll = async (requests) => { export const TAxiosSequential = async (requests) => { const results = []; const errors = []; - + for (let i = 0; i < requests.length; i++) { try { const result = await requests[i]; @@ -498,37 +444,33 @@ export const TAxiosSequential = async (requests) => { } } catch (error) { errors.push({ index: i, error }); - console.error( - `TAxiosSequential unexpected error at request ${i}:`, - error - ); + console.error(`TAxiosSequential unexpected error at request ${i}:`, error); } } - + return { success: errors.length === 0, results, - errors, + errors }; }; // 안전한 Redux Thunk 헬퍼 export const createSafeApiThunk = (apiCall) => { - return (...args) => - async (dispatch, getState) => { - try { - const result = await apiCall(dispatch, getState, ...args); - return result; // 이미 안전한 형태로 반환됨 - } catch (error) { - console.error("API thunk unexpected error:", error); - return { - success: false, - data: null, - response: null, - error, - }; - } - }; + return (...args) => async (dispatch, getState) => { + try { + const result = await apiCall(dispatch, getState, ...args); + return result; // 이미 안전한 형태로 반환됨 + } catch (error) { + console.error('API thunk unexpected error:', error); + return { + success: false, + data: null, + response: null, + error + }; + } + }; }; // 실제 사용 예시들 (안전한 버전) @@ -538,16 +480,16 @@ export const safeUsageExamples = { const result = await TAxiosPromise( dispatch, getState, - "get", + 'get', URLS.GET_HOME_TERMS, { trmsTpCdList: "MST00401, MST00402", mbrNo: "12345" } ); - + if (result.success) { - console.log("Success:", result.data); + console.log('Success:', result.data); return result.data; } else { - console.error("API call failed:", result.error); + console.error('API call failed:', result.error); // 에러를 throw하지 않고 기본값 반환하거나 사용자에게 안내 return null; } @@ -555,24 +497,26 @@ export const safeUsageExamples = { // 2. retCode 체크를 포함한 안전한 처리 safeWithRetCodeCheck: async (dispatch, getState) => { - const result = await TAxiosGet(dispatch, getState, URLS.GET_HOME_TERMS, { - trmsTpCdList: "MST00401, MST00402", - mbrNo: "12345", - }); - + const result = await TAxiosGet( + dispatch, + getState, + URLS.GET_HOME_TERMS, + { trmsTpCdList: "MST00401, MST00402", mbrNo: "12345" } + ); + if (!result.success) { - console.error("Network error:", result.error); - return { success: false, message: "네트워크 오류가 발생했습니다." }; + console.error('Network error:', result.error); + return { success: false, message: '네트워크 오류가 발생했습니다.' }; } - + if (result.data.retCode !== 0) { - console.error("API error:", result.data.retCode, result.data.retMsg); - return { - success: false, - message: result.data.retMsg || "API 오류가 발생했습니다.", + console.error('API error:', result.data.retCode, result.data.retMsg); + return { + success: false, + message: result.data.retMsg || 'API 오류가 발생했습니다.' }; } - + return { success: true, data: result.data }; }, @@ -581,41 +525,40 @@ export const safeUsageExamples = { const requests = [ TAxiosGet(dispatch, getState, URLS.GET_HOME_TERMS, { mbrNo: "12345" }), TAxiosGet(dispatch, getState, URLS.GET_USER_INFO, { mbrNo: "12345" }), - TAxiosPost(dispatch, getState, URLS.UPDATE_SETTINGS, { - setting: "value", - }), + TAxiosPost(dispatch, getState, URLS.UPDATE_SETTINGS, { setting: "value" }) ]; - + const result = await TAxiosAll(requests); - + if (result.success) { - console.log("All requests succeeded"); - return result.successResults.map((item) => item.result); + console.log('All requests succeeded'); + return result.successResults.map(item => item.result); } else { - console.error("Some requests failed:", result.failedResults); + console.error('Some requests failed:', result.failedResults); // 부분적 성공도 처리 가능 return { - successData: result.successResults.map((item) => item.result), - errors: result.failedResults, + successData: result.successResults.map(item => item.result), + errors: result.failedResults }; } - }, + } }; + // 컴포넌트에서의 안전한 사용법 export const ComponentUsageExample = () => { const dispatch = useDispatch(); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); - + const handleFetchTerms = async () => { setLoading(true); setError(null); - + const result = await dispatch(fetchCurrentUserHomeTermsSafe()); - + setLoading(false); - + if (result.success) { console.log("Terms fetched successfully"); // 성공 처리 (예: 성공 토스트 표시) @@ -625,13 +568,13 @@ export const ComponentUsageExample = () => { // 에러 처리 (예: 에러 토스트 표시) } }; - + return (
{contentTarget}
+ */} ); }