tf-checkout-react 1.0.101 → 1.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/billing-info-container/index.d.ts +3 -1
- package/dist/components/common/SnackbarAlert.d.ts +13 -0
- package/dist/components/confirmationContainer/index.d.ts +2 -1
- package/dist/components/ticketsContainer/index.d.ts +2 -1
- package/dist/env.d.ts +1 -0
- package/dist/images/done.svg +3 -3
- package/dist/tf-checkout-react.cjs.development.js +242 -117
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +243 -118
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/package.json +89 -89
- package/src/.DS_Store +0 -0
- package/src/.d.ts +2 -2
- package/src/api/index.ts +278 -278
- package/src/assets/images/done.svg +3 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/billing-info-container/index.tsx +796 -777
- package/src/components/billing-info-container/style.css +105 -105
- package/src/components/billing-info-container/utils.ts +224 -224
- package/src/components/common/CheckboxField.tsx +41 -41
- package/src/components/common/CustomField.tsx +84 -84
- package/src/components/common/FormikPhoneNumberField.tsx +51 -51
- package/src/components/common/Loader.tsx +9 -9
- package/src/components/common/RadioField.tsx +35 -35
- package/src/components/common/SelectField.tsx +80 -80
- package/src/components/common/SnackbarAlert.tsx +54 -0
- package/src/components/common/index.tsx +4 -4
- package/src/components/confirmModal/index.tsx +51 -51
- package/src/components/confirmModal/style.css +21 -21
- package/src/components/confirmationContainer/config.ts +72 -72
- package/src/components/confirmationContainer/index.tsx +197 -194
- package/src/components/confirmationContainer/social-buttons.tsx +94 -94
- package/src/components/confirmationContainer/style.css +202 -202
- package/src/components/countdown/index.tsx +89 -89
- package/src/components/countdown/style.css +9 -9
- package/src/components/index.ts +7 -7
- package/src/components/loginModal/index.tsx +209 -209
- package/src/components/loginModal/style.css +71 -71
- package/src/components/myTicketsContainer/index.tsx +196 -137
- package/src/components/myTicketsContainer/row.tsx +41 -41
- package/src/components/myTicketsContainer/style.css +39 -39
- package/src/components/myTicketsContainer/tableConfig.tsx +34 -34
- package/src/components/orderDetailsContainer/index.tsx +249 -249
- package/src/components/orderDetailsContainer/style.css +72 -72
- package/src/components/orderDetailsContainer/ticketsTable.tsx +124 -124
- package/src/components/paymentContainer/index.tsx +284 -284
- package/src/components/registerModal/index.tsx +190 -190
- package/src/components/stripePayment/index.tsx +253 -253
- package/src/components/stripePayment/style.css +59 -59
- package/src/components/ticketResale/index.tsx +56 -56
- package/src/components/ticketResaleModal/index.tsx +210 -210
- package/src/components/ticketResaleModal/style.css +28 -28
- package/src/components/ticketsContainer/PromoCodeSection.tsx +99 -99
- package/src/components/ticketsContainer/ReferralLogic.tsx +33 -33
- package/src/components/ticketsContainer/TicketRow.tsx +83 -83
- package/src/components/ticketsContainer/TicketsSection.tsx +81 -81
- package/src/components/ticketsContainer/index.tsx +430 -422
- package/src/components/ticketsContainer/style.css +181 -181
- package/src/components/ticketsContainer/utils.ts +11 -11
- package/src/components/timerWidget/index.tsx +70 -70
- package/src/components/timerWidget/style.css +26 -26
- package/src/components/waitingList/index.tsx +178 -178
- package/src/components/waitingList/style.css +26 -26
- package/src/env.ts +20 -19
- package/src/index.ts +13 -13
- package/src/normalizers/index.ts +45 -45
- package/src/types/billing-info-data.ts +37 -37
- package/src/types/payment-field.ts +7 -7
- package/src/types/referral-promotion.ts +7 -7
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +59 -59
- package/src/utils/downloadPDF.tsx +30 -30
- package/src/utils/formikErrorFocus.ts +24 -24
- package/src/utils/getImage.ts +14 -14
- package/src/utils/getQueryVariable.ts +13 -13
- package/src/utils/index.ts +5 -5
- package/src/utils/setConfigs.ts +26 -26
- package/src/utils/showZero.tsx +10 -10
- package/src/validators/index.ts +20 -20
|
@@ -1,422 +1,430 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import axios, { AxiosError } from 'axios'
|
|
3
|
-
import { Loader } from '../common/index'
|
|
4
|
-
import './style.css'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
getTickets,
|
|
8
|
-
getEvent,
|
|
9
|
-
addToCart,
|
|
10
|
-
setCustomHeader,
|
|
11
|
-
postOnCheckout,
|
|
12
|
-
} from '../../api'
|
|
13
|
-
import _get from 'lodash/get'
|
|
14
|
-
import _some from 'lodash/some'
|
|
15
|
-
import _every from 'lodash/every'
|
|
16
|
-
import _find from 'lodash/find'
|
|
17
|
-
import _isEmpty from 'lodash/isEmpty'
|
|
18
|
-
import Button from 'react-bootstrap/Button'
|
|
19
|
-
import jwt_decode from 'jwt-decode'
|
|
20
|
-
import { TicketsSection } from './TicketsSection'
|
|
21
|
-
import WaitingList from '../waitingList'
|
|
22
|
-
import { PromoCodeSection } from './PromoCodeSection'
|
|
23
|
-
import { LoginModal } from '../loginModal'
|
|
24
|
-
import Countdown from '../countdown'
|
|
25
|
-
import { createCheckoutDataBodyWithDefaultHolder, getQueryVariable } from '../../utils'
|
|
26
|
-
import { ThemeProvider } from '@mui/private-theming'
|
|
27
|
-
import { createTheme, ThemeOptions } from '@mui/material'
|
|
28
|
-
import { CSSProperties } from '@mui/styles'
|
|
29
|
-
import { ReferralLogic } from './ReferralLogic'
|
|
30
|
-
|
|
31
|
-
interface CartSuccess {
|
|
32
|
-
skip_billing_page: boolean;
|
|
33
|
-
names_required: boolean;
|
|
34
|
-
age_required: boolean;
|
|
35
|
-
phone_required: boolean;
|
|
36
|
-
event_id: string;
|
|
37
|
-
hash?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface IGetTickets {
|
|
41
|
-
eventId: number;
|
|
42
|
-
onAddToCartSuccess: (response: CartSuccess) => void;
|
|
43
|
-
getTicketsLabel?: string;
|
|
44
|
-
contentStyle?: React.CSSProperties;
|
|
45
|
-
onAddToCartError: (e: AxiosError) => void;
|
|
46
|
-
onGetTicketsSuccess: (response: any) => void;
|
|
47
|
-
onGetTicketsError: (e: AxiosError) => void;
|
|
48
|
-
onLoginSuccess: () => void;
|
|
49
|
-
|
|
50
|
-
theme?: 'light' | 'dark';
|
|
51
|
-
queryPromoCode?: string;
|
|
52
|
-
isPromotionsEnabled?: boolean;
|
|
53
|
-
themeOptions?: ThemeOptions & { input?: CSSProperties; checkbox?: CSSProperties }
|
|
54
|
-
isAccessCodeEnabled?: boolean;
|
|
55
|
-
hideSessionButtons?: boolean;
|
|
56
|
-
hideWaitingList?: boolean;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const [
|
|
95
|
-
const [
|
|
96
|
-
const [
|
|
97
|
-
const [
|
|
98
|
-
const [
|
|
99
|
-
const [
|
|
100
|
-
const [
|
|
101
|
-
const [
|
|
102
|
-
const [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
window.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
isWindowDefined && window.localStorage.getItem('
|
|
258
|
-
? window.localStorage.getItem('
|
|
259
|
-
:
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
tickets,
|
|
303
|
-
item => (item.
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import axios, { AxiosError } from 'axios'
|
|
3
|
+
import { Loader } from '../common/index'
|
|
4
|
+
import './style.css'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
getTickets,
|
|
8
|
+
getEvent,
|
|
9
|
+
addToCart,
|
|
10
|
+
setCustomHeader,
|
|
11
|
+
postOnCheckout,
|
|
12
|
+
} from '../../api'
|
|
13
|
+
import _get from 'lodash/get'
|
|
14
|
+
import _some from 'lodash/some'
|
|
15
|
+
import _every from 'lodash/every'
|
|
16
|
+
import _find from 'lodash/find'
|
|
17
|
+
import _isEmpty from 'lodash/isEmpty'
|
|
18
|
+
import Button from 'react-bootstrap/Button'
|
|
19
|
+
import jwt_decode from 'jwt-decode'
|
|
20
|
+
import { TicketsSection } from './TicketsSection'
|
|
21
|
+
import WaitingList from '../waitingList'
|
|
22
|
+
import { PromoCodeSection } from './PromoCodeSection'
|
|
23
|
+
import { LoginModal } from '../loginModal'
|
|
24
|
+
import Countdown from '../countdown'
|
|
25
|
+
import { createCheckoutDataBodyWithDefaultHolder, getQueryVariable } from '../../utils'
|
|
26
|
+
import { ThemeProvider } from '@mui/private-theming'
|
|
27
|
+
import { createTheme, ThemeOptions } from '@mui/material'
|
|
28
|
+
import { CSSProperties } from '@mui/styles'
|
|
29
|
+
import { ReferralLogic } from './ReferralLogic'
|
|
30
|
+
|
|
31
|
+
interface CartSuccess {
|
|
32
|
+
skip_billing_page: boolean;
|
|
33
|
+
names_required: boolean;
|
|
34
|
+
age_required: boolean;
|
|
35
|
+
phone_required: boolean;
|
|
36
|
+
event_id: string;
|
|
37
|
+
hash?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface IGetTickets {
|
|
41
|
+
eventId: number;
|
|
42
|
+
onAddToCartSuccess: (response: CartSuccess) => void;
|
|
43
|
+
getTicketsLabel?: string;
|
|
44
|
+
contentStyle?: React.CSSProperties;
|
|
45
|
+
onAddToCartError: (e: AxiosError) => void;
|
|
46
|
+
onGetTicketsSuccess: (response: any) => void;
|
|
47
|
+
onGetTicketsError: (e: AxiosError) => void;
|
|
48
|
+
onLoginSuccess: () => void;
|
|
49
|
+
|
|
50
|
+
theme?: 'light' | 'dark';
|
|
51
|
+
queryPromoCode?: string;
|
|
52
|
+
isPromotionsEnabled?: boolean;
|
|
53
|
+
themeOptions?: ThemeOptions & { input?: CSSProperties; checkbox?: CSSProperties }
|
|
54
|
+
isAccessCodeEnabled?: boolean;
|
|
55
|
+
hideSessionButtons?: boolean;
|
|
56
|
+
hideWaitingList?: boolean;
|
|
57
|
+
isButtonScrollable?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ITicket {
|
|
61
|
+
id: string | number;
|
|
62
|
+
[key: string]: string | number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ISelectedTickets {
|
|
66
|
+
[key: string]: string | number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const TicketsContainer = ({
|
|
70
|
+
onLoginSuccess,
|
|
71
|
+
getTicketsLabel,
|
|
72
|
+
eventId,
|
|
73
|
+
onAddToCartSuccess,
|
|
74
|
+
contentStyle = {},
|
|
75
|
+
onAddToCartError = () => {},
|
|
76
|
+
onGetTicketsSuccess = () => {},
|
|
77
|
+
onGetTicketsError = () => {},
|
|
78
|
+
theme = 'light',
|
|
79
|
+
queryPromoCode = '',
|
|
80
|
+
isPromotionsEnabled = true,
|
|
81
|
+
themeOptions,
|
|
82
|
+
isAccessCodeEnabled = false,
|
|
83
|
+
hideSessionButtons = false,
|
|
84
|
+
hideWaitingList = false,
|
|
85
|
+
isButtonScrollable = false
|
|
86
|
+
}: IGetTickets) => {
|
|
87
|
+
const [selectedTickets, setSelectedTickets] = useState(
|
|
88
|
+
{} as ISelectedTickets
|
|
89
|
+
)
|
|
90
|
+
const isWindowDefined = typeof window !== 'undefined'
|
|
91
|
+
const [isLogged, setIsLogged] = useState(
|
|
92
|
+
isWindowDefined ? !!window.localStorage.getItem('access_token') : false
|
|
93
|
+
)
|
|
94
|
+
const [showLoginModal, setShowLoginModal] = useState(false)
|
|
95
|
+
const [tickets, setTickets] = useState([] as ITicket[])
|
|
96
|
+
const [event, setEvent] = useState<any>(null)
|
|
97
|
+
const [showWaitingList, setShowWaitingList] = useState(false)
|
|
98
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
99
|
+
const [isPromoLoading, setIsPromoLoading] = useState(false)
|
|
100
|
+
const [handleBookIsLoading, setHandleBookIsLoading] = useState(false)
|
|
101
|
+
const [promoCode, setPromoCode] = useState('')
|
|
102
|
+
const [promoCodeUpdated, setPromoCodeUpdated] = useState(getQueryVariable('r') || queryPromoCode)
|
|
103
|
+
const [showPromoInput, setShowPromoInput] = useState(false)
|
|
104
|
+
const [promoCodeIsApplied, setPromoCodeIsApplied] = useState(false)
|
|
105
|
+
|
|
106
|
+
const ticketsContainerRef = useRef<HTMLDivElement>(null)
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (typeof window !== 'undefined') {
|
|
110
|
+
const access_token = window.localStorage.getItem('access_token')
|
|
111
|
+
if (access_token) {
|
|
112
|
+
const decoded = jwt_decode<{ exp: number }>(access_token)
|
|
113
|
+
if (decoded && decoded.exp < Date.now() / 1000) {
|
|
114
|
+
window.localStorage.removeItem('access_token')
|
|
115
|
+
window.localStorage.removeItem('user_data')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, [])
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
!!eventId && getTicketsApi(!!promoCodeUpdated)
|
|
123
|
+
}, [eventId, promoCodeUpdated])
|
|
124
|
+
|
|
125
|
+
const handleLogout = () => {
|
|
126
|
+
if (isWindowDefined) {
|
|
127
|
+
window.localStorage.removeItem('access_token')
|
|
128
|
+
window.localStorage.removeItem('user_data')
|
|
129
|
+
setIsLogged(false)
|
|
130
|
+
const event = new window.CustomEvent('tf-logout')
|
|
131
|
+
window.document.dispatchEvent(event)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
try {
|
|
137
|
+
if (typeof window !== 'undefined') {
|
|
138
|
+
const userData = window.localStorage.getItem('user_data')
|
|
139
|
+
? JSON.parse(window.localStorage.getItem('user_data') || '{}')
|
|
140
|
+
: {}
|
|
141
|
+
if (userData.country === '') {
|
|
142
|
+
handleLogout()
|
|
143
|
+
window.open("https://www.ticketfairy.com/account/change_information?need_country=true");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch(e) {}
|
|
147
|
+
}, [])
|
|
148
|
+
|
|
149
|
+
const handleExternalLogin = () => {
|
|
150
|
+
setIsLogged(true)
|
|
151
|
+
}
|
|
152
|
+
const handleOnClose = () => {
|
|
153
|
+
setShowLoginModal(false)
|
|
154
|
+
}
|
|
155
|
+
const handleOnLogin = () => {
|
|
156
|
+
setShowLoginModal(false)
|
|
157
|
+
setIsLogged(true)
|
|
158
|
+
if (onLoginSuccess) {
|
|
159
|
+
onLoginSuccess()
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function getTicketsApi(isUpdateingPromoCode?: boolean) {
|
|
164
|
+
try {
|
|
165
|
+
!isUpdateingPromoCode && setIsLoading(true)
|
|
166
|
+
setIsPromoLoading(true)
|
|
167
|
+
const response = await getTickets(eventId, promoCodeUpdated)
|
|
168
|
+
const eventResponse = await getEvent(eventId)
|
|
169
|
+
if (response.data.success) {
|
|
170
|
+
setCustomHeader(response)
|
|
171
|
+
const attributes = _get(response, 'data.data.attributes')
|
|
172
|
+
setPromoCodeIsApplied(attributes.ValidPromoCode)
|
|
173
|
+
setTickets(_get(attributes, 'tickets'))
|
|
174
|
+
setShowWaitingList(attributes.showWaitingList)
|
|
175
|
+
onGetTicketsSuccess(response.data)
|
|
176
|
+
setPromoCode('')
|
|
177
|
+
}
|
|
178
|
+
if (eventResponse.data.success) {
|
|
179
|
+
const event = _get(eventResponse, 'data.data.attributes')
|
|
180
|
+
setEvent(event)
|
|
181
|
+
}
|
|
182
|
+
} catch (e) {
|
|
183
|
+
if (axios.isAxiosError(e)) {
|
|
184
|
+
onGetTicketsError(e)
|
|
185
|
+
}
|
|
186
|
+
} finally {
|
|
187
|
+
setIsLoading(false)
|
|
188
|
+
setIsPromoLoading(false)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const handleTicketSelect = (key: string, value: number | string) => {
|
|
193
|
+
setSelectedTickets(prevState => {
|
|
194
|
+
if (Object.keys(prevState)[0] !== key && !value) {
|
|
195
|
+
return prevState
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
[key]: value,
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const handleOrdersClick = () => {
|
|
204
|
+
if (isWindowDefined) {
|
|
205
|
+
window.location.href = '/orders'
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const handleBook = async () => {
|
|
210
|
+
setHandleBookIsLoading(true)
|
|
211
|
+
const ticket =
|
|
212
|
+
_find(tickets, item => selectedTickets[item.id] > 0) || ({} as ITicket)
|
|
213
|
+
const optionName = _get(ticket, 'optionName')
|
|
214
|
+
const ticketId = _get(ticket, 'id')
|
|
215
|
+
const ticketQuantity = +selectedTickets[ticket.id]
|
|
216
|
+
|
|
217
|
+
const data = {
|
|
218
|
+
attributes: {
|
|
219
|
+
alternative_view_id: null,
|
|
220
|
+
product_cart_quantity: ticketQuantity,
|
|
221
|
+
product_options: {
|
|
222
|
+
[optionName]: ticketId,
|
|
223
|
+
},
|
|
224
|
+
product_id: eventId,
|
|
225
|
+
ticket_types: {
|
|
226
|
+
[ticketId]: {
|
|
227
|
+
product_options: {
|
|
228
|
+
[optionName]: ticketId,
|
|
229
|
+
ticket_price: ticket.price,
|
|
230
|
+
},
|
|
231
|
+
quantity: ticketQuantity,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
const result = await addToCart(eventId, data)
|
|
239
|
+
if (result.status === 200) {
|
|
240
|
+
setCustomHeader(result)
|
|
241
|
+
|
|
242
|
+
const skipBillingPage =
|
|
243
|
+
result?.data?.data?.attributes?.skip_billing_page ?? false
|
|
244
|
+
const nameIsRequired =
|
|
245
|
+
result?.data?.data?.attributes?.names_required ?? false
|
|
246
|
+
const ageIsRequired =
|
|
247
|
+
result?.data?.data?.attributes?.age_required ?? false
|
|
248
|
+
const phoneIsRequired =
|
|
249
|
+
result?.data?.data?.attributes?.phone_required ?? false
|
|
250
|
+
|
|
251
|
+
let hash = ''
|
|
252
|
+
|
|
253
|
+
if (skipBillingPage) {
|
|
254
|
+
// Get user data for checkout data
|
|
255
|
+
const isWindowDefined = typeof window !== 'undefined'
|
|
256
|
+
const userData =
|
|
257
|
+
isWindowDefined && window.localStorage.getItem('user_data')
|
|
258
|
+
? JSON.parse(window.localStorage.getItem('user_data') || '')
|
|
259
|
+
: {}
|
|
260
|
+
|
|
261
|
+
const access_token =
|
|
262
|
+
isWindowDefined && window.localStorage.getItem('access_token')
|
|
263
|
+
? window.localStorage.getItem('access_token') || ''
|
|
264
|
+
: ''
|
|
265
|
+
|
|
266
|
+
const checkoutBody = createCheckoutDataBodyWithDefaultHolder(
|
|
267
|
+
ticketQuantity,
|
|
268
|
+
userData
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
const checkoutResult = await postOnCheckout(
|
|
272
|
+
checkoutBody,
|
|
273
|
+
access_token
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
hash = _get(checkoutResult, 'data.data.attributes.hash')
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
onAddToCartSuccess({
|
|
280
|
+
skip_billing_page: skipBillingPage,
|
|
281
|
+
names_required: nameIsRequired,
|
|
282
|
+
phone_required: phoneIsRequired,
|
|
283
|
+
age_required: ageIsRequired,
|
|
284
|
+
event_id: String(eventId),
|
|
285
|
+
hash,
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
} catch (e) {
|
|
289
|
+
if (axios.isAxiosError(e)) {
|
|
290
|
+
onAddToCartError(e)
|
|
291
|
+
}
|
|
292
|
+
} finally {
|
|
293
|
+
setHandleBookIsLoading(false)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const updateTickets = () => {
|
|
298
|
+
getTicketsApi()
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const isAllTicketsSoldOut = _every(
|
|
302
|
+
tickets,
|
|
303
|
+
item => (item.sold_out || item.soldOut)
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
const isTicketOnSale = _some(
|
|
307
|
+
tickets,
|
|
308
|
+
item => (item.salesStarted && !item.salesEnded && !item.soldOut)
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
const themeMui = createTheme(themeOptions)
|
|
312
|
+
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
isWindowDefined &&
|
|
315
|
+
window.document.addEventListener('custom-logout', handleLogout)
|
|
316
|
+
return () => {
|
|
317
|
+
isWindowDefined &&
|
|
318
|
+
window.document.removeEventListener('custom-logout', handleLogout)
|
|
319
|
+
}
|
|
320
|
+
}, [])
|
|
321
|
+
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
isWindowDefined &&
|
|
324
|
+
window.document.addEventListener('custom-login', handleExternalLogin)
|
|
325
|
+
return () => {
|
|
326
|
+
isWindowDefined &&
|
|
327
|
+
window.document.removeEventListener(
|
|
328
|
+
'custom-login',
|
|
329
|
+
handleExternalLogin
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
}, [])
|
|
333
|
+
|
|
334
|
+
const handleGetTicketClick = () => {
|
|
335
|
+
if (!handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0) {
|
|
336
|
+
handleBook()
|
|
337
|
+
} else {
|
|
338
|
+
if (isButtonScrollable && ticketsContainerRef && ticketsContainerRef.current) {
|
|
339
|
+
ticketsContainerRef.current.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' })
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const bookButtonIsDisabled = handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0
|
|
345
|
+
|
|
346
|
+
return (
|
|
347
|
+
<ThemeProvider theme={themeMui}>
|
|
348
|
+
<ReferralLogic eventId={eventId} />
|
|
349
|
+
<div className={`get-tickets-page ${theme}`} style={contentStyle}>
|
|
350
|
+
{isLoading ? (
|
|
351
|
+
<Loader />
|
|
352
|
+
) : (
|
|
353
|
+
<div ref={ticketsContainerRef}>
|
|
354
|
+
<TicketsSection
|
|
355
|
+
ticketsList={tickets}
|
|
356
|
+
selectedTickets={selectedTickets}
|
|
357
|
+
handleTicketSelect={handleTicketSelect}
|
|
358
|
+
promoCodeIsApplied={promoCodeIsApplied}
|
|
359
|
+
/>
|
|
360
|
+
{event?.salesEnded ? (
|
|
361
|
+
<p className='event-closed-message'>Sales for this event are closed.</p>
|
|
362
|
+
) : !event?.salesStarted && event?.salesStart ? (
|
|
363
|
+
<Countdown
|
|
364
|
+
startDate={event.salesStart}
|
|
365
|
+
timezone={event.timezone}
|
|
366
|
+
title="Sales start in:"
|
|
367
|
+
message="No tickets are currently available for this event."
|
|
368
|
+
callback={updateTickets}
|
|
369
|
+
/>
|
|
370
|
+
) : null}
|
|
371
|
+
{showWaitingList && event.salesStarted && !hideWaitingList && (
|
|
372
|
+
<WaitingList tickets={tickets} eventId={eventId} />
|
|
373
|
+
)}
|
|
374
|
+
<PromoCodeSection
|
|
375
|
+
promoCode={promoCode}
|
|
376
|
+
promoCodeIsApplied={promoCodeIsApplied}
|
|
377
|
+
showPromoInput={showPromoInput}
|
|
378
|
+
setPromoCode={setPromoCode}
|
|
379
|
+
setPromoCodeUpdated={setPromoCodeUpdated}
|
|
380
|
+
setShowPromoInput={setShowPromoInput}
|
|
381
|
+
isPromotionsEnabled={isPromotionsEnabled}
|
|
382
|
+
isAccessCodeEnabled={isAccessCodeEnabled}
|
|
383
|
+
isAllTicketsSoldOut={isAllTicketsSoldOut}
|
|
384
|
+
isPromoLoading={isPromoLoading}
|
|
385
|
+
/>
|
|
386
|
+
{(isTicketOnSale || !event?.salesEnded) && (
|
|
387
|
+
<Button
|
|
388
|
+
aria-hidden={true}
|
|
389
|
+
className={`book-button
|
|
390
|
+
${bookButtonIsDisabled ? 'disabled' : ''}
|
|
391
|
+
${isButtonScrollable ? 'is-scrollable' : ''}
|
|
392
|
+
`}
|
|
393
|
+
onClick={handleGetTicketClick}
|
|
394
|
+
>
|
|
395
|
+
{getTicketsLabel || 'GET TICKETS'}
|
|
396
|
+
</Button>
|
|
397
|
+
)}
|
|
398
|
+
{isLogged && !hideSessionButtons ? (
|
|
399
|
+
<div className="session-wrapper">
|
|
400
|
+
<span className="session-container">
|
|
401
|
+
<Button
|
|
402
|
+
variant="outline-light"
|
|
403
|
+
className="session-buttons"
|
|
404
|
+
onClick={handleOrdersClick}
|
|
405
|
+
>
|
|
406
|
+
My Orders
|
|
407
|
+
</Button>
|
|
408
|
+
</span>
|
|
409
|
+
<span className="session-container">
|
|
410
|
+
<Button
|
|
411
|
+
variant="outline-light"
|
|
412
|
+
className="session-buttons"
|
|
413
|
+
onClick={handleLogout}
|
|
414
|
+
>
|
|
415
|
+
Log out
|
|
416
|
+
</Button>
|
|
417
|
+
</span>
|
|
418
|
+
</div>
|
|
419
|
+
) : (
|
|
420
|
+
''
|
|
421
|
+
)}
|
|
422
|
+
</div>
|
|
423
|
+
)}
|
|
424
|
+
{showLoginModal ? (
|
|
425
|
+
<LoginModal onClose={handleOnClose} onLogin={handleOnLogin} />
|
|
426
|
+
) : null}
|
|
427
|
+
</div>
|
|
428
|
+
</ThemeProvider>
|
|
429
|
+
)
|
|
430
|
+
}
|