Skip to content

Commit

Permalink
also show the modal if it's been a year since consent was requested.
Browse files Browse the repository at this point in the history
  • Loading branch information
alishaevn committed Nov 28, 2023
1 parent 1c38f49 commit 3cb2484
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
FOOTER_SOCIALS,
LOGO,
NAVIGATION_LINKS,
cookieConsent,
disableCookies,
enableCookies,
getCookieConsent,
fetcher,
headerAndFooterLinkColors,
} from '../utils'
Expand All @@ -33,9 +33,9 @@ const WebStore = ({ Component }) => {
return (
<>
<CookiePreferencesModal
cookieConsent={cookieConsent}
disableCookies={disableCookies}
enableCookies={enableCookies}
getCookieConsent={getCookieConsent()}
/>
<Header
auth={{
Expand Down
9 changes: 9 additions & 0 deletions utils/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ export const disableCookies = () => {
setCookie('_dl_cookie_consent', 'false', { path: '/' })
setCookie('_cookies_updated_at', new Date(), { path: '/' })
}

export const getCookieConsent = () => {
const updatedAt = getCookie('_cookies_updated_at')
const oneYearInMilliseconds = 1000*60*60*24*365
const oneYearLapsed = (new Date() - updatedAt) >= oneYearInMilliseconds

if ((cookieConsent === undefined) || oneYearLapsed) return true
return false
}

0 comments on commit 3cb2484

Please sign in to comment.