Skip to content

Commit 15500bf

Browse files
committed
fix: add consent cookies button
1 parent 78dc97d commit 15500bf

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

src/app/(user-scope)/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CookiesConsent } from '@/components/shared/cookies-consent'
12
import { Footer } from '@/components/shared/footer'
23
import { HighlightStripe } from '@/components/shared/highlight-stripe'
34
import { Navbar } from '@/components/shared/navbar'
@@ -11,6 +12,7 @@ const UserScopePagesLayout: React.FC<NextLayoutDefaultProps> = async ({
1112
<Navbar />
1213
<HighlightStripe />
1314
{children}
15+
<CookiesConsent />
1416
<Footer />
1517
</>
1618
)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
'use client'
2+
3+
import { useEffect, useState } from 'react'
4+
5+
export const CookiesConsent = () => {
6+
const [visible, setVisible] = useState(false)
7+
8+
useEffect(() => {
9+
const consent = sessionStorage.getItem('cookieConsent')
10+
if (!consent) setVisible(true)
11+
}, [])
12+
13+
const handleConsent = (type: 'manage' | 'reject' | 'accept') => {
14+
sessionStorage.setItem('cookieConsent', type)
15+
setVisible(false)
16+
}
17+
18+
if (!visible) return null
19+
20+
return (
21+
<div className="fixed inset-x-0 bottom-0 z-52 flex flex-col gap-4 px-4 pt-4 pb-6 backdrop-blur-3xl md:flex-row md:items-center md:justify-between lg:pt-8 lg:pb-8">
22+
<div className="mx-auto flex w-full max-w-2xl flex-col gap-6 lg:max-w-7xl lg:flex-row lg:gap-6">
23+
<div className="flex max-w-[840px] flex-col gap-2.5">
24+
<p
25+
className="text-sm font-semibold lg:text-base 2xl:text-lg"
26+
id="cookieConsentTitle"
27+
>
28+
Nós usamos cookies
29+
</p>
30+
<p className="text-xs lg:text-sm" id="cookieConsentDesc">
31+
Utilizamos cookies para ajudar este site a funcionar, compreender a
32+
utilização do serviço e promover esforços de marketing e trazer
33+
features exclusivas para nossos usuários. Leia nossos{' '}
34+
<a
35+
className="underline underline-offset-2 transition duration-250"
36+
href="/termos-de-uso"
37+
>
38+
Termos de uso
39+
</a>{' '}
40+
para saber mais.
41+
</p>
42+
</div>
43+
<div className="flex shrink-0 flex-col gap-2.5 md:flex-row lg:items-center">
44+
<button
45+
className="flex h-8 w-full cursor-pointer items-center justify-center gap-[0.3em] rounded-[2.5rem] border border-white/20 bg-white/40 px-6 py-1 text-sm text-nowrap outline-offset-2 backdrop-blur-md transition duration-300 hover:border-white/50 hover:bg-white/55 focus:border-neutral-600 md:w-auto lg:h-10 lg:py-2 lg:text-base"
46+
onClick={() => handleConsent('manage')}
47+
type="button"
48+
>
49+
Rejeitar tudo
50+
</button>
51+
<button
52+
className="flex h-8 w-full cursor-pointer items-center justify-center gap-[0.3em] rounded-[2.5rem] border border-white/20 bg-white/40 px-6 py-1 text-sm text-nowrap outline-offset-2 backdrop-blur-md transition duration-300 hover:border-white/50 hover:bg-white/55 focus:border-neutral-600 md:w-auto lg:h-10 lg:py-2 lg:text-base"
53+
onClick={() => handleConsent('reject')}
54+
type="button"
55+
>
56+
Rejeitar cookies não essenciais
57+
</button>
58+
<button
59+
className="flex h-8 w-full cursor-pointer items-center justify-center gap-[0.3em] rounded-[2.5rem] border border-white/20 bg-white/40 px-6 py-1 text-sm text-nowrap outline-offset-2 backdrop-blur-md transition duration-300 hover:border-white/50 hover:bg-white/55 focus:border-neutral-600 md:w-auto lg:h-10 lg:py-2 lg:text-base"
60+
onClick={() => handleConsent('accept')}
61+
type="button"
62+
>
63+
Aceitar tudo
64+
</button>
65+
</div>
66+
</div>
67+
</div>
68+
)
69+
}

0 commit comments

Comments
 (0)