tf-checkout-react 1.6.6 → 1.7.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 (137) hide show
  1. package/README.md +401 -59
  2. package/dist/adapters/customFields.d.ts +1 -0
  3. package/dist/api/checkout.d.ts +2 -0
  4. package/dist/api/common.d.ts +1 -0
  5. package/dist/api/index.d.ts +2 -0
  6. package/dist/api/preRegistrationComplete.d.ts +1 -1
  7. package/dist/components/addonsContainer/AddonComponent.d.ts +6 -1
  8. package/dist/components/addonsContainer/SimpleAddonsContainer.d.ts +17 -0
  9. package/dist/components/addonsContainer/index.d.ts +6 -1
  10. package/dist/components/billing-info-container/hooks/index.d.ts +3 -0
  11. package/dist/components/billing-info-container/hooks/usePaymentContext.d.ts +5 -0
  12. package/dist/components/billing-info-container/hooks/usePaymentRedirect.d.ts +14 -0
  13. package/dist/components/billing-info-container/hooks/useStripePayment.d.ts +18 -0
  14. package/dist/components/billing-info-container/index.d.ts +13 -2
  15. package/dist/components/billing-info-container/utils.d.ts +26 -1
  16. package/dist/components/common/DatePickerField.d.ts +7 -1
  17. package/dist/components/common/PhoneNumberField.d.ts +1 -1
  18. package/dist/components/confirmationContainer/index.d.ts +4 -1
  19. package/dist/components/countdown/index.d.ts +1 -1
  20. package/dist/components/forgotPasswordModal/index.d.ts +2 -1
  21. package/dist/components/myTicketsContainer/index.d.ts +3 -2
  22. package/dist/components/orderDetailsContainer/index.d.ts +8 -1
  23. package/dist/components/paymentContainer/OrderDetails.d.ts +9 -0
  24. package/dist/components/paymentContainer/handlePayment.d.ts +15 -0
  25. package/dist/components/paymentContainer/index.d.ts +12 -6
  26. package/dist/components/preRegistration/FieldsSection.d.ts +7 -1
  27. package/dist/components/preRegistration/PreRegistrationComplete.d.ts +8 -0
  28. package/dist/components/preRegistration/constants.d.ts +2 -2
  29. package/dist/components/preRegistration/index.d.ts +6 -0
  30. package/dist/components/resetPasswordContainer/index.d.ts +2 -2
  31. package/dist/components/ticketsContainer/InfoIcon.d.ts +5 -0
  32. package/dist/components/ticketsContainer/TicketsSection.d.ts +3 -2
  33. package/dist/components/ticketsContainer/TimeSlotsSection.d.ts +25 -0
  34. package/dist/components/ticketsContainer/index.d.ts +29 -5
  35. package/dist/components/timerWidget/index.d.ts +2 -1
  36. package/dist/constants/index.d.ts +5 -0
  37. package/dist/index.d.ts +4 -1
  38. package/dist/tf-checkout-react.cjs.development.js +11284 -9565
  39. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  40. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  41. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  42. package/dist/tf-checkout-react.esm.js +11293 -9577
  43. package/dist/tf-checkout-react.esm.js.map +1 -1
  44. package/dist/tf-checkout-styles.css +1 -1
  45. package/dist/types/add_on.d.ts +1 -0
  46. package/dist/types/checkoutPageConfigs.d.ts +1 -1
  47. package/dist/types/order-data.d.ts +3 -1
  48. package/dist/utils/auth.d.ts +8 -0
  49. package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +1 -0
  50. package/dist/utils/customFields.d.ts +11 -0
  51. package/dist/utils/getDomain.d.ts +1 -1
  52. package/dist/utils/index.d.ts +1 -1
  53. package/dist/utils/setConfigs.d.ts +1 -0
  54. package/package.json +14 -8
  55. package/src/adapters/customFields.ts +7 -1
  56. package/src/api/auth.ts +2 -1
  57. package/src/api/checkout.ts +9 -4
  58. package/src/api/common.ts +49 -2
  59. package/src/api/index.ts +1 -0
  60. package/src/api/interceptors.ts +7 -23
  61. package/src/api/preRegistrationComplete.ts +1 -1
  62. package/src/api/publicRequest.ts +10 -0
  63. package/src/components/addonsContainer/AddonComponent.tsx +96 -11
  64. package/src/components/addonsContainer/SimpleAddonsContainer.tsx +420 -0
  65. package/src/components/addonsContainer/index.tsx +198 -47
  66. package/src/components/billing-info-container/hooks/index.ts +3 -0
  67. package/src/components/billing-info-container/hooks/usePaymentContext.ts +22 -0
  68. package/src/components/billing-info-container/hooks/usePaymentRedirect.ts +147 -0
  69. package/src/components/billing-info-container/hooks/useStripePayment.ts +121 -0
  70. package/src/components/billing-info-container/index.tsx +859 -418
  71. package/src/components/billing-info-container/{utils.ts → utils.tsx} +124 -1
  72. package/src/components/common/CheckboxField/index.tsx +1 -1
  73. package/src/components/common/CustomField.tsx +39 -3
  74. package/src/components/common/DatePickerField.tsx +25 -10
  75. package/src/components/common/PhoneNumberField.tsx +4 -2
  76. package/src/components/common/SnackbarAlert.tsx +32 -34
  77. package/src/components/confirmationContainer/config.ts +3 -3
  78. package/src/components/confirmationContainer/index.tsx +20 -1
  79. package/src/components/confirmationContainer/social-buttons.tsx +5 -3
  80. package/src/components/confirmationContainer/style.css +9 -5
  81. package/src/components/countdown/index.tsx +22 -22
  82. package/src/components/delegationsContainer/IssueComponent.tsx +2 -1
  83. package/src/components/forgotPasswordModal/index.tsx +44 -13
  84. package/src/components/loginForm/index.tsx +1 -1
  85. package/src/components/loginModal/index.tsx +19 -27
  86. package/src/components/loginModal/style.css +3 -1
  87. package/src/components/myTicketsContainer/index.tsx +13 -9
  88. package/src/components/orderDetailsContainer/index.tsx +206 -174
  89. package/src/components/paymentContainer/OrderDetails.tsx +257 -0
  90. package/src/components/paymentContainer/handlePayment.ts +86 -0
  91. package/src/components/paymentContainer/index.tsx +299 -259
  92. package/src/components/paymentContainer/style.css +141 -0
  93. package/src/components/preRegistration/FieldsSection.tsx +8 -0
  94. package/src/components/preRegistration/PreRegistrationComplete.tsx +138 -118
  95. package/src/components/preRegistration/PreRegistrationInformations.tsx +21 -15
  96. package/src/components/preRegistration/constants.tsx +10 -4
  97. package/src/components/preRegistration/index.tsx +233 -179
  98. package/src/components/preRegistration/style.css +3 -0
  99. package/src/components/registerForm/constants.tsx +3 -1
  100. package/src/components/registerForm/index.tsx +3 -3
  101. package/src/components/registerModal/index.tsx +47 -72
  102. package/src/components/resetPasswordContainer/index.tsx +20 -14
  103. package/src/components/seatMapContainer/TicketsSection.tsx +2 -2
  104. package/src/components/signupModal/index.tsx +13 -6
  105. package/src/components/ticketResale/index.tsx +7 -0
  106. package/src/components/ticketsContainer/InfoIcon.tsx +35 -0
  107. package/src/components/ticketsContainer/PromoCodeSection.tsx +34 -28
  108. package/src/components/ticketsContainer/TicketRow.tsx +1 -1
  109. package/src/components/ticketsContainer/TicketsSection.tsx +189 -57
  110. package/src/components/ticketsContainer/TimeSlotsSection.tsx +120 -0
  111. package/src/components/ticketsContainer/index.tsx +268 -106
  112. package/src/components/timerWidget/index.tsx +15 -3
  113. package/src/components/timerWidget/style.css +2 -1
  114. package/src/constants/index.ts +2 -0
  115. package/src/env.ts +14 -6
  116. package/src/hoc/CustomFields/index.tsx +9 -1
  117. package/src/index.ts +7 -2
  118. package/src/types/add_on.ts +1 -0
  119. package/src/types/api/cart.d.ts +8 -0
  120. package/src/types/api/checkout.d.ts +58 -7
  121. package/src/types/api/common.d.ts +30 -0
  122. package/src/types/api/orders.d.ts +19 -3
  123. package/src/types/api/payment.d.ts +6 -2
  124. package/src/types/api/preRegistrationComplete.d.ts +2 -2
  125. package/src/types/checkoutPageConfigs.ts +1 -1
  126. package/src/types/order-data.ts +3 -1
  127. package/src/types/pre-registration-complete.d.ts +6 -1
  128. package/src/utils/auth.ts +32 -0
  129. package/src/utils/cookies.ts +42 -11
  130. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +3 -1
  131. package/src/utils/customFields.ts +22 -0
  132. package/src/utils/getDomain.ts +10 -4
  133. package/src/utils/index.ts +1 -1
  134. package/src/utils/setConfigs.ts +3 -1
  135. package/dist/components/stripePayment/index.d.ts +0 -24
  136. package/src/components/stripePayment/index.tsx +0 -281
  137. package/src/components/stripePayment/style.css +0 -60
