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.
Files changed (117) hide show
  1. package/README.md +278 -1
  2. package/dist/api/index.d.ts +31 -26
  3. package/dist/components/account-settings/index.d.ts +3 -0
  4. package/dist/components/billing-info-container/index.d.ts +5 -5
  5. package/dist/components/billing-info-container/utils.d.ts +1 -0
  6. package/dist/components/common/CustomField.d.ts +1 -1
  7. package/dist/components/common/DatePickerField.d.ts +14 -0
  8. package/dist/components/common/RedirectModal.d.ts +7 -0
  9. package/dist/components/common/SnackbarAlert.d.ts +13 -0
  10. package/dist/components/confirmationContainer/index.d.ts +2 -1
  11. package/dist/components/countdown/index.d.ts +4 -1
  12. package/dist/components/myTicketsContainer/tableConfig.d.ts +0 -1
  13. package/dist/components/orderDetailsContainer/index.d.ts +5 -1
  14. package/dist/components/orderDetailsContainer/ticketsTable.d.ts +4 -1
  15. package/dist/components/paymentContainer/index.d.ts +3 -1
  16. package/dist/components/rsvpContainer/index.d.ts +7 -0
  17. package/dist/components/stripePayment/index.d.ts +2 -1
  18. package/dist/components/ticketResale/index.d.ts +5 -3
  19. package/dist/components/ticketsContainer/AccessCodeSection.d.ts +7 -0
  20. package/dist/components/ticketsContainer/PromoCodeSection.d.ts +6 -9
  21. package/dist/components/ticketsContainer/TicketsSection.d.ts +5 -3
  22. package/dist/components/ticketsContainer/index.d.ts +13 -2
  23. package/dist/components/timerWidget/index.d.ts +3 -3
  24. package/dist/env.d.ts +1 -0
  25. package/dist/images/cross.svg +44 -0
  26. package/dist/images/done.svg +3 -3
  27. package/dist/index.d.ts +2 -0
  28. package/dist/tf-checkout-react.cjs.development.js +1400 -575
  29. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  30. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  31. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  32. package/dist/tf-checkout-react.esm.js +1409 -586
  33. package/dist/tf-checkout-react.esm.js.map +1 -1
  34. package/dist/tf-checkout-styles.css +1 -1
  35. package/dist/utils/cookies.d.ts +3 -0
  36. package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +6 -1
  37. package/dist/utils/downloadPDF.d.ts +1 -1
  38. package/dist/utils/getDomain.d.ts +1 -0
  39. package/dist/utils/index.d.ts +2 -0
  40. package/package.json +89 -89
  41. package/src/.DS_Store +0 -0
  42. package/src/.d.ts +2 -2
  43. package/src/api/index.ts +313 -278
  44. package/src/assets/images/cross.svg +44 -0
  45. package/src/assets/images/done.svg +3 -3
  46. package/src/components/.DS_Store +0 -0
  47. package/src/components/account-settings/index.tsx +161 -0
  48. package/src/components/account-settings/style.css +200 -0
  49. package/src/components/billing-info-container/index.tsx +821 -777
  50. package/src/components/billing-info-container/style.css +106 -106
  51. package/src/components/billing-info-container/utils.ts +233 -223
  52. package/src/components/common/CheckboxField.tsx +41 -41
  53. package/src/components/common/CustomField.tsx +87 -84
  54. package/src/components/common/DatePickerField.tsx +98 -0
  55. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  56. package/src/components/common/Loader.tsx +9 -9
  57. package/src/components/common/RadioField.tsx +35 -35
  58. package/src/components/common/RedirectModal.tsx +43 -0
  59. package/src/components/common/SelectField.tsx +80 -80
  60. package/src/components/common/SnackbarAlert.tsx +54 -0
  61. package/src/components/common/dist/PhoneNumberField.js +96 -0
  62. package/src/components/common/index.tsx +4 -4
  63. package/src/components/confirmModal/index.tsx +51 -51
  64. package/src/components/confirmModal/style.css +21 -21
  65. package/src/components/confirmationContainer/config.ts +72 -72
  66. package/src/components/confirmationContainer/index.tsx +197 -194
  67. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  68. package/src/components/confirmationContainer/style.css +202 -202
  69. package/src/components/countdown/index.tsx +100 -89
  70. package/src/components/countdown/style.css +9 -9
  71. package/src/components/index.ts +7 -7
  72. package/src/components/loginModal/index.tsx +171 -209
  73. package/src/components/loginModal/style.css +71 -71
  74. package/src/components/myTicketsContainer/index.tsx +201 -137
  75. package/src/components/myTicketsContainer/row.tsx +41 -41
  76. package/src/components/myTicketsContainer/style.css +40 -40
  77. package/src/components/myTicketsContainer/tableConfig.tsx +32 -34
  78. package/src/components/orderDetailsContainer/index.tsx +289 -249
  79. package/src/components/orderDetailsContainer/style.css +73 -73
  80. package/src/components/orderDetailsContainer/ticketsTable.tsx +177 -124
  81. package/src/components/paymentContainer/index.tsx +352 -284
  82. package/src/components/registerModal/index.tsx +183 -190
  83. package/src/components/rsvpContainer/index.tsx +126 -0
  84. package/src/components/stripePayment/index.tsx +258 -253
  85. package/src/components/stripePayment/style.css +60 -60
  86. package/src/components/ticketResale/index.tsx +74 -56
  87. package/src/components/ticketResaleModal/index.tsx +213 -210
  88. package/src/components/ticketResaleModal/style.css +28 -28
  89. package/src/components/ticketsContainer/AccessCodeSection.tsx +50 -0
  90. package/src/components/ticketsContainer/PromoCodeSection.tsx +89 -99
  91. package/src/components/ticketsContainer/ReferralLogic.tsx +31 -33
  92. package/src/components/ticketsContainer/TicketRow.tsx +89 -83
  93. package/src/components/ticketsContainer/TicketsSection.tsx +87 -81
  94. package/src/components/ticketsContainer/index.tsx +506 -409
  95. package/src/components/ticketsContainer/style.css +181 -181
  96. package/src/components/ticketsContainer/utils.ts +11 -11
  97. package/src/components/timerWidget/index.tsx +87 -70
  98. package/src/components/timerWidget/style.css +34 -26
  99. package/src/components/waitingList/index.tsx +178 -178
  100. package/src/components/waitingList/style.css +26 -26
  101. package/src/env.ts +20 -19
  102. package/src/index.ts +15 -13
  103. package/src/normalizers/index.ts +45 -45
  104. package/src/types/billing-info-data.ts +37 -37
  105. package/src/types/payment-field.ts +7 -7
  106. package/src/types/referral-promotion.ts +7 -7
  107. package/src/utils/cookies.ts +42 -0
  108. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +71 -59
  109. package/src/utils/downloadPDF.tsx +52 -30
  110. package/src/utils/formikErrorFocus.ts +24 -24
  111. package/src/utils/getDomain.ts +15 -0
  112. package/src/utils/getImage.ts +14 -14
  113. package/src/utils/getQueryVariable.ts +13 -13
  114. package/src/utils/index.ts +7 -5
  115. package/src/utils/setConfigs.ts +26 -26
  116. package/src/utils/showZero.tsx +10 -10
  117. 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
