From 55b623294a44226e8b3cbcbeee4f1ad2c9af4154 Mon Sep 17 00:00:00 2001 From: Lencodes Date: Tue, 21 Nov 2023 12:03:56 +0100 Subject: [PATCH] INIT hiding theme switcher --- pwa/src/hooks/useEnvironment.ts | 2 ++ pwa/src/services/getConfig.ts | 1 + .../themeSwitcherTopBar/ThemeSwitcherTopBar.tsx | 6 +++++- pwa/static/.env.development | 5 ++++- pwa/static/configFiles/conduction.json | 1 + pwa/static/configFiles/dinkelland.json | 1 + pwa/static/configFiles/epe.json | 1 + pwa/static/configFiles/noaberkracht.json | 1 + pwa/static/configFiles/noordwijk.json | 1 + pwa/static/configFiles/open-webconcept.json | 1 + pwa/static/configFiles/rotterdam.json | 1 + pwa/static/configFiles/tubbergen.json | 1 + pwa/static/configFiles/xxllnc.json | 1 + 13 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pwa/src/hooks/useEnvironment.ts b/pwa/src/hooks/useEnvironment.ts index 2a16aef2..f465fc48 100644 --- a/pwa/src/hooks/useEnvironment.ts +++ b/pwa/src/hooks/useEnvironment.ts @@ -22,6 +22,7 @@ export const useEnvironment = () => { }, []); const initiateFromEnv = () => { + window.sessionStorage.setItem("SHOW_THEME_SWITCHER", process.env.GATSBY_SHOW_THEME_SWITCHER ?? ""); window.sessionStorage.setItem("API_BASE_URL", process.env.GATSBY_API_BASE_URL ?? ""); window.sessionStorage.setItem("NL_DESIGN_THEME_CLASSNAME", process.env.GATSBY_NL_DESIGN_THEME_CLASSNAME ?? ""); window.sessionStorage.setItem("FAVICON_URL", process.env.GATSBY_FAVICON_URL ?? ""); @@ -40,6 +41,7 @@ export const useEnvironment = () => { if (!config) return; // no config found, nothing else to do + window.sessionStorage.setItem("SHOW_THEME_SWITCHER", config.GATSBY_SHOW_THEME_SWITCHER ?? ""); window.sessionStorage.setItem("API_BASE_URL", config.GATSBY_API_BASE_URL ?? ""); window.sessionStorage.setItem("NL_DESIGN_THEME_CLASSNAME", config.GATSBY_NL_DESIGN_THEME_CLASSNAME ?? ""); window.sessionStorage.setItem("FAVICON_URL", config.GATSBY_FAVICON_URL ?? ""); diff --git a/pwa/src/services/getConfig.ts b/pwa/src/services/getConfig.ts index 3d8a9db9..5b2752be 100644 --- a/pwa/src/services/getConfig.ts +++ b/pwa/src/services/getConfig.ts @@ -33,6 +33,7 @@ export const getConfig = (themeOrDomainName: string): Record | unde return Xxllnc; case "koophulpje.nl": case "open-webconcept-theme": + case "localhost": return OpenWebconcept; default: return Conduction; diff --git a/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.tsx b/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.tsx index 163a0374..e9fdf969 100644 --- a/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.tsx +++ b/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.tsx @@ -38,6 +38,10 @@ export const ThemeSwitcherTopBar: React.FC = () => { initiateFromJSON(watchTheme.value); }, [watchTheme]); + if (window.sessionStorage.getItem("SHOW_THEME_SWITCHER") === "false") { + return <>; + } + return (
@@ -47,7 +51,7 @@ export const ThemeSwitcherTopBar: React.FC = () => {
- Huidige gemeente + Selecteer een gemeente