[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";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
|||||||
|
|
||||||
import appinfo from "../../webos-meta/appinfo.json";
|
import appinfo from "../../webos-meta/appinfo.json";
|
||||||
import {
|
import {
|
||||||
|
alertToast,
|
||||||
changeAppStatus,
|
changeAppStatus,
|
||||||
getDeviceId,
|
getDeviceId,
|
||||||
getHttpHeaderForServiceRequest,
|
getHttpHeaderForServiceRequest,
|
||||||
@@ -14,9 +15,14 @@ import {
|
|||||||
} from "../actions/commonActions";
|
} from "../actions/commonActions";
|
||||||
import { getAuthenticationCode } from "../actions/deviceActions";
|
import { getAuthenticationCode } from "../actions/deviceActions";
|
||||||
import { getHomeMenu, getHomeTerms } from "../actions/homeActions";
|
import { getHomeMenu, getHomeTerms } from "../actions/homeActions";
|
||||||
import { getMyRecommandedKeyword } from "../actions/myPageActions";
|
import {
|
||||||
|
getMyRecommandedKeyword,
|
||||||
|
setMyTermsWithdraw,
|
||||||
|
} from "../actions/myPageActions";
|
||||||
import { pushPanel } from "../actions/panelActions";
|
import { pushPanel } from "../actions/panelActions";
|
||||||
|
import { countryCode, ricCode } from "../api/apiConfig";
|
||||||
import usePrevious from "../hooks/usePrevious";
|
import usePrevious from "../hooks/usePrevious";
|
||||||
|
import { checkValidCountry } from "../lunaSend/common";
|
||||||
import { lunaTest } from "../lunaSend/lunaTest";
|
import { lunaTest } from "../lunaSend/lunaTest";
|
||||||
import * as Config from "../utils/Config";
|
import * as Config from "../utils/Config";
|
||||||
import { clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
|
import { clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
|
||||||
@@ -29,10 +35,16 @@ let foreGroundChangeTimer = null;
|
|||||||
function AppBase(props) {
|
function AppBase(props) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const panels = useSelector((state) => state.panels.panels);
|
const panels = useSelector((state) => state.panels.panels);
|
||||||
|
const [isValidCountry, setIsValidCountry] = useState(false);
|
||||||
|
const [changedCountry, setChangedCountry] = useState(false);
|
||||||
const { httpHeader, appStatus, introTermsAgree } = useSelector(
|
const { httpHeader, appStatus, introTermsAgree } = useSelector(
|
||||||
(state) => state.common
|
(state) => state.common
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const termsData = useSelector((state) => state.home.termsData);
|
||||||
|
|
||||||
const introTermsAgreeRef = usePrevious(introTermsAgree);
|
const introTermsAgreeRef = usePrevious(introTermsAgree);
|
||||||
|
|
||||||
// called by [receive httpHeader, launch, relaunch]
|
// called by [receive httpHeader, launch, relaunch]
|
||||||
const initService = useCallback(
|
const initService = useCallback(
|
||||||
(haveyInit = true) => {
|
(haveyInit = true) => {
|
||||||
@@ -72,6 +84,30 @@ function AppBase(props) {
|
|||||||
// loading 임시 주석 pjh
|
// loading 임시 주석 pjh
|
||||||
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
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]
|
[dispatch, httpHeader]
|
||||||
);
|
);
|
||||||
@@ -118,12 +154,31 @@ function AppBase(props) {
|
|||||||
}
|
}
|
||||||
}, [dispatch, initService]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
if (typeof window === "object" && window.PalmSystem) {
|
if (typeof window === "object" && window.PalmSystem) {
|
||||||
window.PalmSystem.activate();
|
window.PalmSystem.activate();
|
||||||
window.lunaTest = (service, method, subscribe, parameters) =>
|
window.lunaTest = (service, method, subscribe, parameters) =>
|
||||||
lunaTest(service, method, subscribe, parameters);
|
lunaTest(service, method, subscribe, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(getDeviceId());
|
dispatch(getDeviceId());
|
||||||
dispatch(getHttpHeaderForServiceRequest());
|
dispatch(getHttpHeaderForServiceRequest());
|
||||||
dispatch(getSystemSettings());
|
dispatch(getSystemSettings());
|
||||||
@@ -146,6 +201,7 @@ function AppBase(props) {
|
|||||||
changeAppStatus({ showLoadingPanel: { show: true, type: "launching" } })
|
changeAppStatus({ showLoadingPanel: { show: true, type: "launching" } })
|
||||||
);
|
);
|
||||||
dispatch(getAuthenticationCode());
|
dispatch(getAuthenticationCode());
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
getHomeTerms({
|
getHomeTerms({
|
||||||
mbrNo: appStatus.loginUserData.userInfo,
|
mbrNo: appStatus.loginUserData.userInfo,
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ export const URLS = {
|
|||||||
LOG_CHECKOUT_BTN_CLICK: "/lgsp/v1/log/checkout/btnClick.lge",
|
LOG_CHECKOUT_BTN_CLICK: "/lgsp/v1/log/checkout/btnClick.lge",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export let countryCode = "";
|
||||||
|
export let ricCode = "";
|
||||||
|
|
||||||
const getRicCode = (country, ricCodeSetting) => {
|
const getRicCode = (country, ricCodeSetting) => {
|
||||||
if (ricCodeSetting !== "system") {
|
if (ricCodeSetting !== "system") {
|
||||||
return ricCodeSetting;
|
return ricCodeSetting;
|
||||||
@@ -239,8 +242,9 @@ export const getUrl = (getState, endStr) => {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
let sdpURL = serverHOST.split(".")[0];
|
let sdpURL = serverHOST.split(".")[0];
|
||||||
let countryCode = "",
|
|
||||||
ricCode = "";
|
// let countryCode = "",
|
||||||
|
// ricCode = "";
|
||||||
if (sdpURL.indexOf("-") > 0) {
|
if (sdpURL.indexOf("-") > 0) {
|
||||||
countryCode = sdpURL.split("-")[1];
|
countryCode = sdpURL.split("-")[1];
|
||||||
} else {
|
} else {
|
||||||
@@ -250,6 +254,7 @@ export const getUrl = (getState, endStr) => {
|
|||||||
if (!ricCode) {
|
if (!ricCode) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
sdpURL = sdpURL.toLowerCase();
|
sdpURL = sdpURL.toLowerCase();
|
||||||
if (serverType !== "system") {
|
if (serverType !== "system") {
|
||||||
sdpURL = serverType;
|
sdpURL = serverType;
|
||||||
|
|||||||
@@ -122,4 +122,23 @@ export const getSystemSettings = (
|
|||||||
onSuccess(res);
|
onSuccess(res);
|
||||||
onComplete(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