Skip to content

Commit

Permalink
Finish cookie consent #128
Browse files Browse the repository at this point in the history
  • Loading branch information
gffuma committed May 25, 2022
1 parent a63f1da commit 8af27ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import About from './pages/About'
import TermsOfUse from './pages/TermsOfUse/TermsOfUse'
import Education from './pages/Education'
import Anaylitcs from './components/Analytics'
import CookieConsent from './components/CookieConsent'

// NOTE: This sync lang when changed from push state navigation
// (user press back, forward history)
Expand Down Expand Up @@ -143,6 +144,7 @@ function App({ client, apiUrl, requestsCache }) {
</ErrorBoundary>
{/* NOTE: Here to avoid re-sending page view on 404 and so on ... */}
<Anaylitcs />
<CookieConsent />
</>
)
}
Expand Down
26 changes: 13 additions & 13 deletions src/components/CookieConsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { useTranslation } from 'react-i18next'
import { Modal, ModalBody } from 'reactstrap'

export default function CookieConsent() {
const [isOpen, setIsOpen] = useState(true)
// const storeKey = 'modalTip:' + type
const [isOpen, setIsOpen] = useState(false)
const storeKey = 'cookieconsent'

// useEffect(() => {
// const showed = sessionStorage.getItem(storeKey)
// if (!showed) {
// setIsOpen(true)
// }
// }, [storeKey])
useEffect(() => {
const showed = sessionStorage.getItem(storeKey)
if (!showed) {
setIsOpen(true)
}
}, [storeKey])

const { t } = useTranslation()

Expand All @@ -24,14 +24,14 @@ export default function CookieConsent() {
<div className="text-center">
{t('read_more')}
</div>

<div className="text-center mt-2">
<button
className="btn-auto-tip btn text-white rounded-pill bg-dark-gray"
// onClick={() => {
// setIsOpen(false)
// sessionStorage.setItem(storeKey, 'yes')
// }}
onClick={() => {
setIsOpen(false)
sessionStorage.setItem(storeKey, 'yes')
}}
>
{t('ok_i_got')}
</button>
Expand Down

0 comments on commit 8af27ad

Please sign in to comment.