[APP] 국가 체크(팝업-연동전)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -7,6 +7,7 @@ import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
||||
|
||||
import appinfo from "../../webos-meta/appinfo.json";
|
||||
import {
|
||||
alertToast,
|
||||
changeAppStatus,
|
||||
getDeviceId,
|
||||
getHttpHeaderForServiceRequest,
|
||||
@@ -14,9 +15,14 @@ import {
|
||||
} from "../actions/commonActions";
|
||||
import { getAuthenticationCode } from "../actions/deviceActions";
|
||||
import { getHomeMenu, getHomeTerms } from "../actions/homeActions";
|
||||
import { getMyRecommandedKeyword } from "../actions/myPageActions";
|
||||
import {
|
||||
getMyRecommandedKeyword,
|
||||
setMyTermsWithdraw,
|
||||
} from "../actions/myPageActions";
|
||||
import { pushPanel } from "../actions/panelActions";
|
||||
import { countryCode, ricCode } from "../api/apiConfig";
|
||||
import usePrevious from "../hooks/usePrevious";
|
||||
import { checkValidCountry } from "../lunaSend/common";
|
||||
import { lunaTest } from "../lunaSend/lunaTest";
|
||||
import * as Config from "../utils/Config";
|
||||
import { clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
|
||||
@@ -29,10 +35,16 @@ let foreGroundChangeTimer = null;
|
||||
function AppBase(props) {
|
||||
const dispatch = useDispatch();
|
||||
const panels = useSelector((state) => state.panels.panels);
|
||||
const [isValidCountry, setIsValidCountry] = useState(false);
|
||||
const [changedCountry, setChangedCountry] = useState(false);
|
||||
const { httpHeader, appStatus, introTermsAgree } = useSelector(
|
||||
(state) => state.common
|
||||
);
|
||||
|
||||
const termsData = useSelector((state) => state.home.termsData);
|
||||
|
||||
const introTermsAgreeRef = usePrevious(introTermsAgree);
|
||||
|
||||
// called by [receive httpHeader, launch, relaunch]
|
||||
const initService = useCallback(
|
||||
(haveyInit = true) => {
|
||||
@@ -72,6 +84,30 @@ function AppBase(props) {
|
||||
// loading 임시 주석 pjh
|
||||
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
||||
}
|
||||
|
||||
if (!checkValidCountry(ricCode, countryCode)) {
|
||||
setIsValidCountry(false);
|
||||
// 미지원 국가 알림창
|
||||
// this.$nextTick(() => {
|
||||
// if (this.$refs.unsupportedBox.isShow() == false) {
|
||||
// this.$refs.unsupportedBox.show();
|
||||
// }
|
||||
// });
|
||||
dispatch(alertToast("This is an unsupported country."));
|
||||
return;
|
||||
}
|
||||
if (changedCountry === true) {
|
||||
dispatch(alertToast("The country has been changed."));
|
||||
|
||||
dispatch(
|
||||
setMyTermsWithdraw({
|
||||
mandatoryIncludeYn: "Y",
|
||||
termsList: ["MST00401", "MST00402"],
|
||||
})
|
||||
);
|
||||
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
[dispatch, httpHeader]
|
||||
);
|
||||
@@ -118,12 +154,31 @@ function AppBase(props) {
|
||||
}
|
||||
}, [dispatch, initService]);
|
||||
|
||||
// 사용 할수 없는 국가 체크
|
||||
useEffect(() => {
|
||||
if (termsData && termsData.retCode) {
|
||||
if (termsData.retCode === 602) {
|
||||
setIsValidCountry(checkValidCountry(ricCode, countryCode));
|
||||
if (isValidCountry === true) {
|
||||
setChangedCountry(true);
|
||||
} else {
|
||||
setIsValidCountry(false);
|
||||
}
|
||||
} else if (termsData.retCode === 603) {
|
||||
setIsValidCountry(false);
|
||||
} else {
|
||||
setIsValidCountry(false);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "object" && window.PalmSystem) {
|
||||
window.PalmSystem.activate();
|
||||
window.lunaTest = (service, method, subscribe, parameters) =>
|
||||
lunaTest(service, method, subscribe, parameters);
|
||||
}
|
||||
|
||||
dispatch(getDeviceId());
|
||||
dispatch(getHttpHeaderForServiceRequest());
|
||||
dispatch(getSystemSettings());
|
||||
@@ -146,6 +201,7 @@ function AppBase(props) {
|
||||
changeAppStatus({ showLoadingPanel: { show: true, type: "launching" } })
|
||||
);
|
||||
dispatch(getAuthenticationCode());
|
||||
|
||||
dispatch(
|
||||
getHomeTerms({
|
||||
mbrNo: appStatus.loginUserData.userInfo,
|
||||
|
||||
@@ -218,6 +218,9 @@ export const URLS = {
|
||||
LOG_CHECKOUT_BTN_CLICK: "/lgsp/v1/log/checkout/btnClick.lge",
|
||||
};
|
||||
|
||||
export let countryCode = "";
|
||||
export let ricCode = "";
|
||||
|
||||
const getRicCode = (country, ricCodeSetting) => {
|
||||
if (ricCodeSetting !== "system") {
|
||||
return ricCodeSetting;
|
||||
@@ -239,8 +242,9 @@ export const getUrl = (getState, endStr) => {
|
||||
return "";
|
||||
}
|
||||
let sdpURL = serverHOST.split(".")[0];
|
||||
let countryCode = "",
|
||||
ricCode = "";
|
||||
|
||||
// let countryCode = "",
|
||||
// ricCode = "";
|
||||
if (sdpURL.indexOf("-") > 0) {
|
||||
countryCode = sdpURL.split("-")[1];
|
||||
} else {
|
||||
@@ -250,6 +254,7 @@ export const getUrl = (getState, endStr) => {
|
||||
if (!ricCode) {
|
||||
return "";
|
||||
}
|
||||
|
||||
sdpURL = sdpURL.toLowerCase();
|
||||
if (serverType !== "system") {
|
||||
sdpURL = serverType;
|
||||
|
||||
@@ -122,4 +122,23 @@ export const getSystemSettings = (
|
||||
onSuccess(res);
|
||||
onComplete(res);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export function checkValidCountry(ricCode, country) {
|
||||
if (ricCode === "aic") {
|
||||
if (country === "US") return true;
|
||||
else return false;
|
||||
} else if (ricCode === "eic") {
|
||||
if (country === "GB" || country === "DE") return true;
|
||||
else return false;
|
||||
} else if (ricCode === "ruc") {
|
||||
if (country === "RU") return true;
|
||||
else return false;
|
||||
} else {
|
||||
if (country === "US") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user