Skip to content

Commit 7972229

Browse files
authored
Merge pull request #1321 from PlanB-Network/gdpr
feat(gdpr): add gdpr check on event booking
2 parents cd1d6ae + 7a46e81 commit 7972229

File tree

15 files changed

+14191
-8
lines changed

15 files changed

+14191
-8
lines changed

apps/web/public/locales/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,9 @@
811811
"max_capacity": "Max capacity of",
812812
"payment_successful": "Booking successful.",
813813
"time": "Time"
814-
}
814+
},
815+
"tcDisclaimer": "I agree that my information may be shared with organizers for venue access purposes.",
816+
"tcMustBeAccepter": "You must accept the terms to proceed with the purchase"
815817
},
816818
"filters": {
817819
"categories": "Categories",

apps/web/src/routes/$lang/_content/events/-components/event-book-modal.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export const EventBookModal = ({
7272
<ModalBookDescription
7373
accessType={accessType}
7474
onBooked={saveAndDisplaySuccess}
75+
isGdprCompliance={event.isGdprCompliance}
76+
gdprTerms={event.customTcDisclaimer ?? t('events.tcDisclaimer')}
7577
description={
7678
accessType === 'physical'
7779
? t('events.payment.description_free_physical')

apps/web/src/routes/$lang/_content/events/-components/modal-book-description.tsx

+58-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { t } from 'i18next';
22

3-
import { Button } from '@blms/ui';
3+
import { Button, Checkbox } from '@blms/ui';
44

55
import PlanBLogo from '#src/assets/logo/planb_logo_horizontal_black.svg?react';
66
import { PaymentCallout } from '#src/components/payment-callout.js';
77

8-
import type { JSX } from 'react';
8+
import { type JSX, useState } from 'react';
9+
import ReactMarkdown from 'react-markdown';
910

1011
interface ModalBookDescriptionProps {
1112
accessType: 'physical' | 'online' | 'replay';
1213
callout: string;
1314
description: string;
15+
isGdprCompliance: boolean;
16+
gdprTerms: string;
1417
onBooked: () => void;
1518
children?: JSX.Element | JSX.Element[];
1619
}
@@ -19,12 +22,16 @@ export const ModalBookDescription = ({
1922
accessType,
2023
callout,
2124
description,
25+
isGdprCompliance,
26+
gdprTerms,
2227
onBooked,
2328
children,
2429
}: ModalBookDescriptionProps) => {
2530
const splitDescription =
2631
description.includes('\n') && description.split('\n');
2732

33+
const [isBookEnabled, setIsBookEnabled] = useState(!isGdprCompliance);
34+
const [isBtnClicked, setIsBtnClicked] = useState(false);
2835
return (
2936
<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">
3037
<PlanBLogo className="h-auto max-lg:hidden" width={240} />
@@ -40,14 +47,61 @@ export const ModalBookDescription = ({
4047
<p className="text-sm max-lg:text-center">{description}</p>
4148
)}
4249
</div>
43-
4450
{accessType === 'physical' && (
4551
<p className="w-full text-sm max-lg:text-center">
4652
{t('events.payment.additional_free_description')}
4753
</p>
4854
)}
4955
{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+
>
51105
{t('events.payment.book_seat')}
52106
</Button>
53107
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "content"."events" ADD COLUMN "is_gdpr_compliance" boolean DEFAULT false;--> statement-breakpoint
2+
ALTER TABLE "content"."events" ADD COLUMN "custom_tc_disclaimer" text;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "content"."events" ALTER COLUMN "is_gdpr_compliance" SET NOT NULL;

0 commit comments

Comments
 (0)