@@ -1,4 +1,7 @@
1
- import { Button, CircularProgress } from '@mui/material'
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Button, CircularProgress, ThemeOptions } from '@mui/material'
3
+ import { createTheme, ThemeProvider } from '@mui/material/styles'
4
+ import { CSSProperties } from '@mui/styles'
2
5
  import axios, { AxiosError } from 'axios'
3
6
  import { Form, Formik, FormikValues } from 'formik'
4
7
  import _get from 'lodash/get'
@@ -13,8 +16,9 @@ import SnackbarAlert from '../common/SnackbarAlert'
13
16
  import ConfirmModal from '../confirmModal'
14
17
  import { ForgotPasswordModal, IForgotPasswordProps } from '../forgotPasswordModal'
15
18
  import { LoginModal, Props } from '../loginModal'
16
- import { formFieldsLoggedIn, formFieldsNotLoggedIn } from './constants'
19
+ import { getFormFieldsLoggedIn, getFormFieldsNotLoggedIn } from './constants'
17
20
  import { FieldsSection } from './FieldsSection'
21
+ import { PreRegistrationComplete } from './PreRegistrationComplete'
18
22
  import { getFormInitialValues, updateFormFieldsAttributes } from './utils'
19
23
 
20
24
  const X_TF_ECOMMERCE = 'X-TF-ECOMMERCE'
