1
1
import { t } from 'i18next' ;
2
2
3
- import { Button } from '@blms/ui' ;
3
+ import { Button , Checkbox } from '@blms/ui' ;
4
4
5
5
import PlanBLogo from '#src/assets/logo/planb_logo_horizontal_black.svg?react' ;
6
6
import { PaymentCallout } from '#src/components/payment-callout.js' ;
7
7
8
- import type { JSX } from 'react' ;
8
+ import { type JSX , useState } from 'react' ;
9
+ import ReactMarkdown from 'react-markdown' ;
9
10
10
11
interface ModalBookDescriptionProps {
11
12
accessType : 'physical' | 'online' | 'replay' ;
12
13
callout : string ;
13
14
description : string ;
15
+ isGdprCompliance : boolean ;
16
+ gdprTerms : string ;
14
17
onBooked : ( ) => void ;
15
18
children ?: JSX . Element | JSX . Element [ ] ;
16
19
}
@@ -19,12 +22,16 @@ export const ModalBookDescription = ({
19
22
accessType,
20
23
callout,
21
24
description,
25
+ isGdprCompliance,
26
+ gdprTerms,
22
27
onBooked,
23
28
children,
24
29
} : ModalBookDescriptionProps ) => {
25
30
const splitDescription =
26
31
description . includes ( '\n' ) && description . split ( '\n' ) ;
27
32
33
+ const [ isBookEnabled , setIsBookEnabled ] = useState ( ! isGdprCompliance ) ;
34
+ const [ isBtnClicked , setIsBtnClicked ] = useState ( false ) ;
28
35
return (
29
36
< div className = "items-center justify-center w-full max-w-96 lg:w-96 flex flex-col gap-6 max-lg:pb-6 max-lg:pt-8" >
30
37
< PlanBLogo className = "h-auto max-lg:hidden" width = { 240 } />
@@ -40,14 +47,61 @@ export const ModalBookDescription = ({
40
47
< p className = "text-sm max-lg:text-center" > { description } </ p >
41
48
) }
42
49
</ div >
43
-
44
50
{ accessType === 'physical' && (
45
51
< p className = "w-full text-sm max-lg:text-center" >
46
52
{ t ( 'events.payment.additional_free_description' ) }
47
53
</ p >
48
54
) }
49
55
{ children }
50
- < Button variant = "primary" className = "lg:w-full" onClick = { onBooked } >
56
+
57
+ { isGdprCompliance ? (
58
+ < div className = "flex items-center space-x-2" >
59
+ < Checkbox
60
+ id = "terms"
61
+ className = "self-start mt-[2px]"
62
+ checked = { isBookEnabled }
63
+ onCheckedChange = { ( e : boolean ) => {
64
+ setIsBookEnabled ( e ) ;
65
+ console . log ( e ) ;
66
+ } }
67
+ />
68
+ < label htmlFor = "terms" className = "text-sm" >
69
+ < ReactMarkdown
70
+ components = { {
71
+ a : ( { children, href } ) => (
72
+ < a
73
+ href = { href }
74
+ target = "_blank"
75
+ className = " text-darkOrange-5 "
76
+ rel = "noreferrer"
77
+ >
78
+ { children }
79
+ </ a >
80
+ ) ,
81
+ } }
82
+ >
83
+ { gdprTerms }
84
+ </ ReactMarkdown >
85
+ </ label >
86
+ </ div >
87
+ ) : null }
88
+
89
+ { ! isBookEnabled && isBtnClicked ? (
90
+ < p className = "text-red-6 text-sm self-start" >
91
+ { t ( 'events.tcMustBeAccepter' ) }
92
+ </ p >
93
+ ) : null }
94
+
95
+ < Button
96
+ variant = "primary"
97
+ className = "lg:w-full"
98
+ onClick = { ( ) => {
99
+ setIsBtnClicked ( true ) ;
100
+ if ( isBookEnabled ) {
101
+ onBooked ( ) ;
102
+ }
103
+ } }
104
+ >
51
105
{ t ( 'events.payment.book_seat' ) }
52
106
</ Button >
53
107
</ div >
0 commit comments