[국가코드체크] 메인뷰 이동

This commit is contained in:
sungmin.in
2024-06-21 14:45:22 +09:00
parent 018946fdd9
commit d0db8bb369
4 changed files with 99 additions and 91 deletions

View File

@@ -13,7 +13,6 @@ import {
getDeviceId,
getHttpHeaderForServiceRequest,
getSystemSettings,
setExitApp,
} from "../actions/commonActions";
import { getShoptimeTerms } from "../actions/empActions";
import { getHomeMenu, getHomeTerms } from "../actions/homeActions";
@@ -60,8 +59,6 @@ function AppBase(props) {
const { sendLogSecondLayer } = useLogService();
const dispatch = useDispatch();
const panels = useSelector((state) => state.panels.panels);
const [isValidCountry, setIsValidCountry] = useState(false);
const [changedCountry, setChangedCountry] = useState(false);
const httpHeader = useSelector((state) => state.common.httpHeader);
const appStatus = useSelector((state) => state.common.appStatus);
const introTermsAgree = useSelector((state) => state.common.introTermsAgree);
@@ -85,7 +82,6 @@ function AppBase(props) {
}, 5000)
);
// called by [receive httpHeader, launch, relaunch]
// todo 국가 변경 해서 테스트 진행 필요
const initService = useCallback(
(haveyInit = true) => {
console.log(
@@ -130,12 +126,6 @@ function AppBase(props) {
clearLaunchParams();
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
}
// 국가 체크
if (!checkValidCountry(ricCode, countryCode)) {
setIsValidCountry(true);
return;
}
},
[dispatch, httpHeader]
);
@@ -184,26 +174,6 @@ function AppBase(props) {
}
}, [dispatch, initService]);
// 사용할수 없는 국가 체크
const showInvalidCountry = (retCode) => {
if (retCode === 602) {
setIsValidCountry(true);
if (isValidCountry === true) {
setChangedCountry(true);
} else {
setIsValidCountry(false);
}
} else if (retCode === 603) {
setIsValidCountry(false);
} else {
setIsValidCountry(false);
}
};
useEffect(() => {
showInvalidCountry(termsData.retCode);
}, [termsData.retCode]);
useEffect(() => {
const keyDownEvent = (event) => {
dispatch(changeAppStatus({ cursorVisible: false }));
@@ -280,46 +250,6 @@ function AppBase(props) {
}
}, [introTermsAgree, dispatch]);
const onExit = useCallback(() => {
dispatch(setExitApp());
}, [dispatch]);
// 동의 여부 철회
const onClick = useCallback(() => {
dispatch(
setMyTermsWithdraw({
mandatoryIncludeYn: "Y",
termsList: ["MST00401", "MST00402"],
})
);
}, [dispatch]);
<TPopUp
kind="exitPopup"
open={isValidCountry}
onExit={onExit}
hasButton
button1Text={$L("Exit")}
hasText
title={$L("Exit Shop Time")}
text={$L("This is an unsupported country.")}
/>;
<TPopUp
kind="exitPopup"
open={changedCountry}
onExit={onClick}
onClose={onExit}
hasButton
button1Text={$L("Yes")}
button2Text={$L("No")}
hasText
title={$L("Exit Shop Time")}
text={$L(
"If you have changed your LG service country setting, the usage information in Shop Time during your previous country setting will be deleted. Do you want to proceed?"
)}
/>;
return (
<MainView
className={

View File

@@ -1,17 +1,20 @@
import axios from 'axios';
import axios from "axios";
import * as HelperMethods from '../utils/helperMethods';
import Spotlight from "@enact/spotlight";
import { types } from "../actions/actionTypes";
import { changeLocalSettings, setShowPopup } from "../actions/commonActions";
import {
getUrl
} from './apiConfig';
import { types } from '../actions/actionTypes';
import { changeLocalSettings } from '../actions/commonActions';
import { getAuthenticationCode, getReAuthenticationCode } from '../actions/deviceActions';
getAuthenticationCode,
getReAuthenticationCode,
} from "../actions/deviceActions";
import { ACTIVE_POPUP } from "../utils/Config";
import * as HelperMethods from "../utils/helperMethods";
import { getUrl } from "./apiConfig";
let tokenRefreshing = false;
export const setTokenRefreshing = (value) =>{
console.log('TAxios setTokenRefreshing ', value);
export const setTokenRefreshing = (value) => {
console.log("TAxios setTokenRefreshing ", value);
tokenRefreshing = value;
};
@@ -29,13 +32,10 @@ export const TAxios = (
const checkAccessToken = () => {
return new Promise((resolve) => {
const accessToken = getState().localSettings.accessToken;
if (
noTokenRefresh ||
(!tokenRefreshing && accessToken)
) {
if (noTokenRefresh || (!tokenRefreshing && accessToken)) {
resolve(accessToken);
} else {
if(!accessToken && !tokenRefreshing){
if (!accessToken && !tokenRefreshing) {
dispatch(getAuthenticationCode());
}
HelperMethods.wait(100).then(() => {
@@ -92,8 +92,8 @@ export const TAxios = (
// dispatch({type: types.GET_TERMS_AGREE_YN, payload: {}});
// return;
// }
//AccessToken 만료
if(res?.data?.retCode === 401 ){
// AccessToken 만료
if (res?.data?.retCode === 401) {
dispatch(getReAuthenticationCode());
checkAccessToken().then((token) => {
executeRequest(token);
@@ -101,18 +101,26 @@ export const TAxios = (
return;
}
//RefreshToken 만료
if(res?.data?.retCode === 402 || res?.data?.retCode === 501 ){
if (res?.data?.retCode === 402 || res?.data?.retCode === 501) {
dispatch(getAuthenticationCode());
checkAccessToken().then((token) => {
executeRequest(token);
});
return;
}
if(res?.data?.retCode === 603 ){
//todo "NotServiceCountry"
// 602 요청 국가 불일치
if (res?.data?.retCode === 602) {
dispatch(setShowPopup(ACTIVE_POPUP.unSupportedCountryPopup));
Spotlight.focus("tPopupBtn1");
return;
}
if(res?.data?.retCode === 604 ){
// 603 서비스 국가 아님
if (res?.data?.retCode === 603) {
dispatch(setShowPopup(ACTIVE_POPUP.changeCountyPopup));
Spotlight.focus("tPopupBtn1");
return;
}
if (res?.data?.retCode === 604) {
//todo "NotServiceLanguage"
return;
}

View File

@@ -72,6 +72,8 @@ export const ACTIVE_POPUP = {
orderDetailPopup: "orderDetailPopup",
orderDetailCancel: "orderDetailCancel",
errorPopup: "errorPopup",
unSupportedCountryPopup: "unSupportedCountryPopup",
changeCountyPopup: "changeCounty",
};
export const DEBUG_VIDEO_SUBTITLE_TEST = false;
export const AUTO_SCROLL_DELAY = 600;

View File

@@ -13,6 +13,7 @@ import defaultImageItem from "../../../assets/images/img-thumb-empty-product@3x.
import {
alertToast,
changeAppStatus,
setExitApp,
setHidePopup,
setShowPopup,
} from "../../actions/commonActions";
@@ -73,6 +74,16 @@ const panelMap = {
[Config.panel_names.CONFIRM_PANEL]: ConfirmPanel,
};
const STRING_CONF = {
YES: $L("YES"),
NO: $L("NO"),
EXIT: $L("EXIT"),
THIS_IS_AN_UNSUPPORTED_COUNTRY: $L("This is an unsupported country."),
CHANGE_COUNTRY: $L(
"If you have changed your LG service country setting, the usage information in Shop Time during your previous country setting will be deleted. Do you want to proceed?"
),
};
export default function MainView({ className }) {
const { sendLogAlarmPop, sendLogAlarmClick } = useLogService();
const dispatch = useDispatch();
@@ -181,6 +192,40 @@ export default function MainView({ className }) {
return null;
}, [panels]);
const handlePopupClick = useCallback(() => {
if (activePopup === Config.ACTIVE_POPUP.unSupportedCountryPopup) {
dispatch(setExitApp());
}
if (activePopup === Config.ACTIVE_POPUP.changeCountyPopup) {
dispatch(
pushPanel({
name: panel_names.INTRO_PANEL,
})
);
}
dispatch(setHidePopup());
setTimeout(() => Spotlight.focus());
}, [dispatch, activePopup]);
const handlePopupClose = useCallback(() => {
dispatch(setExitApp());
dispatch(setHidePopup());
}, [dispatch]);
const getMessageByPopupType = (type) => {
switch (type) {
case Config.ACTIVE_POPUP.unSupportedCountryPopup:
return STRING_CONF.THIS_IS_AN_UNSUPPORTED_COUNTRY;
case Config.ACTIVE_POPUP.changeCountyPopup:
return STRING_CONF.CHANGE_COUNTRY;
default:
return;
}
};
useEffect(() => {
if (panels && panels.length > 0) {
let panel = panels[panels.length - 1];
@@ -459,6 +504,29 @@ export default function MainView({ className }) {
text={alertItems[0]?.showNm}
/>
)}
{(activePopup === Config.ACTIVE_POPUP.unSupportedCountryPopup ||
activePopup === Config.ACTIVE_POPUP.changeCountyPopup) && (
<TPopUp
button1Text={
activePopup !== Config.ACTIVE_POPUP.unSupportedCountryPopup
? STRING_CONF.YES
: STRING_CONF.EXIT
}
button2Text={
activePopup == Config.ACTIVE_POPUP.changeCountyPopup &&
STRING_CONF.NO
}
hasButton
hasText
kind="textPopup"
onClick={handlePopupClick}
onClose={handlePopupClose}
open={popupVisible}
text={getMessageByPopupType(activePopup)}
title={$L("Exit Shop Time")}
/>
)}
</div>
);
}