diff --git a/com.twin.app.shoptime/src/hooks/useDebugKey.js b/com.twin.app.shoptime/src/hooks/useDebugKey.js index abc35e0a..dad2971e 100644 --- a/com.twin.app.shoptime/src/hooks/useDebugKey.js +++ b/com.twin.app.shoptime/src/hooks/useDebugKey.js @@ -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;