tf-checkout-react 1.0.103 → 1.0.106

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