tf-checkout-react 1.6.6 → 1.7.1

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