tf-checkout-react 1.0.99 → 1.0.100-beta.2
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/README.md +278 -1
- package/dist/api/index.d.ts +31 -26
- package/dist/components/account-settings/index.d.ts +3 -0
- package/dist/components/billing-info-container/index.d.ts +5 -5
- package/dist/components/billing-info-container/utils.d.ts +1 -0
- package/dist/components/common/CustomField.d.ts +1 -1
- package/dist/components/common/DatePickerField.d.ts +14 -0
- package/dist/components/common/RedirectModal.d.ts +7 -0
- package/dist/components/common/SnackbarAlert.d.ts +13 -0
- package/dist/components/confirmationContainer/index.d.ts +2 -1
- package/dist/components/countdown/index.d.ts +4 -1
- package/dist/components/myTicketsContainer/tableConfig.d.ts +0 -1
- package/dist/components/orderDetailsContainer/index.d.ts +5 -1
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +4 -1
- package/dist/components/paymentContainer/index.d.ts +3 -1
- package/dist/components/rsvpContainer/index.d.ts +7 -0
- package/dist/components/stripePayment/index.d.ts +2 -1
- package/dist/components/ticketResale/index.d.ts +5 -3
- package/dist/components/ticketsContainer/AccessCodeSection.d.ts +7 -0
- package/dist/components/ticketsContainer/PromoCodeSection.d.ts +6 -9
- package/dist/components/ticketsContainer/TicketsSection.d.ts +5 -3
- package/dist/components/ticketsContainer/index.d.ts +13 -2
- package/dist/components/timerWidget/index.d.ts +3 -3
- package/dist/env.d.ts +1 -0
- package/dist/images/cross.svg +44 -0
- package/dist/images/done.svg +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/tf-checkout-react.cjs.development.js +1400 -575
- 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 +1409 -586
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/dist/utils/cookies.d.ts +3 -0
- package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +6 -1
- package/dist/utils/downloadPDF.d.ts +1 -1
- package/dist/utils/getDomain.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/package.json +89 -89
- package/src/.DS_Store +0 -0
- package/src/.d.ts +2 -2
- package/src/api/index.ts +313 -278
- package/src/assets/images/cross.svg +44 -0
- package/src/assets/images/done.svg +3 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/account-settings/index.tsx +161 -0
- package/src/components/account-settings/style.css +200 -0
- package/src/components/billing-info-container/index.tsx +821 -777
- package/src/components/billing-info-container/style.css +106 -106
- package/src/components/billing-info-container/utils.ts +233 -223
- package/src/components/common/CheckboxField.tsx +41 -41
- package/src/components/common/CustomField.tsx +87 -84
- package/src/components/common/DatePickerField.tsx +98 -0
- 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/RedirectModal.tsx +43 -0
- package/src/components/common/SelectField.tsx +80 -80
- package/src/components/common/SnackbarAlert.tsx +54 -0
- package/src/components/common/dist/PhoneNumberField.js +96 -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 +100 -89
- package/src/components/countdown/style.css +9 -9
- package/src/components/index.ts +7 -7
- package/src/components/loginModal/index.tsx +171 -209
- package/src/components/loginModal/style.css +71 -71
- package/src/components/myTicketsContainer/index.tsx +201 -137
- package/src/components/myTicketsContainer/row.tsx +41 -41
- package/src/components/myTicketsContainer/style.css +40 -40
- package/src/components/myTicketsContainer/tableConfig.tsx +32 -34
- package/src/components/orderDetailsContainer/index.tsx +289 -249
- package/src/components/orderDetailsContainer/style.css +73 -73
- package/src/components/orderDetailsContainer/ticketsTable.tsx +177 -124
- package/src/components/paymentContainer/index.tsx +352 -284
- package/src/components/registerModal/index.tsx +183 -190
- package/src/components/rsvpContainer/index.tsx +126 -0
- package/src/components/stripePayment/index.tsx +258 -253
- package/src/components/stripePayment/style.css +60 -60
- package/src/components/ticketResale/index.tsx +74 -56
- package/src/components/ticketResaleModal/index.tsx +213 -210
- package/src/components/ticketResaleModal/style.css +28 -28
- package/src/components/ticketsContainer/AccessCodeSection.tsx +50 -0
- package/src/components/ticketsContainer/PromoCodeSection.tsx +89 -99
- package/src/components/ticketsContainer/ReferralLogic.tsx +31 -33
- package/src/components/ticketsContainer/TicketRow.tsx +89 -83
- package/src/components/ticketsContainer/TicketsSection.tsx +87 -81
- package/src/components/ticketsContainer/index.tsx +506 -409
- package/src/components/ticketsContainer/style.css +181 -181
- package/src/components/ticketsContainer/utils.ts +11 -11
- package/src/components/timerWidget/index.tsx +87 -70
- package/src/components/timerWidget/style.css +34 -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 +15 -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/cookies.ts +42 -0
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +71 -59
- package/src/utils/downloadPDF.tsx +52 -30
- package/src/utils/formikErrorFocus.ts +24 -24
- package/src/utils/getDomain.ts +15 -0
- package/src/utils/getImage.ts +14 -14
- package/src/utils/getQueryVariable.ts +13 -13
- package/src/utils/index.ts +7 -5
- package/src/utils/setConfigs.ts +26 -26
- package/src/utils/showZero.tsx +10 -10
- package/src/validators/index.ts +20 -20
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
.button-container {
|
|
2
|
-
display: flex;
|
|
3
|
-
padding: 20px;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.billing-info-container {
|
|
8
|
-
max-width: 800px;
|
|
9
|
-
margin: 0 auto;
|
|
10
|
-
}
|
|
11
|
-
.billing-info-container .is-half {
|
|
12
|
-
width: 49%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.billing-info-container p {
|
|
16
|
-
color: #000;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.billing-info-container .main-header {
|
|
20
|
-
font-size: 2rem;
|
|
21
|
-
font-weight: 600;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.billing-info-container__twoFields {
|
|
25
|
-
display: flex;
|
|
26
|
-
justify-content: space-between;
|
|
27
|
-
margin-top: 15px;
|
|
28
|
-
}
|
|
29
|
-
.billing-info-container__singleField {
|
|
30
|
-
margin-top: 15px;
|
|
31
|
-
}
|
|
32
|
-
button {
|
|
33
|
-
margin-top: 10px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.account-actions-block {
|
|
37
|
-
margin-top: 10px;
|
|
38
|
-
color: #182026;
|
|
39
|
-
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
|
40
|
-
Ubuntu, Cantarell, Open Sans, Helvetica Neue, Icons16, sans-serif;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.MuiButtonBase-root.MuiButton-root,
|
|
44
|
-
.MuiButtonBase-root.MuiButton-root:hover,
|
|
45
|
-
.login-register-button {
|
|
46
|
-
width: 49%;
|
|
47
|
-
margin-top: 10px;
|
|
48
|
-
min-height: 46px;
|
|
49
|
-
background-color: #212529;
|
|
50
|
-
font-size: 26px;
|
|
51
|
-
border: #f28051;
|
|
52
|
-
border-radius: 5px;
|
|
53
|
-
color: #fff;
|
|
54
|
-
position: relative;
|
|
55
|
-
display: block;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
font-family: Inter-Bold;
|
|
58
|
-
font-weight: 700;
|
|
59
|
-
text-transform: uppercase;
|
|
60
|
-
/* font-size: 1rem; */
|
|
61
|
-
padding: 14px 12px 12px;
|
|
62
|
-
line-height: 1.15;
|
|
63
|
-
text-align: center;
|
|
64
|
-
overflow: hidden;
|
|
65
|
-
text-overflow: ellipsis;
|
|
66
|
-
outline: none;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.logo-image-container {
|
|
70
|
-
width: 49%;
|
|
71
|
-
margin-top: 5px;
|
|
72
|
-
text-align: center;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.logo-image-container img {
|
|
76
|
-
height: 30px;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.login-block {
|
|
80
|
-
display: flex;
|
|
81
|
-
flex-direction: column;
|
|
82
|
-
align-items: center;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.login-register-button:hover {
|
|
86
|
-
background-color: #505050 !important;
|
|
87
|
-
border-color: #505050 !important;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.login-register-block {
|
|
91
|
-
display: flex;
|
|
92
|
-
justify-content: space-between;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@media only screen and (max-width: 820px) {
|
|
96
|
-
.billing-info-container {
|
|
97
|
-
width: 90%;
|
|
98
|
-
}
|
|
99
|
-
.billing-info-container .main-header {
|
|
100
|
-
font-size: 1.5rem;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.email-checking {
|
|
105
|
-
margin-bottom: 15px;
|
|
106
|
-
}
|
|
1
|
+
.button-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
padding: 20px;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.billing-info-container {
|
|
8
|
+
max-width: 800px;
|
|
9
|
+
margin: 0 auto;
|
|
10
|
+
}
|
|
11
|
+
.billing-info-container .is-half {
|
|
12
|
+
width: 49%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.billing-info-container p {
|
|
16
|
+
color: #000;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.billing-info-container .main-header {
|
|
20
|
+
font-size: 2rem;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.billing-info-container__twoFields {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
margin-top: 15px;
|
|
28
|
+
}
|
|
29
|
+
.billing-info-container__singleField {
|
|
30
|
+
margin-top: 15px;
|
|
31
|
+
}
|
|
32
|
+
button {
|
|
33
|
+
margin-top: 10px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.account-actions-block {
|
|
37
|
+
margin-top: 10px;
|
|
38
|
+
color: #182026;
|
|
39
|
+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
|
40
|
+
Ubuntu, Cantarell, Open Sans, Helvetica Neue, Icons16, sans-serif;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.MuiButtonBase-root.MuiButton-root,
|
|
44
|
+
.MuiButtonBase-root.MuiButton-root:hover,
|
|
45
|
+
.login-register-button {
|
|
46
|
+
width: 49%;
|
|
47
|
+
margin-top: 10px;
|
|
48
|
+
min-height: 46px;
|
|
49
|
+
background-color: #212529;
|
|
50
|
+
font-size: 26px;
|
|
51
|
+
border: #f28051;
|
|
52
|
+
border-radius: 5px;
|
|
53
|
+
color: #fff;
|
|
54
|
+
position: relative;
|
|
55
|
+
display: block;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
font-family: Inter-Bold;
|
|
58
|
+
font-weight: 700;
|
|
59
|
+
text-transform: uppercase;
|
|
60
|
+
/* font-size: 1rem; */
|
|
61
|
+
padding: 14px 12px 12px;
|
|
62
|
+
line-height: 1.15;
|
|
63
|
+
text-align: center;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
outline: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.logo-image-container {
|
|
70
|
+
width: 49%;
|
|
71
|
+
margin-top: 5px;
|
|
72
|
+
text-align: center;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.logo-image-container img {
|
|
76
|
+
height: 30px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.login-block {
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
align-items: center;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.login-register-button:hover {
|
|
86
|
+
background-color: #505050 !important;
|
|
87
|
+
border-color: #505050 !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.login-register-block {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@media only screen and (max-width: 820px) {
|
|
96
|
+
.billing-info-container {
|
|
97
|
+
width: 90%;
|
|
98
|
+
}
|
|
99
|
+
.billing-info-container .main-header {
|
|
100
|
+
font-size: 1.5rem;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.email-checking {
|
|
105
|
+
margin-bottom: 15px;
|
|
106
|
+
}
|
|
@@ -1,223 +1,233 @@
|
|
|
1
|
-
import _map from 'lodash/map'
|
|
2
|
-
import _get from 'lodash/get'
|
|
3
|
-
import _forEach from 'lodash/forEach'
|
|
4
|
-
import _flatMapDeep from 'lodash/flatMapDeep'
|
|
5
|
-
import _isArray from 'lodash/isArray'
|
|
6
|
-
|
|
7
|
-
import { CONFIGS } from '../../utils'
|
|
8
|
-
import { IGroupItem } from '../../types'
|
|
9
|
-
import { combineValidators, requiredValidator } from '../../validators'
|
|
10
|
-
import { nanoid } from 'nanoid'
|
|
11
|
-
import { FormikValues } from 'formik'
|
|
12
|
-
|
|
13
|
-
export interface ILoggedInValues {
|
|
14
|
-
emailLogged?: string;
|
|
15
|
-
firstNameLogged?: string;
|
|
16
|
-
lastNameLogged?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface IValues {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const getInitialValues = (
|
|
24
|
-
data: any = [],
|
|
25
|
-
propsInitialValues: IValues = {},
|
|
26
|
-
userValues: any = {}
|
|
27
|
-
): IValues => {
|
|
28
|
-
const results = _flatMapDeep(data, ({ fields }) =>
|
|
29
|
-
_map(fields, ({ groupItems }) => _map(groupItems, ({ name }) => name))
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const initialValues: IValues = {}
|
|
33
|
-
_forEach(results, item => {
|
|
34
|
-
initialValues[item] = propsInitialValues[item] || userValues[item] || ''
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
// set logged in user as first ticket holder
|
|
38
|
-
initialValues['holderFirstName-0'] =
|
|
39
|
-
propsInitialValues.firstName || userValues.firstName || ''
|
|
40
|
-
initialValues['holderLastName-0'] =
|
|
41
|
-
propsInitialValues.lastName || userValues.lastName || ''
|
|
42
|
-
initialValues['holderEmail-0'] =
|
|
43
|
-
propsInitialValues.email || userValues.email || ''
|
|
44
|
-
|
|
45
|
-
return initialValues
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const createRegisterFormData = (
|
|
49
|
-
values: IValues = {},
|
|
50
|
-
checkoutBody: { attributes: { [key: string]: any } }
|
|
51
|
-
): FormData => {
|
|
52
|
-
const bodyFormData = new FormData()
|
|
53
|
-
bodyFormData.append('first_name', values.firstName)
|
|
54
|
-
bodyFormData.append('last_name', values.lastName)
|
|
55
|
-
bodyFormData.append('email', values.email)
|
|
56
|
-
bodyFormData.append('password', values.password)
|
|
57
|
-
bodyFormData.append('password_confirmation', values.confirmPassword)
|
|
58
|
-
bodyFormData.append(
|
|
59
|
-
'client_id',
|
|
60
|
-
CONFIGS.CLIENT_ID || 'e9d8f8922797b4621e562255afe90dbf'
|
|
61
|
-
)
|
|
62
|
-
bodyFormData.append(
|
|
63
|
-
'client_secret',
|
|
64
|
-
CONFIGS.CLIENT_SECRET || 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9'
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
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
|
-
body.attributes.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
return
|
|
222
|
-
}
|
|
223
|
-
|
|
1
|
+
import _map from 'lodash/map'
|
|
2
|
+
import _get from 'lodash/get'
|
|
3
|
+
import _forEach from 'lodash/forEach'
|
|
4
|
+
import _flatMapDeep from 'lodash/flatMapDeep'
|
|
5
|
+
import _isArray from 'lodash/isArray'
|
|
6
|
+
|
|
7
|
+
import { CONFIGS } from '../../utils'
|
|
8
|
+
import { IGroupItem } from '../../types'
|
|
9
|
+
import { combineValidators, requiredValidator } from '../../validators'
|
|
10
|
+
import { nanoid } from 'nanoid'
|
|
11
|
+
import { FormikValues } from 'formik'
|
|
12
|
+
|
|
13
|
+
export interface ILoggedInValues {
|
|
14
|
+
emailLogged?: string;
|
|
15
|
+
firstNameLogged?: string;
|
|
16
|
+
lastNameLogged?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IValues {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const getInitialValues = (
|
|
24
|
+
data: any = [],
|
|
25
|
+
propsInitialValues: IValues = {},
|
|
26
|
+
userValues: any = {}
|
|
27
|
+
): IValues => {
|
|
28
|
+
const results = _flatMapDeep(data, ({ fields }) =>
|
|
29
|
+
_map(fields, ({ groupItems }) => _map(groupItems, ({ name }) => name))
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const initialValues: IValues = {}
|
|
33
|
+
_forEach(results, item => {
|
|
34
|
+
initialValues[item] = propsInitialValues[item] || userValues[item] || ''
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// set logged in user as first ticket holder
|
|
38
|
+
initialValues['holderFirstName-0'] =
|
|
39
|
+
propsInitialValues.firstName || userValues.firstName || ''
|
|
40
|
+
initialValues['holderLastName-0'] =
|
|
41
|
+
propsInitialValues.lastName || userValues.lastName || ''
|
|
42
|
+
initialValues['holderEmail-0'] =
|
|
43
|
+
propsInitialValues.email || userValues.email || ''
|
|
44
|
+
|
|
45
|
+
return initialValues
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const createRegisterFormData = (
|
|
49
|
+
values: IValues = {},
|
|
50
|
+
checkoutBody: { attributes: { [key: string]: any } }
|
|
51
|
+
): FormData => {
|
|
52
|
+
const bodyFormData = new FormData()
|
|
53
|
+
bodyFormData.append('first_name', values.firstName)
|
|
54
|
+
bodyFormData.append('last_name', values.lastName)
|
|
55
|
+
bodyFormData.append('email', values.email)
|
|
56
|
+
bodyFormData.append('password', values.password)
|
|
57
|
+
bodyFormData.append('password_confirmation', values.confirmPassword)
|
|
58
|
+
bodyFormData.append(
|
|
59
|
+
'client_id',
|
|
60
|
+
CONFIGS.CLIENT_ID || 'e9d8f8922797b4621e562255afe90dbf'
|
|
61
|
+
)
|
|
62
|
+
bodyFormData.append(
|
|
63
|
+
'client_secret',
|
|
64
|
+
CONFIGS.CLIENT_SECRET || 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9'
|
|
65
|
+
)
|
|
66
|
+
bodyFormData.append('check_cart_expiration', 'true')
|
|
67
|
+
|
|
68
|
+
_forEach(checkoutBody.attributes, (item: any, key: string) => {
|
|
69
|
+
bodyFormData.append(key, item)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
return bodyFormData
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ICheckoutBody {
|
|
76
|
+
attributes: {
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface IUserData {
|
|
82
|
+
id: string;
|
|
83
|
+
firstName: string;
|
|
84
|
+
lastName: string;
|
|
85
|
+
email: string;
|
|
86
|
+
city?: string;
|
|
87
|
+
country?: string;
|
|
88
|
+
countryId?: string;
|
|
89
|
+
phone?: string;
|
|
90
|
+
streetAddress?: string;
|
|
91
|
+
state?: string;
|
|
92
|
+
zip?: string;
|
|
93
|
+
zipCode?: string;
|
|
94
|
+
stateId?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface IticketHolder {
|
|
98
|
+
first_name?: string;
|
|
99
|
+
last_name?: string;
|
|
100
|
+
phone?: string;
|
|
101
|
+
email?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const setLoggedUserData = (data: IUserData) => ({
|
|
105
|
+
id: data.id,
|
|
106
|
+
first_name: data.firstName,
|
|
107
|
+
last_name: data.lastName,
|
|
108
|
+
email: data.email,
|
|
109
|
+
confirmEmail: data.email,
|
|
110
|
+
city: data?.city || '',
|
|
111
|
+
country: data?.countryId || data?.country || '',
|
|
112
|
+
phone: data?.phone || '',
|
|
113
|
+
street_address: data?.streetAddress || '',
|
|
114
|
+
state: data?.stateId || '',
|
|
115
|
+
zip: data?.zip || data?.zipCode || '',
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
export const createCheckoutDataBody = (
|
|
119
|
+
ticketsQuantity: number,
|
|
120
|
+
values: IValues = {},
|
|
121
|
+
logedInValues: ILoggedInValues = {},
|
|
122
|
+
includeDob: boolean = false
|
|
123
|
+
): ICheckoutBody => {
|
|
124
|
+
const {
|
|
125
|
+
firstName,
|
|
126
|
+
lastName,
|
|
127
|
+
holderAge,
|
|
128
|
+
confirmEmail,
|
|
129
|
+
confirmPassword,
|
|
130
|
+
...restValues
|
|
131
|
+
} = values
|
|
132
|
+
|
|
133
|
+
const holders = []
|
|
134
|
+
let ticket_holders: IticketHolder[] = []
|
|
135
|
+
|
|
136
|
+
for (let i = 0; i <= ticketsQuantity; i++) {
|
|
137
|
+
const individualHolder = Object.fromEntries(
|
|
138
|
+
Object.entries(values).filter(([key, _val]) => key.includes(String(i)))
|
|
139
|
+
)
|
|
140
|
+
holders.push(individualHolder)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const filteredHolders = holders.filter(
|
|
144
|
+
holder => Object.entries(holder).length > 0
|
|
145
|
+
)
|
|
146
|
+
ticket_holders = filteredHolders.map((item, index) => ({
|
|
147
|
+
first_name: !index ? item[`holderFirstName-${index}`] || logedInValues.firstNameLogged || '' : item[`holderFirstName-${index}`] || '',
|
|
148
|
+
last_name: !index ? item[`holderLastName-${index}`] || logedInValues.lastNameLogged || '' : item[`holderLastName-${index}`] || '',
|
|
149
|
+
phone: item[`holderPhone-${index}`] || '',
|
|
150
|
+
email: !index ? item[`holderEmail-${index}`] || logedInValues.emailLogged || '' : item[`holderEmail-${index}`] || '',
|
|
151
|
+
}))
|
|
152
|
+
|
|
153
|
+
const filteredRestValue: { [key: string]: any } = {}
|
|
154
|
+
_forEach(restValues, (value, key) => {
|
|
155
|
+
if (!key.includes('holder')) {
|
|
156
|
+
filteredRestValue[key] = value
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const body: ICheckoutBody = {
|
|
161
|
+
attributes: {
|
|
162
|
+
...filteredRestValue,
|
|
163
|
+
email: restValues.email || logedInValues.emailLogged,
|
|
164
|
+
confirm_email: restValues.email || logedInValues.emailLogged,
|
|
165
|
+
first_name: firstName || logedInValues.firstNameLogged,
|
|
166
|
+
last_name: lastName || logedInValues.lastNameLogged,
|
|
167
|
+
ticket_holders,
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (includeDob) {
|
|
172
|
+
const holderAgeDate = new Date(holderAge)
|
|
173
|
+
body.attributes.dob_day = holderAgeDate.getDate()
|
|
174
|
+
body.attributes.dob_month = holderAgeDate.getMonth() + 1
|
|
175
|
+
body.attributes.dob_year = holderAgeDate.getFullYear()
|
|
176
|
+
}
|
|
177
|
+
return body
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const getValidateFunctions = (
|
|
181
|
+
element: IGroupItem,
|
|
182
|
+
states: Array<{ [key: string]: any }>,
|
|
183
|
+
values: FormikValues
|
|
184
|
+
) => {
|
|
185
|
+
const validationFunctions: any[] = []
|
|
186
|
+
|
|
187
|
+
if (element.required) {
|
|
188
|
+
if (
|
|
189
|
+
element.name !== 'state' ||
|
|
190
|
+
(element.name === 'state' && states.length)
|
|
191
|
+
) {
|
|
192
|
+
validationFunctions.push(requiredValidator)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (element.onValidate) {
|
|
197
|
+
validationFunctions.push(element.onValidate)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (element.name === 'confirmEmail') {
|
|
201
|
+
const isSameEmail = (confirmEmail?: string) =>
|
|
202
|
+
values.email !== confirmEmail
|
|
203
|
+
? 'Please confirm your email address correctly'
|
|
204
|
+
: null
|
|
205
|
+
validationFunctions.push(isSameEmail)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (element.name === 'confirmPassword') {
|
|
209
|
+
const isSame = (confirmPassword?: string) =>
|
|
210
|
+
values.password !== confirmPassword
|
|
211
|
+
? 'Password confirmation does not match'
|
|
212
|
+
: null
|
|
213
|
+
validationFunctions.push(isSame)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return combineValidators(...validationFunctions)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export const assingUniqueIds = (data: any): any => {
|
|
220
|
+
if (_get(data[0], 'uniqueId')) {
|
|
221
|
+
return data
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return _map(data, (item: any) => {
|
|
225
|
+
_forEach(item, (itemValue: string, key) => {
|
|
226
|
+
if (_isArray(itemValue)) {
|
|
227
|
+
item[key] = assingUniqueIds(itemValue)
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
return { ...item, uniqueId: nanoid() }
|
|
232
|
+
})
|
|
233
|
+
}
|