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.
- package/README.md +401 -59
- package/dist/adapters/customFields.d.ts +1 -0
- package/dist/api/checkout.d.ts +2 -0
- package/dist/api/common.d.ts +1 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/preRegistrationComplete.d.ts +1 -1
- package/dist/components/addonsContainer/AddonComponent.d.ts +6 -1
- package/dist/components/addonsContainer/SimpleAddonsContainer.d.ts +17 -0
- package/dist/components/addonsContainer/index.d.ts +6 -1
- package/dist/components/billing-info-container/hooks/index.d.ts +3 -0
- package/dist/components/billing-info-container/hooks/usePaymentContext.d.ts +5 -0
- package/dist/components/billing-info-container/hooks/usePaymentRedirect.d.ts +14 -0
- package/dist/components/billing-info-container/hooks/useStripePayment.d.ts +18 -0
- package/dist/components/billing-info-container/index.d.ts +13 -2
- package/dist/components/billing-info-container/utils.d.ts +25 -1
- package/dist/components/common/DatePickerField.d.ts +7 -1
- package/dist/components/confirmationContainer/index.d.ts +4 -1
- package/dist/components/countdown/index.d.ts +1 -1
- package/dist/components/forgotPasswordModal/index.d.ts +2 -1
- package/dist/components/myTicketsContainer/index.d.ts +3 -2
- package/dist/components/orderDetailsContainer/index.d.ts +8 -1
- package/dist/components/paymentContainer/OrderDetails.d.ts +9 -0
- package/dist/components/paymentContainer/handlePayment.d.ts +15 -0
- package/dist/components/paymentContainer/index.d.ts +12 -6
- package/dist/components/preRegistration/FieldsSection.d.ts +7 -1
- package/dist/components/preRegistration/PreRegistrationComplete.d.ts +6 -0
- package/dist/components/preRegistration/constants.d.ts +2 -2
- package/dist/components/preRegistration/index.d.ts +6 -0
- package/dist/components/resetPasswordContainer/index.d.ts +2 -2
- package/dist/components/ticketsContainer/InfoIcon.d.ts +5 -0
- package/dist/components/ticketsContainer/TicketsSection.d.ts +3 -2
- package/dist/components/ticketsContainer/TimeSlotsSection.d.ts +25 -0
- package/dist/components/ticketsContainer/index.d.ts +29 -5
- package/dist/components/timerWidget/index.d.ts +2 -1
- package/dist/constants/index.d.ts +5 -0
- package/dist/index.d.ts +4 -1
- package/dist/tf-checkout-react.cjs.development.js +11231 -9563
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +11194 -9529
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/dist/types/add_on.d.ts +1 -0
- package/dist/types/checkoutPageConfigs.d.ts +1 -1
- package/dist/types/order-data.d.ts +3 -1
- package/dist/utils/auth.d.ts +8 -0
- package/dist/utils/customFields.d.ts +11 -0
- package/dist/utils/getDomain.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/setConfigs.d.ts +1 -0
- package/package.json +14 -8
- package/src/adapters/customFields.ts +7 -1
- package/src/api/auth.ts +2 -1
- package/src/api/checkout.ts +9 -4
- package/src/api/common.ts +49 -2
- package/src/api/index.ts +1 -0
- package/src/api/interceptors.ts +7 -23
- package/src/api/preRegistrationComplete.ts +1 -1
- package/src/api/publicRequest.ts +10 -0
- package/src/components/addonsContainer/AddonComponent.tsx +96 -11
- package/src/components/addonsContainer/SimpleAddonsContainer.tsx +420 -0
- package/src/components/addonsContainer/index.tsx +198 -47
- package/src/components/billing-info-container/hooks/index.ts +3 -0
- package/src/components/billing-info-container/hooks/usePaymentContext.ts +22 -0
- package/src/components/billing-info-container/hooks/usePaymentRedirect.ts +147 -0
- package/src/components/billing-info-container/hooks/useStripePayment.ts +121 -0
- package/src/components/billing-info-container/index.tsx +827 -406
- package/src/components/billing-info-container/{utils.ts → utils.tsx} +119 -0
- package/src/components/common/CheckboxField/index.tsx +1 -1
- package/src/components/common/CustomField.tsx +38 -2
- package/src/components/common/DatePickerField.tsx +25 -10
- package/src/components/common/SnackbarAlert.tsx +32 -34
- package/src/components/confirmationContainer/config.ts +3 -3
- package/src/components/confirmationContainer/index.tsx +20 -1
- package/src/components/confirmationContainer/social-buttons.tsx +5 -3
- package/src/components/confirmationContainer/style.css +9 -5
- package/src/components/countdown/index.tsx +22 -22
- package/src/components/delegationsContainer/IssueComponent.tsx +2 -1
- package/src/components/forgotPasswordModal/index.tsx +44 -13
- package/src/components/loginForm/index.tsx +1 -1
- package/src/components/loginModal/index.tsx +19 -27
- package/src/components/loginModal/style.css +3 -1
- package/src/components/myTicketsContainer/index.tsx +13 -9
- package/src/components/orderDetailsContainer/index.tsx +206 -174
- package/src/components/paymentContainer/OrderDetails.tsx +257 -0
- package/src/components/paymentContainer/handlePayment.ts +86 -0
- package/src/components/paymentContainer/index.tsx +299 -259
- package/src/components/paymentContainer/style.css +141 -0
- package/src/components/preRegistration/FieldsSection.tsx +8 -0
- package/src/components/preRegistration/PreRegistrationComplete.tsx +128 -118
- package/src/components/preRegistration/PreRegistrationInformations.tsx +21 -15
- package/src/components/preRegistration/constants.tsx +10 -4
- package/src/components/preRegistration/index.tsx +194 -174
- package/src/components/registerForm/constants.tsx +3 -1
- package/src/components/registerForm/index.tsx +3 -3
- package/src/components/registerModal/index.tsx +47 -72
- package/src/components/resetPasswordContainer/index.tsx +20 -14
- package/src/components/seatMapContainer/TicketsSection.tsx +2 -2
- package/src/components/signupModal/index.tsx +13 -6
- package/src/components/ticketResale/index.tsx +7 -0
- package/src/components/ticketsContainer/InfoIcon.tsx +35 -0
- package/src/components/ticketsContainer/PromoCodeSection.tsx +34 -28
- package/src/components/ticketsContainer/TicketRow.tsx +1 -1
- package/src/components/ticketsContainer/TicketsSection.tsx +189 -57
- package/src/components/ticketsContainer/TimeSlotsSection.tsx +120 -0
- package/src/components/ticketsContainer/index.tsx +268 -106
- package/src/components/timerWidget/index.tsx +15 -3
- package/src/constants/index.ts +2 -0
- package/src/env.ts +14 -6
- package/src/hoc/CustomFields/index.tsx +9 -1
- package/src/index.ts +7 -2
- package/src/types/add_on.ts +1 -0
- package/src/types/api/cart.d.ts +8 -0
- package/src/types/api/checkout.d.ts +58 -7
- package/src/types/api/common.d.ts +30 -0
- package/src/types/api/orders.d.ts +19 -3
- package/src/types/api/payment.d.ts +6 -2
- package/src/types/api/preRegistrationComplete.d.ts +2 -2
- package/src/types/checkoutPageConfigs.ts +1 -1
- package/src/types/order-data.ts +3 -1
- package/src/types/pre-registration-complete.d.ts +6 -1
- package/src/utils/auth.ts +32 -0
- package/src/utils/cookies.ts +42 -11
- package/src/utils/customFields.ts +22 -0
- package/src/utils/getDomain.ts +10 -4
- package/src/utils/index.ts +1 -1
- package/src/utils/setConfigs.ts +3 -1
- package/dist/components/stripePayment/index.d.ts +0 -24
- package/src/components/stripePayment/index.tsx +0 -281
- package/src/components/stripePayment/style.css +0 -60
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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 {
|
|
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 =
|
|
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
|
-
<
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
'
|
|
188
|
-
_get(
|
|
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
|
-
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
214
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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>
|