Skip to content

Commit

Permalink
remving .env check
Browse files Browse the repository at this point in the history
  • Loading branch information
snmln committed Sep 18, 2024
1 parent 9cc346e commit 01b7443
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions app/scripts/components/common/layout-root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import {
subNavItems
} from '$components/common/page-header/default-config';

import { checkEnvFlag } from '$utils/utils';

const appTitle = process.env.APP_TITLE;
const appDescription = process.env.APP_DESCRIPTION;

Expand All @@ -43,8 +41,7 @@ const PageBody = styled.div`
`;

function LayoutRoot(props: { children?: ReactNode }) {
const useConsentForm = checkEnvFlag(process.env.COOKIE_CONSENT_FORM);

const cookieConsentContent = getCookieConsentFromVedaConfig();
const readCookie = (name) => {
const nameEQ = name + '=';
const attribute = document.cookie.split(';');
Expand All @@ -56,26 +53,19 @@ function LayoutRoot(props: { children?: ReactNode }) {
return null;
};
const { children } = props;
let cookieContents;

function getCookie() {
if (document.cookie != '') {
const cookie = readCookie('CookieConsent');
if (cookie != null) {
cookieContents = JSON.parse(cookie);

cookieContents.answer && setGoogleTagManager();

return cookieContents;
}
const getCookie = () => {
const cookie = readCookie('CookieConsent');
if (cookie) {
const cookieContents = JSON.parse(cookie);
if (cookieContents.answer) setGoogleTagManager();
return cookieContents;
}
cookieContents = 'NO COOKIE';
}
return 'NO COOKIE';
};

const cookieConsentContent = getCookieConsentFromVedaConfig();
const showForm = () => {
getCookie();

const cookieContents = getCookie();
if (cookieContents === 'NO COOKIE') {
return true;
} else {
Expand All @@ -84,8 +74,7 @@ function LayoutRoot(props: { children?: ReactNode }) {
};

useEffect(() => {
!useConsentForm && setGoogleTagManager();

!cookieConsentContent && setGoogleTagManager();
}, []);

const { title, thumbnail, description, banner, hideFooter } =
Expand All @@ -111,7 +100,7 @@ function LayoutRoot(props: { children?: ReactNode }) {
<PageBody id={PAGE_BODY_ID} tabIndex={-1}>
<Outlet />
{children}
{useConsentForm && showForm() && (
{cookieConsentContent && showForm() && (
<CookieConsent
{...cookieConsentContent}
onFormInteraction={getCookie}
Expand Down

0 comments on commit 01b7443

Please sign in to comment.