tf-checkout-react 1.0.81 → 1.0.82

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.81",
2
+ "version": "1.0.82",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -27,6 +27,7 @@ import {
27
27
  register,
28
28
  setCustomHeader,
29
29
  getStates,
30
+ getPaymentData,
30
31
  } from '../../api'
31
32
  import { LoginModal } from '../loginModal'
32
33
  import { RegisterModal } from '../registerModal'
@@ -41,7 +42,7 @@ import {
41
42
  import { CustomField } from '../common/CustomField'
42
43
  import axios from 'axios'
43
44
  import { CheckboxField } from '../common/CheckboxField'
44
- import { CircularProgress, ThemeOptions } from '@mui/material'
45
+ import { Alert, CircularProgress, ThemeOptions } from '@mui/material'
45
46
  import { nanoid } from 'nanoid'
46
47
  import { getQueryVariable } from '../../utils/getQueryVariable'
47
48
  import { SelectField } from '../common/SelectField'
@@ -92,6 +93,7 @@ export interface IBillingInfoPage {
92
93
 
93
94
  onLogin?: () => void;
94
95
  onLoginSuccess?: () => void;
96
+ onErrorClose?: () => void;
95
97
 
96
98
  initialValues?: FormikValues;
97
99
  buttonName?: string;
@@ -117,7 +119,7 @@ const LogicRunner: FC<{
117
119
  setValues,
118
120
  setUserValues,
119
121
  onGetStatesSuccess,
120
- onGetStatesError,
122
+ onGetStatesError
121
123
  }) => {
122
124
  const prevCountry = useRef(values.country)
123
125
  useEffect(() => {
@@ -211,7 +213,8 @@ export const BillingInfoContainer = ({
211
213
  isLoggedIn: pIsLoggedIn = false,
212
214
  accountInfoTitle = '',
213
215
  hideLogo,
214
- themeOptions
216
+ themeOptions,
217
+ onErrorClose = () => {}
215
218
  }: IBillingInfoPage) => {
216
219
  const themeMui = createTheme(themeOptions)
217
220
  const isWindowDefined = typeof window !== 'undefined'
@@ -252,6 +255,7 @@ export const BillingInfoContainer = ({
252
255
  state: '',
253
256
  zip: '',
254
257
  })
258
+ const [error, setError] = useState(null)
255
259
  const emailLogged =
256
260
  _get(userData, 'email', '') || _get(userValues, 'email', '')
257
261
  const firstNameLogged =
@@ -403,6 +407,7 @@ export const BillingInfoContainer = ({
403
407
  showDOB
404
408
  )
405
409
  const res = await postOnCheckout(checkoutBody, access_token)
410
+ await getPaymentData(res.data.data.attributes.hash)
406
411
  handleSubmit(
407
412
  values,
408
413
  formikHelpers as FormikHelpers<any>,
@@ -487,6 +492,7 @@ export const BillingInfoContainer = ({
487
492
  checkoutBody,
488
493
  access_token_register
489
494
  )
495
+ await getPaymentData(res.data.data.attributes.hash)
490
496
  handleSubmit(
491
497
  values,
492
498
  formikHelpers as FormikHelpers<any>,
@@ -503,6 +509,12 @@ export const BillingInfoContainer = ({
503
509
  setShowModalLogin(true)
504
510
  }
505
511
  }
512
+ if (e.response?.data.message) {
513
+ if (typeof document !== undefined) {
514
+ document.body.scrollTop = document.documentElement.scrollTop = 0
515
+ }
516
+ setError(_get(e, 'response.data.message'))
517
+ }
506
518
  onSubmitError(e)
507
519
  }
508
520
  }
@@ -521,6 +533,11 @@ export const BillingInfoContainer = ({
521
533
  onGetStatesError={onGetStatesError}
522
534
  />
523
535
  <div className={`billing-info-container ${theme}`}>
536
+ {error && (
537
+ <Alert severity="error" onClose={onErrorClose} variant="filled">
538
+ {error}
539
+ </Alert>
540
+ )}
524
541
  {!isLoggedIn && (
525
542
  <div className="account-actions-block">
526
543
  <div>{accountInfoTitle}</div>