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

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

@@ -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;
}