-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathCookieNotice.tsx
79 lines (76 loc) · 2.68 KB
/
CookieNotice.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { useEffect, useState } from "react"
import classnames from "classnames"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import { faCheck } from "@fortawesome/free-solid-svg-icons"
import { Action, getTodayDate } from "./cookiePreferences.js"
export const CookieNotice = ({
accepted,
outdated,
dispatch,
}: {
accepted: boolean
outdated: boolean
dispatch: any
}) => {
const [mounted, setMounted] = useState(false)
useEffect(() => {
setTimeout(() => {
setMounted(true)
}, 200)
}, [])
return (
<div
className={classnames("cookie-notice", {
open: mounted && (!accepted || outdated),
})}
data-test="cookie-notice"
>
<div className="cookie-notice__inner">
<div>
<p className="cookie-notice__text">
We use cookies to give you the best experience on our
website.
</p>
<p className="cookie-notice__text">
By agreeing, you consent to our use of cookies and other
analytics tools according to{" "}
<a href="/privacy-policy">our privacy policy</a>.
</p>
</div>
<div className="actions">
<button
aria-label="Reject cookies"
className="button"
onClick={() =>
dispatch({
type: Action.Reject,
payload: { date: getTodayDate() },
})
}
data-test="reject"
data-track-note="cookie_notice"
>
No thanks
</button>
<button
aria-label="Accept cookies"
className="button accept"
onClick={() =>
dispatch({
type: Action.Accept,
payload: { date: getTodayDate() },
})
}
data-test="accept"
data-track-note="cookie_notice"
>
<span className="icon">
<FontAwesomeIcon icon={faCheck} />
</span>
I agree
</button>
</div>
</div>
</div>
)
}