- _forEach(checkoutBody.attributes, (item: any, key: string) => {
68
- bodyFormData.append(key, item)
69
- })
70
-
71
- return bodyFormData
72
- }
73
-
74
- interface ICheckoutBody {
75
- attributes: {
76
- [key: string]: any;
77
- };
78
- }
79
-
80
- interface IUserData {
81
- id: string;
82
- firstName: string;
83
- lastName: string;
84
- email: string;
85
- city?: string;
86
- country?: string;
87
- phone?: string;
88
- streetAddress?: string;
89
- state?: string;
90
- zip?: string;
91
- zipCode?: string;
92
- stateId?: string;
93
- }
94
-
95
- interface IticketHolder {
96
- first_name?: string;
97
- last_name?: string;
98
- phone?: string;
99
- email?: string;
100
- }
101
-
102
- export const setLoggedUserData = (data: IUserData) => ({
103
- id: data.id,
104
- first_name: data.firstName,
105
- last_name: data.lastName,
106
- email: data.email,
107
- confirmEmail: data.email,
108
- city: data?.city || '',
109
- country: data?.country || '',
110
- phone: data?.phone || '',
111
- street_address: data?.streetAddress || '',
112
- state: data?.stateId || '',
113
- zip: data?.zip || data?.zipCode || '',
114
- })
115
-
116
- export const createCheckoutDataBody = (
117
- ticketsQuantity: number,
118
- values: IValues = {},
119
- logedInValues: ILoggedInValues = {},
120
- includeDob: boolean = false
121
- ): ICheckoutBody => {
122
- const {
123
- firstName,
124
- lastName,
125
- holderAge,
126
- confirmEmail,
127
- confirmPassword,
128
- ...restValues
129
- } = values
130
-
131
- const holders = []
132
- let ticket_holders: IticketHolder[] = []
133
-
134
- for (let i = 0; i <= ticketsQuantity; i++) {
135
- const individualHolder = Object.fromEntries(
136
- Object.entries(values).filter(([key, _val]) => key.includes(String(i)))
137
- )
138
- holders.push(individualHolder)
139
- }
140
-
141
- const filteredHolders = holders.filter(
142
- holder => Object.entries(holder).length > 0
143
- )
144
- ticket_holders = filteredHolders.map((item, index) => ({
145
- first_name: item[`holderFirstName-${index}`] || '',
146
- last_name: item[`holderLastName-${index}`] || '',
147
- phone: item[`holderPhone-${index}`] || '',
148
- email: item[`holderEmail-${index}`] || '',
149
- }))
150
-
151
- const filteredRestValue: { [key: string]: any } = {}
152
- _forEach(restValues, (value, key) => {
153
- if (!key.includes('holder')) {
154
- filteredRestValue[key] = value
155
- }
156
- })
157
-
158
- const body: ICheckoutBody = {
159
- attributes: {
160
- ...filteredRestValue,
161
- email: restValues.email || logedInValues.emailLogged,
162
- confirm_email: restValues.email || logedInValues.emailLogged,
163
- first_name: firstName || logedInValues.firstNameLogged,
164
- last_name: lastName || logedInValues.lastNameLogged,
165
- ticket_holders,
166
- },
167
- }
168
-
169
- if (includeDob) {
170
- const holderAgeDate = new Date(holderAge)
171
- body.attributes.dob_day = holderAgeDate.getDate()
172
- body.attributes.dob_month = holderAgeDate.getMonth() + 1
173
- body.attributes.dob_year = holderAgeDate.getFullYear()
174
- }
175
- return body
176
- }
177
-
178
- export const getValidateFunctions = (
179
- element: IGroupItem,
180
- states: Array<{ [key: string]: any }>,
181
- values: FormikValues
182
- ) => {
183
- const validationFunctions: any[] = []
184
-
185
- if (element.required) {
186
- if (
187
- element.name !== 'state' ||
188
- (element.name === 'state' && states.length)
189
- ) {
190
- validationFunctions.push(requiredValidator)
191
- }
192
- }
193
-
194
- if (element.onValidate) {
195
- validationFunctions.push(element.onValidate)
196
- }
197
-
198
- if (element.name === 'confirmEmail') {
199
- const isSameEmail = (confirmEmail?: string) =>
200
- values.email !== confirmEmail
201
- ? 'Please confirm your email address correctly'
202
- : null
203
- validationFunctions.push(isSameEmail)
204
- }
205
-
206
- return combineValidators(...validationFunctions)
207
- }
208
-
209
- export const assingUniqueIds = (data: any): any => {
210
- if (_get(data[0], 'uniqueId')) {
211
- return data
212
- }
213
-
214
- return _map(data, (item: any) => {
215
- _forEach(item, (itemValue: string, key) => {
216
- if (_isArray(itemValue)) {
217
- item[key] = assingUniqueIds(itemValue)
218
- }
219
- })
220
-
221
- return { ...item, uniqueId: nanoid() }
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
+ }