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.
- 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 +26 -1
- package/dist/components/common/DatePickerField.d.ts +7 -1
- package/dist/components/common/PhoneNumberField.d.ts +1 -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 +8 -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 +11284 -9565
- 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 +11293 -9577
- 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/createCheckoutDataBodyWithDefaultHolder.d.ts +1 -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 +859 -418
- package/src/components/billing-info-container/{utils.ts → utils.tsx} +124 -1
- package/src/components/common/CheckboxField/index.tsx +1 -1
- package/src/components/common/CustomField.tsx +39 -3
- package/src/components/common/DatePickerField.tsx +25 -10
- package/src/components/common/PhoneNumberField.tsx +4 -2
- 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 +138 -118
- package/src/components/preRegistration/PreRegistrationInformations.tsx +21 -15
- package/src/components/preRegistration/constants.tsx +10 -4
- package/src/components/preRegistration/index.tsx +233 -179
- package/src/components/preRegistration/style.css +3 -0
- 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/components/timerWidget/style.css +2 -1
- 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/createCheckoutDataBodyWithDefaultHolder.ts +3 -1
- 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,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 {
|
|
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 =
|
|
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
|
|
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
|
-
<
|
|
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}
|
|
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
|
-
|
|
127
|
+
setError('')
|
|
154
128
|
}}
|
|
155
|
-
onLoginButtonClick={() => {
|
|
156
|
-
setShowModalForgotPassword(false)
|
|
157
|
-
setShowModalLogin(true)
|
|
158
|
-
}}
|
|
159
|
-
onForgotPasswordSuccess={onForgotPasswordSuccess}
|
|
160
|
-
onForgotPasswordError={onForgotPasswordError}
|
|
161
129
|
/>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
</
|
|
274
|
-
</
|
|
327
|
+
</div>
|
|
328
|
+
</ThemeProvider>
|
|
275
329
|
)
|
|
276
330
|
}
|
|
@@ -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)
|