@@ -30,6 +34,11 @@ interface IPreRegistrationProps extends Props, IForgotPasswordProps {
30
34
  onConfirmationSuccess?: (res: any) => void;
31
35
  onConfirmationError?: (e: AxiosError) => void;
32
36
  onLoginSuccess?: (res: any) => void;
37
+
38
+ themeOptions?: ThemeOptions & {
39
+ input?: CSSProperties;
40
+ checkbox?: CSSProperties;
41
+ };
33
42
  }
34
43
 
35
44
  export const PreRegistration: FC<IPreRegistrationProps> = ({
@@ -46,6 +55,7 @@ export const PreRegistration: FC<IPreRegistrationProps> = ({
46
55
  onGetCountriesError = _identity,
47
56
  onConfirmationSuccess = _identity,
48
57
  onConfirmationError = _identity,
58
+ themeOptions,
49
59
  }) => {
50
60
  const [error, setError] = useState('')
51
61
  const [showModalLogin, setShowModalLogin] = useState(false)
@@ -55,8 +65,24 @@ export const PreRegistration: FC<IPreRegistrationProps> = ({
55
65
  const [isLoggedIn, setIsLoggedIn] = useState(Boolean(getCookieByName(X_TF_ECOMMERCE)))
56
66
  const [confirmModalState, setConfirmModalState] = useState({ show: false, message: '' })
57
67
  const [, setUserData] = useState({} as IProfileData)
68
+ const [isPreRegistrationComplete, setIsPreRegistrationComplete] = useState(false)
58
69
  useCookieListener(X_TF_ECOMMERCE, value => setIsLoggedIn(Boolean(value)))
59
70
 
71
+ // Check if user already has a pre-registration when logged in
72
+ useEffect(() => {
73
+ if (!isLoggedIn || !isWindowDefined) return
74
+
75
+ const savedHash = window.localStorage.getItem('pre-registration-hash')
76
+ if (savedHash) {
77
+ setIsPreRegistrationComplete(true)
78
+ }
79
+ }, [isLoggedIn])
80
+
81
+ const themeMui = createTheme(themeOptions)
82
+
83
+ const formFieldsLoggedIn = getFormFieldsLoggedIn(CONFIGS.CLIENT_NAME)
84
+ const formFieldsNotLoggedIn = getFormFieldsNotLoggedIn(CONFIGS.CLIENT_NAME)
85
+
60
86
  const formFields = updateFormFieldsAttributes(
61
87
  pFormFields || isLoggedIn ? formFieldsLoggedIn : formFieldsNotLoggedIn,
62
88
  additionalFieldAttribute
@@ -76,7 +102,7 @@ export const PreRegistration: FC<IPreRegistrationProps> = ({
76
102
  onGetCountriesSuccess(res.data)
77
103
  } catch (e) {
78
104
  if (axios.isAxiosError(e)) {
79
- const error = e?.response?.data?.message || 'Error'
105
+ const error = 'Error'
80
106
  setError(error)
81
107
  onGetCountriesError(e)
82
108
  }
@@ -85,192 +111,220 @@ export const PreRegistration: FC<IPreRegistrationProps> = ({
85
111
  fetchCountries()
86
112
  }, [])
87
113
 
88
- const hash = getQueryVariable('hash') || ''
114
+ const localStorageHash = isWindowDefined
115
+ ? window.localStorage.getItem('pre-registration-hash') || ''
116
+ : ''
117
+ const hash = getQueryVariable('hash') || localStorageHash
89
118
  const referrerId = getQueryVariable('referrer_id') || ''
90
119
  return (
91
- <div className="pre-registration-container">
92
- <SnackbarAlert
93
- type="error"
94
- isOpen={!!error}
95
- message={error || ''}
96
- onClose={() => {
97
- setError('')
98
- }}
99
- />
100
- {confirmModalState.show && (
101
- <ConfirmModal
102
- hideCancelBtn
103
- onConfirm={() => setConfirmModalState({ show: false, message: '' })}
104
- message={confirmModalState.message}
105
- />
106
- )}
107
- {!isLoggedIn && (
108
- <div className="account-actions-block">
109
- <div className="action-item">
110
- <div>
111
- <span>
112
- Create (or log in to) your account, then click on Confirm Registration.
113
- </span>
114
- <span> If you have a</span>
115
- <b> Mana Common </b>
116
- <span>account and password already</span>
117
- </div>
118
- </div>
119
- <div className="action-item login-block">
120
- <button
121
- className="login-register-button"
122
- type="button"
123
- onClick={() => {
124
- setShowModalLogin(true)
125
- }}
126
- >
127
- Login
128
- </button>
129
- </div>
130
- </div>
131
- )}
132
- {showModalLogin && (
133
- <LoginModal
134
- logo={logo}
135
- onClose={() => {
136
- setShowModalLogin(false)
137
- }}
138
- onLogin={res => {
139
- setShowModalLogin(false)
140
- onLoginSuccess(res)
141
- }}
142
- showForgotPasswordButton={showForgotPasswordButton}
143
- onForgotPassword={() => {
144
- setShowModalLogin(false)
145
- setShowModalForgotPassword(true)
146
- }}
147
- alreadyHasUser={alreadyHasUser}
148
- />
149
- )}
150
- {showModalForgotPassword && (
151
- <ForgotPasswordModal
120
+ <ThemeProvider theme={themeMui}>
121
+ <div className="pre-registration-container">
122
+ <SnackbarAlert
123
+ type="error"
124
+ isOpen={!!error}
125
+ message={error || ''}
152
126
  onClose={() => {
153
- setShowModalForgotPassword(false)
127
+ setError('')
154
128
  }}
155
- onLoginButtonClick={() => {
156
- setShowModalForgotPassword(false)
157
- setShowModalLogin(true)
158
- }}
159
- onForgotPasswordSuccess={onForgotPasswordSuccess}
160
- onForgotPasswordError={onForgotPasswordError}
161
129
  />
162
- )}
163
- <h2>Pre-Registration</h2>
164
- <Formik
165
- initialValues={getFormInitialValues(formFields)}
166
- enableReinitialize={true}
167
- onSubmit={async (values: FormikValues) => {
168
- try {
169
- if (isLoggedIn) {
170
- if (isPreregistrationStarted) {
171
- const updatedValues = { ...values }
172
- const holderAgeDate = new Date(values.holderAge)
173
- updatedValues.dobDay = holderAgeDate.getDate()
174
- updatedValues.dobMonth = holderAgeDate.getMonth() + 1
175
- updatedValues.dobYear = holderAgeDate.getFullYear()
176
- updatedValues.referrerId = referrerId
177
- updatedValues.shareHash = hash
178
- // remove date picker string value
179
- delete updatedValues.holderAge
130
+ {confirmModalState.show && (
131
+ <ConfirmModal
132
+ hideCancelBtn
133
+ onConfirm={() => setConfirmModalState({ show: false, message: '' })}
134
+ message={confirmModalState.message}
135
+ />
136
+ )}
137
+ {!isLoggedIn && (
138
+ <div className="account-actions-block">
139
+ <div className="action-item">
140
+ <div>
141
+ <span>
142
+ Create (or log in to) your account, then click on Confirm Registration.
143
+ </span>
144
+ <span> If you have a</span>
145
+ <b> {CONFIGS.CLIENT_NAME || 'Mana Common'} </b>
146
+ <span>account and password already</span>
147
+ </div>
148
+ </div>
149
+ <div className="action-item login-block">
150
+ <button
151
+ className="login-register-button"
152
+ type="button"
153
+ onClick={() => {
154
+ setShowModalLogin(true)
155
+ }}
156
+ >
157
+ Login
158
+ </button>
159
+ </div>
160
+ </div>
161
+ )}
162
+ {showModalLogin && (
163
+ <LoginModal
164
+ logo={logo}
165
+ onClose={() => {
166
+ setShowModalLogin(false)
167
+ }}
168
+ onLogin={res => {
169
+ setShowModalLogin(false)
170
+ onLoginSuccess(res)
171
+ }}
172
+ showForgotPasswordButton={showForgotPasswordButton}
173
+ onForgotPassword={() => {
174
+ setShowModalLogin(false)
175
+ setShowModalForgotPassword(true)
176
+ }}
177
+ alreadyHasUser={alreadyHasUser}
178
+ />
179
+ )}
180
+ {showModalForgotPassword && (
181
+ <ForgotPasswordModal
182
+ onClose={() => {
183
+ setShowModalForgotPassword(false)
184
+ }}
185
+ onLoginButtonClick={() => {
186
+ setShowModalForgotPassword(false)
187
+ setShowModalLogin(true)
188
+ }}
189
+ onForgotPasswordSuccess={onForgotPasswordSuccess}
190
+ onForgotPasswordError={onForgotPasswordError}
191
+ displaySuccessMessage
192
+ />
193
+ )}
194
+ {isPreRegistrationComplete ? (
195
+ <PreRegistrationComplete
196
+ eventId={eventId}
197
+ logo={logo}
198
+ themeOptions={themeOptions}
199
+ onLoginSuccess={onLoginSuccess}
200
+ data={{} as IShareOptionsData}
201
+ classNamePrefix=""
202
+ onLinkCopied={_identity}
203
+ updateShareActionData={_identity}
204
+ hash={hash}
205
+ shareActionData={{} as ISubmitShareActionAttributes}
206
+ skipInitialValidation={true}
207
+ />
208
+ ) : (
209
+ <>
210
+ <h2>Pre-Registration</h2>
211
+ <Formik
212
+ initialValues={getFormInitialValues(formFields)}
213
+ enableReinitialize={true}
214
+ onSubmit={async (values: FormikValues) => {
215
+ try {
216
+ if (isLoggedIn) {
217
+ if (isPreregistrationStarted) {
218
+ const updatedValues = { ...values }
219
+ const holderAgeDate = new Date(values.holderAge)
220
+ updatedValues.dobDay = holderAgeDate.getDate()
221
+ updatedValues.dobMonth = holderAgeDate.getMonth() + 1
222
+ updatedValues.dobYear = holderAgeDate.getFullYear()
223
+ updatedValues.referrerId = referrerId
224
+ updatedValues.shareHash = hash
225
+ // remove date picker string value
226
+ delete updatedValues.holderAge
180
227
 
181
- const confirmationData = await confirmPreRegistration(
182
- eventId,
183
- updatedValues as IConfirmPreRegistrationRequestData
184
- )
185
- if (isWindowDefined) {
186
- window.localStorage.setItem(
187
- 'pre-registration-hash',
188
- _get(confirmationData, 'attributes.hash')
189
- )
190
- }
228
+ const confirmationData = await confirmPreRegistration(
229
+ eventId,
230
+ updatedValues as IConfirmPreRegistrationRequestData
231
+ )
232
+ if (isWindowDefined) {
233
+ window.localStorage.setItem(
234
+ 'pre-registration-hash',
235
+ _get(confirmationData, 'attributes.hash')
236
+ )
237
+ }
191
238
 
192
- onConfirmationSuccess(confirmationData)
193
- } else {
194
- setConfirmModalState({
195
- show: true,
196
- message: 'The preregistration has not started',
197
- })
198
- }
199
- } else {
200
- const bodyFormData = new FormData()
201
- bodyFormData.append('first_name', values.firstName)
202
- bodyFormData.append('last_name', values.lastName)
203
- bodyFormData.append('email', values.email)
204
- bodyFormData.append('confirm_email', values.confirmEmail)
205
- bodyFormData.append('zip', values.zip)
206
- bodyFormData.append('country', values.country)
207
- bodyFormData.append('password', values.password)
208
- bodyFormData.append('password_confirmation', values.confirmPassword)
209
- bodyFormData.append('client_id', CONFIGS.CLIENT_ID)
210
- bodyFormData.append('client_secret', CONFIGS.CLIENT_SECRET)
211
- bodyFormData.append('register_for', 'prereg')
239
+ setIsPreRegistrationComplete(true)
240
+ onConfirmationSuccess(confirmationData)
241
+ } else {
242
+ setConfirmModalState({
243
+ show: true,
244
+ message: 'The preregistration has not started',
245
+ })
246
+ }
247
+ } else {
248
+ const bodyFormData = new FormData()
249
+ bodyFormData.append('first_name', values.firstName)
250
+ bodyFormData.append('last_name', values.lastName)
251
+ bodyFormData.append('email', values.email)
252
+ bodyFormData.append('confirm_email', values.confirmEmail)
253
+ bodyFormData.append('zip', values.zip)
254
+ bodyFormData.append('country', values.country)
255
+ bodyFormData.append('password', values.password)
256
+ bodyFormData.append('password_confirmation', values.confirmPassword)
257
+ bodyFormData.append('client_id', CONFIGS.CLIENT_ID)
258
+ bodyFormData.append('client_secret', CONFIGS.CLIENT_SECRET)
259
+ bodyFormData.append('register_for', 'prereg')
212
260
 
213
- const res = await register(bodyFormData)
214
- const profileRes = await getProfileData()
215
- onLoginSuccess(res.data)
216
- if (isWindowDefined) {
217
- window.localStorage.setItem(
218
- 'user_data',
219
- JSON.stringify(_get(profileRes, 'data'))
220
- )
221
- setUserData(_get(profileRes, 'data'))
222
- }
223
- }
224
- } catch (e) {
225
- let errorMessage = e?.message || 'Error'
226
- const emailErrors = e?.response?.data?.message?.email
261
+ const res = await register(bodyFormData)
262
+ const profileRes = await getProfileData()
263
+ onLoginSuccess(res.data)
264
+ if (isWindowDefined) {
265
+ window.localStorage.setItem(
266
+ 'user_data',
267
+ JSON.stringify(_get(profileRes, 'data'))
268
+ )
269
+ setUserData(_get(profileRes, 'data'))
270
+ }
271
+ }
272
+ } catch (e) {
273
+ const error = e as AxiosError
274
+ let errorMessage = error?.message || 'Error'
275
+ const emailErrors = _get(error, 'response.data.message.email') || ''
276
+ const errorDataMessage = _get(error, 'response.data.message')
227
277
 
228
- if (typeof e?.response?.data?.message === 'string') {
229
- errorMessage = e?.response?.data?.message
230
- }
231
- if (emailErrors?.length > 0) {
232
- if (emailErrors[0] === 'The email is already used') {
233
- setShowModalLogin(true)
234
- setAlreadyHasUser(true)
235
- }
236
- } else {
237
- setError(errorMessage)
238
- }
278
+ if (typeof errorDataMessage === 'string') {
279
+ errorMessage = errorDataMessage
280
+ }
281
+ if (emailErrors?.length > 0) {
282
+ if (emailErrors[0] === 'The email is already used') {
283
+ setShowModalLogin(true)
284
+ setAlreadyHasUser(true)
285
+ }
286
+ } else {
287
+ setError(errorMessage)
288
+ }
239
289
 
240
- onConfirmationError(e)
241
- }
242
- }}
243
- >
244
- {props => (
245
- <Form>
246
- <div className="login-modal-body">
247
- <FieldsSection
248
- formFields={formFields}
249
- values={props.values}
250
- setFieldValue={props.setFieldValue}
251
- containerClass="pre-registration"
252
- countries={countries}
253
- />
254
- </div>
255
- <div className="button-container">
256
- <Button
257
- type="submit"
258
- variant="contained"
259
- className="login-register-button"
260
- disabled={props.isSubmitting}
261
- >
262
- {props.isSubmitting ? (
263
- <CircularProgress size={26} />
264
- ) : isLoggedIn ? (
265
- 'Confirm Pre-Registration'
266
- ) : (
267
- 'Create Account'
268
- )}
269
- </Button>
270
- </div>
271
- </Form>
290
+ onConfirmationError(error)
291
+ }
292
+ }}
293
+ >
294
+ {props => (
295
+ <Form>
296
+ <div className="login-modal-body">
297
+ <FieldsSection
298
+ formFields={formFields}
299
+ values={props.values}
300
+ setFieldValue={props.setFieldValue}
301
+ containerClass="pre-registration"
302
+ countries={countries}
303
+ themeOptions={themeOptions}
304
+ />
305
+ </div>
306
+ <div className="button-container">
307
+ <Button
308
+ type="submit"
309
+ variant="contained"
310
+ className="login-register-button"
311
+ disabled={props.isSubmitting}
312
+ >
313
+ {props.isSubmitting ? (
314
+ <CircularProgress size={26} />
315
+ ) : isLoggedIn ? (
316
+ 'Confirm Pre-Registration'
317
+ ) : (
318
+ 'Create Account'
319
+ )}
320
+ </Button>
321
+ </div>
322
+ </Form>
323
+ )}
324
+ </Formik>
325
+ </>
272
326
  )}
273
- </Formik>
274
- </div>
327
+ </div>
328
+ </ThemeProvider>
275
329
  )
276
330
  }
@@ -0,0 +1,3 @@
1
+ .preregistration_confirmation_header {
2
+ margin-bottom: 2rem;
3
+ }
@@ -1,5 +1,7 @@
1
1
  import React from 'react'
2
2
 
3
+ import { CONFIGS } from '../../utils'
4
+
3
5
  export const formDefaultFields: IFormFieldsSection[] = [
4
6
  {
5
7
  name: 'basic-info',
@@ -68,7 +70,7 @@ export const formDefaultFields: IFormFieldsSection[] = [
68
70
  groupLabel: (
69
71
  <div className="email-info-block">
70
72
  <span>Choose a password for your new</span>
71
- <b> Mana Common </b>
73
+ <b> {CONFIGS.CLIENT_NAME || 'Mana Common'} </b>
72
74
  <span>account</span>
73
75
  </div>
74
76
  ),
@@ -63,7 +63,7 @@ export const RegistrationForm: FC<IRegistrationProps> = ({
63
63
  onGetCountriesSuccess(res.data)
64
64
  } catch (e) {
65
65
  if (axios.isAxiosError(e)) {
66
- const errorMessage = e?.response?.data?.message || 'Error'
66
+ const errorMessage = _get(e, 'response.data.message') || 'Error'
67
67
  setErrorMessage(errorMessage)
68
68
  onGetCountriesError(e)
69
69
  }
@@ -81,7 +81,7 @@ export const RegistrationForm: FC<IRegistrationProps> = ({
81
81
  onGetStatesSuccess(res.data)
82
82
  } catch (e) {
83
83
  if (axios.isAxiosError(e)) {
84
- const errorMessage = e?.response?.data?.message || 'Error'
84
+ const errorMessage = _get(e, 'response.data.message', {}) as AxiosError
85
85
  onGetStatesError(errorMessage)
86
86
  }
87
87
  }
@@ -115,7 +115,7 @@ export const RegistrationForm: FC<IRegistrationProps> = ({
115
115
  } catch (e) {
116
116
  if (axios.isAxiosError(e)) {
117
117
  console.log(e)
118
- const errorMessage = e?.response?.data?.message || 'Error'
118
+ const errorMessage = _get(e, 'response.data.message') || 'Error'
119
119
  onRegisterAccountError(e)
120
120
  setshowErrorModal(true)
121
121
  setErrorMessage(errorMessage)