[SHOPTIME-3130] 운영 및 QA1 테스트 메뉴 제거
운영서버에서는 테스트 메뉴 제거함.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useRef } from "react";
|
||||
import { useCallback, useEffect, useRef, useMemo } from "react";
|
||||
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -10,13 +10,25 @@ import * as Config from "../utils/Config";
|
||||
const useDebugKey = ({ isLandingPage = false }) => {
|
||||
const panels = useSelector((state) => state.panels.panels);
|
||||
const serverType = useSelector((state) => state.localSettings.serverType);
|
||||
|
||||
const serverHOST = useSelector((state) => state.common.appStatus.serverHOST);
|
||||
const debugKey = useRef([]);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const isPrdServer = useMemo(() => {
|
||||
if (!serverHOST) return true;
|
||||
|
||||
if (serverType === "system") {
|
||||
const sdpURL = serverHOST.toLowerCase();
|
||||
if (sdpURL.indexOf("qt2") >= 0 || sdpURL.indexOf("qt") >= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}, [serverType, serverHOST]);
|
||||
|
||||
const handleKeydown = useCallback(
|
||||
(ev) => {
|
||||
if (serverType === "prd") return;
|
||||
if (isPrdServer) return;
|
||||
|
||||
if (isLandingPage && panels && panels.length > 0) {
|
||||
return;
|
||||
@@ -28,9 +40,7 @@ const useDebugKey = ({ isLandingPage = false }) => {
|
||||
debugKey.current.push(String(ev.key));
|
||||
if (debugKey.current.join("") === Config.DEBUG_KEY) {
|
||||
debugKey.current = [];
|
||||
dispatch(
|
||||
pushPanel({ name: Config.panel_names.DEBUG_PANEL, panelInfo: {} })
|
||||
);
|
||||
dispatch(pushPanel({ name: Config.panel_names.DEBUG_PANEL, panelInfo: {} }));
|
||||
}
|
||||
if (debugKey.current.join("") === Config.TESTPANEL_KEY) {
|
||||
debugKey.current = [];
|
||||
@@ -43,17 +53,17 @@ const useDebugKey = ({ isLandingPage = false }) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
[panels, dispatch, isLandingPage, serverType]
|
||||
[panels, dispatch, isLandingPage, isPrdServer]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (serverType !== "prd") {
|
||||
if (!isPrdServer) {
|
||||
on("keydown", handleKeydown);
|
||||
return () => {
|
||||
off("keydown", handleKeydown);
|
||||
};
|
||||
}
|
||||
}, [handleKeydown, serverType]);
|
||||
}, [handleKeydown, isPrdServer]);
|
||||
};
|
||||
|
||||
export default useDebugKey;
|
||||
|
||||
Reference in New Issue
Block a user