1
1
import { useEffect , useState } from "react"
2
- import { Checkbox , Flex } from "@chakra-ui/react"
3
2
4
3
import Text from "@/components/OldText"
5
4
6
5
import { MATOMO_LS_KEY } from "@/lib/utils/matomo"
7
6
7
+ import Checkbox from "../../tailwind/ui/Checkbox"
8
+
8
9
const MatomoOptOut = ( ) => {
9
10
const [ loading , setLoading ] = useState < boolean > ( true )
10
11
const [ isOptedOut , setIsOptedOut ] = useState < boolean > ( false )
@@ -22,28 +23,15 @@ const MatomoOptOut = () => {
22
23
setLoading ( false )
23
24
} , [ ] )
24
25
25
- const handleCheckbox = ( {
26
- target : { checked } ,
27
- } : React . ChangeEvent < HTMLInputElement > ) : void => {
26
+ const handleCheckbox = ( checked : boolean ) : void => {
28
27
// Set local opt-out state based on check mark
29
28
// Note: `checked` in the UI refers to being opted-in
30
29
setIsOptedOut ( ! checked )
31
30
// Save selection to localStorage
32
31
localStorage . setItem ( MATOMO_LS_KEY , String ( ! checked ) )
33
32
}
34
33
return (
35
- < Flex
36
- border = "1px solid"
37
- borderColor = "border"
38
- bgColor = "background.base"
39
- borderRadius = "base"
40
- p = { 6 }
41
- direction = "column"
42
- mb = { 4 }
43
- mt = { 8 }
44
- align = "flex-start"
45
- justify = "space-between"
46
- >
34
+ < div className = "mb-4 mt-8 flex flex-col rounded border border-body-light bg-background p-6" >
47
35
< Text color = "fail" >
48
36
You can opt out of being tracked by Matomo Analytics and prevent the
49
37
website from analysing the actions you take using the website. This will
@@ -53,18 +41,21 @@ const MatomoOptOut = () => {
53
41
{ loading ? (
54
42
"Loading preferences..."
55
43
) : (
56
- < Checkbox
57
- id = "matomo"
58
- isChecked = { ! isOptedOut }
59
- onChange = { handleCheckbox }
60
- me = { 2 }
61
- >
62
- { isOptedOut
63
- ? "You are opted out. Check this box to opt-in."
64
- : "You are not opted out. Uncheck this box to opt-out." }
65
- </ Checkbox >
44
+ < div className = "flex items-center" >
45
+ < Checkbox
46
+ id = "matomo"
47
+ checked = { ! isOptedOut }
48
+ onCheckedChange = { handleCheckbox }
49
+ className = "me-2"
50
+ />
51
+ < label htmlFor = "matomo" >
52
+ { isOptedOut
53
+ ? "You are opted out. Check this box to opt-in."
54
+ : "You are not opted out. Uncheck this box to opt-out." }
55
+ </ label >
56
+ </ div >
66
57
) }
67
- </ Flex >
58
+ </ div >
68
59
)
69
60
}
70
61
0 commit comments