tf-checkout-react 1.0.102 → 1.0.105

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 (80) hide show
  1. package/dist/components/common/RedirectModal.d.ts +7 -0
  2. package/dist/components/ticketsContainer/TicketsSection.d.ts +2 -1
  3. package/dist/components/ticketsContainer/index.d.ts +2 -1
  4. package/dist/images/done.svg +3 -3
  5. package/dist/index.d.ts +1 -0
  6. package/dist/tf-checkout-react.cjs.development.js +71 -25
  7. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  8. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  9. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  10. package/dist/tf-checkout-react.esm.js +71 -26
  11. package/dist/tf-checkout-react.esm.js.map +1 -1
  12. package/package.json +89 -89
  13. package/src/.d.ts +2 -2
  14. package/src/api/index.ts +293 -278
  15. package/src/assets/images/done.svg +3 -3
  16. package/src/components/billing-info-container/index.tsx +796 -796
  17. package/src/components/billing-info-container/style.css +105 -105
  18. package/src/components/billing-info-container/utils.ts +224 -224
  19. package/src/components/common/CheckboxField.tsx +41 -41
  20. package/src/components/common/CustomField.tsx +84 -84
  21. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  22. package/src/components/common/Loader.tsx +9 -9
  23. package/src/components/common/RadioField.tsx +35 -35
  24. package/src/components/common/RedirectModal.tsx +43 -0
  25. package/src/components/common/SelectField.tsx +80 -80
  26. package/src/components/common/SnackbarAlert.tsx +53 -53
  27. package/src/components/common/index.tsx +4 -4
  28. package/src/components/confirmModal/index.tsx +51 -51
  29. package/src/components/confirmModal/style.css +21 -21
  30. package/src/components/confirmationContainer/config.ts +72 -72
  31. package/src/components/confirmationContainer/index.tsx +197 -197
  32. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  33. package/src/components/confirmationContainer/style.css +202 -202
  34. package/src/components/countdown/index.tsx +89 -89
  35. package/src/components/countdown/style.css +9 -9
  36. package/src/components/index.ts +7 -7
  37. package/src/components/loginModal/index.tsx +209 -209
  38. package/src/components/loginModal/style.css +71 -71
  39. package/src/components/myTicketsContainer/index.tsx +196 -196
  40. package/src/components/myTicketsContainer/row.tsx +41 -41
  41. package/src/components/myTicketsContainer/style.css +39 -39
  42. package/src/components/myTicketsContainer/tableConfig.tsx +34 -34
  43. package/src/components/orderDetailsContainer/index.tsx +249 -249
  44. package/src/components/orderDetailsContainer/style.css +72 -72
  45. package/src/components/orderDetailsContainer/ticketsTable.tsx +124 -124
  46. package/src/components/paymentContainer/index.tsx +284 -284
  47. package/src/components/registerModal/index.tsx +190 -190
  48. package/src/components/stripePayment/index.tsx +253 -253
  49. package/src/components/stripePayment/style.css +59 -59
  50. package/src/components/ticketResale/index.tsx +56 -56
  51. package/src/components/ticketResaleModal/index.tsx +210 -210
  52. package/src/components/ticketResaleModal/style.css +28 -28
  53. package/src/components/ticketsContainer/PromoCodeSection.tsx +99 -99
  54. package/src/components/ticketsContainer/ReferralLogic.tsx +33 -33
  55. package/src/components/ticketsContainer/TicketRow.tsx +83 -83
  56. package/src/components/ticketsContainer/TicketsSection.tsx +85 -81
  57. package/src/components/ticketsContainer/index.tsx +430 -430
  58. package/src/components/ticketsContainer/style.css +181 -181
  59. package/src/components/ticketsContainer/utils.ts +11 -11
  60. package/src/components/timerWidget/index.tsx +70 -70
  61. package/src/components/timerWidget/style.css +26 -26
  62. package/src/components/waitingList/index.tsx +178 -178
  63. package/src/components/waitingList/style.css +26 -26
  64. package/src/env.ts +20 -20
  65. package/src/index.ts +14 -13
  66. package/src/normalizers/index.ts +45 -45
  67. package/src/types/billing-info-data.ts +37 -37
  68. package/src/types/payment-field.ts +7 -7
  69. package/src/types/referral-promotion.ts +7 -7
  70. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +59 -59
  71. package/src/utils/downloadPDF.tsx +30 -30
  72. package/src/utils/formikErrorFocus.ts +24 -24
  73. package/src/utils/getImage.ts +14 -14
  74. package/src/utils/getQueryVariable.ts +13 -13
  75. package/src/utils/index.ts +5 -5
  76. package/src/utils/setConfigs.ts +26 -26
  77. package/src/utils/showZero.tsx +10 -10
  78. package/src/validators/index.ts +20 -20
  79. package/src/.DS_Store +0 -0
  80. package/src/components/.DS_Store +0 -0
@@ -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,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
-
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
+
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
+ }