diff --git a/client/src/App/App.jsx b/client/src/App/App.jsx index 6fe558910..2a0b679c6 100644 --- a/client/src/App/App.jsx +++ b/client/src/App/App.jsx @@ -18,7 +18,6 @@ import { checkUserSession } from "../redux/user/user.actions"; import { selectBodyshop, selectCurrentEula, selectCurrentUser } from "../redux/user/user.selectors"; import PrivateRoute from "../components/PrivateRoute"; import "./App.styles.scss"; -import handleBeta from "../utils/handleBeta"; import Eula from "../components/eula/eula.component"; import InstanceRenderMgr from "../utils/instanceRenderMgr"; import ProductFruitsWrapper from "./ProductFruitsWrapper.jsx"; @@ -108,8 +107,6 @@ export function App({ bodyshop, checkUserSession, currentUser, online, setOnline return ; } - handleBeta(); - if (!online) { return ( { - const isBeta = checkBeta(); - setBetaSwitch(isBeta); - }, []); - - const betaSwitchChange = (checked) => { - setBeta(checked); - setBetaSwitch(checked); - handleBeta(); + const deleteBetaCookie = () => { + const cookieExists = document.cookie.split("; ").some((row) => row.startsWith(`betaSwitchImex=`)); + if (cookieExists) { + const domain = window.location.hostname.split(".").slice(-2).join("."); + document.cookie = `betaSwitchImex=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${domain}`; + console.log(`betaSwitchImex cookie deleted`); + } else { + console.log(`betaSwitchImex cookie does not exist`); + } }; + deleteBetaCookie(); + const accountingChildren = []; if ( @@ -695,31 +695,6 @@ function Header({ } ]; - InstanceRenderManager({ - executeFunction: true, - args: [], - imex: () => { - menuItems.push({ - key: "beta-switch", - id: "header-beta-switch", - style: { marginLeft: "auto" }, - label: ( - - - Try the new app - - - ) - }); - } - }); - return ( { operationName: eventName, variables: additionalParams, dbevent: false, - env: checkBeta() ? "beta" : "master" + env: "master" }); // console.log( // "%c[Analytics]", diff --git a/client/src/utils/handleBeta.js b/client/src/utils/handleBeta.js deleted file mode 100644 index dcb0d18d1..000000000 --- a/client/src/utils/handleBeta.js +++ /dev/null @@ -1,47 +0,0 @@ -export const BETA_KEY = "betaSwitchImex"; - -export const checkBeta = () => { - const cookie = document.cookie.split("; ").find((row) => row.startsWith(BETA_KEY)); - return cookie ? cookie.split("=")[1] === "true" : false; -}; - -export const setBeta = (value) => { - const domain = window.location.hostname.split(".").slice(-2).join("."); - document.cookie = `${BETA_KEY}=${value}; path=/; domain=.${domain}`; -}; - -export const handleBeta = () => { - if (window.location.hostname.startsWith("localhost")) { - console.log("Not on beta or test, so no need to handle beta."); - return; - } - - const isBeta = checkBeta(); - const currentHostName = window.location.hostname; - - // Determine if the host name starts with "beta" or "www.beta" - const isBetaHost = currentHostName.startsWith("beta."); - const isBetaHostWithWWW = currentHostName.startsWith("www.beta."); - - if (isBeta) { - // If beta is on and we are not on a beta domain, redirect to the beta version - if (!isBetaHost && !isBetaHostWithWWW) { - const newHostName = currentHostName.startsWith("www.") - ? `www.beta.${currentHostName.replace(/^www\./, "")}` - : `beta.${currentHostName}`; - const href = `${window.location.protocol}//${newHostName}${window.location.pathname}${window.location.search}${window.location.hash}`; - window.location.replace(href); - } - // Otherwise, if beta is on and we're already on a beta domain, stay there - } else { - // If beta is off and we are on a beta domain, redirect to the non-beta version - if (isBetaHost || isBetaHostWithWWW) { - const newHostName = currentHostName.replace(/^www\.beta\./, "www.").replace(/^beta\./, ""); - const href = `${window.location.protocol}//${newHostName}${window.location.pathname}${window.location.search}${window.location.hash}`; - window.location.replace(href); - } - // Otherwise, if beta is off and we're not on a beta domain, stay there - } -}; - -export default handleBeta;