약관동의 확인 후 다른 api 호출하도록 수정

This commit is contained in:
yonghyon
2024-03-13 16:54:10 +09:00
parent 03fad20dc5
commit 49ce8355a3
4 changed files with 58 additions and 28 deletions

View File

@@ -22,10 +22,13 @@ import {
import { getSubCategory, getTop20Show } from "../actions/mainActions";
import { getMyRecommandedKeyword } from "../actions/myPageActions";
import { getOnSaleInfo } from "../actions/onSaleActions";
import { getBestSeller } from "../actions/productActions";
import { getBestSeller } from "../actions/productActions"
import { pushPanel } from "../actions/panelActions";;
import { lunaTest } from "../lunaSend/lunaTest";
import { clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
import * as Config from "../utils/Config";
import MainView from "../views/MainView/MainView";
import usePrevious from "../hooks/usePrevious";
import css from "./App.module.less";
import { handleDeepLink } from "./deepLinkHandler";
@@ -33,9 +36,8 @@ let foreGroundChangeTimer = null;
function AppBase(props) {
const dispatch = useDispatch();
const { httpHeader } = useSelector((state) => state.common);
const { appStatus } = useSelector((state) => state.common);
const { httpHeader, appStatus, introTermsAgree } = useSelector((state) => state.common);
const introTermsAgreeRef = usePrevious(introTermsAgree);
// called by [receive httpHeader, launch, relaunch]
const initService = useCallback(
(haveyInit = true) => {
@@ -54,13 +56,8 @@ function AppBase(props) {
})
);
}
dispatch(getAuthenticationCode());
dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" }));
dispatch(
getHomeTerms({
trmsTpCdList: "MST00401, MST00402, MST00403, MST00404",
})
);
dispatch(getHomeMenu());
dispatch(getHomeLayout());
dispatch(getHomeMainContents());
@@ -99,8 +96,11 @@ function AppBase(props) {
const handleRelaunchEvent = useCallback(() => {
console.log("handleRelaunchEvent started");
initService(false);
}, [initService]);
dispatch(getAuthenticationCode());
if(introTermsAgreeRef.current){
initService(false);
}
}, [initService, dispatch]);
const visibilityChanged = useCallback(() => {
console.log("document is hidden", document.hidden);
@@ -158,15 +158,32 @@ function AppBase(props) {
}, []);
useEffect(() => {
console.log("httpHeader changed ", httpHeader);
console.log("httpHeader changed ", httpHeader, appStatus);
if (!httpHeader || !appStatus.deviceId) {
} else {
//계정정보 변경시 또는 초기 로딩시
dispatch(changeAppStatus({ showLoadingPanel: { show: true } }));
initService(true);
dispatch(changeAppStatus({ showLoadingPanel: { show: true, type: 'launching' } }));
dispatch(getAuthenticationCode());
dispatch(
getHomeTerms({
trmsTpCdList: "MST00401, MST00402, MST00403, MST00404",
})
);
}
}, [httpHeader, appStatus.deviceId]);
useEffect(() => {
console.log('App.js introTermsAgree', introTermsAgree);
if (introTermsAgree !== undefined) {
if(introTermsAgree){
initService(true);
}else{
dispatch(pushPanel({ name: Config.panel_names.INTRO_PANEL, panelInfo: {} }));
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
}
}
}, [introTermsAgree, dispatch]);
return <MainView />;
}

View File

@@ -0,0 +1,13 @@
import {useRef, useEffect} from 'react';
function usePrevious (value) {
const ref = useRef();
useEffect(() => {
ref.current = value;
}, [value]);
return ref;
}
export default usePrevious;

View File

@@ -20,7 +20,7 @@ const initialState = {
activePopup: null,
},
termsFlag: null,
introTermsAgree: true,
introTermsAgree: undefined,
checkoutTermsAgree: false,
};
@@ -107,6 +107,18 @@ export const commonReducer = (state = initialState, action) => {
checkoutTermsAgree,
};
}
case types.REGISTER_DEVICE: {
if(action.payload && action.payload.dvcIndex){
return {
...state,
termsFlag: {...state.termsFlag, privacyTerms: "Y", serviceTerms: "Y"},
introTermsAgree: true
};
}else{
return state;
}
}
default:
return state;

View File

@@ -9,7 +9,6 @@ import Spotlight from "@enact/spotlight";
// 테스트용 - TODO: 메인 홈 화면에 나와야 하는 이미지들 추가 후 preloadImages에 추가
import testImage from "../../../assets/images/img-banner-myinfo-login@3x.png";
import { changeAppStatus } from "../../actions/commonActions";
import { pushPanel } from "../../actions/panelActions";
import Loader from "../../components/Loader/Loader";
import PreloadImage from "../../components/PreloadImage/PreloadImage";
import TabLayout from "../../components/TabLayout/TabLayout";
@@ -60,7 +59,6 @@ export default function MainView() {
const { showLoadingPanel, toast, toastText, isLoading } = useSelector(
(state) => state.common.appStatus
);
const { introTermsAgree } = useSelector((state) => state.common);
const [tabActivated, setTabActivated] = useState(false);
@@ -110,16 +108,6 @@ export default function MainView() {
}
}, [panels]);
useEffect(() => {
if (!showLoadingPanel.show) {
if (!introTermsAgree) {
dispatch(
pushPanel({ name: Config.panel_names.INTRO_PANEL, panelInfo: {} })
);
}
}
}, [showLoadingPanel.show, introTermsAgree, dispatch]);
const cursorStateChange = useCallback(
(ev) => {
dispatch(