tf-checkout-react 1.3.31 → 1.3.34

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.
@@ -14,6 +14,7 @@ import {
14
14
  FormikProps,
15
15
  FormikValues,
16
16
  } from 'formik'
17
+ import _find from 'lodash/find'
17
18
  import _get from 'lodash/get'
18
19
  import _identity from 'lodash/identity'
19
20
  import _includes from 'lodash/includes'
@@ -46,6 +47,7 @@ import {
46
47
  CheckboxField,
47
48
  CustomField,
48
49
  PhoneNumberField,
50
+ RadioGroupField,
49
51
  SelectField,
50
52
  } from '../common/index'
51
53
  import SnackbarAlert from '../common/SnackbarAlert'
@@ -253,6 +255,9 @@ export const BillingInfoContainer = React.memo(
253
255
  const [isNewUser, setIsNewUser] = useState(false)
254
256
  const themeMui = createTheme(themeOptions)
255
257
  const isWindowDefined = typeof window !== 'undefined'
258
+ const defaultCountry = isWindowDefined
259
+ ? window.localStorage.getItem('eventCountry')
260
+ : ''
256
261
  const userData =
257
262
  isWindowDefined && window.localStorage.getItem('user_data')
258
263
  ? JSON.parse(window.localStorage.getItem('user_data') || '')
@@ -293,6 +298,7 @@ export const BillingInfoContainer = React.memo(
293
298
  zip: '',
294
299
  })
295
300
  const [loading, setLoading] = useState(true)
301
+ const [isCountriesLoading, setIsCountriesLoading] = useState(true)
296
302
  const [error, setError] = useState(null)
297
303
  const [phoneValidationIsLoading, setPhoneValidationIsLoading] = useState(
298
304
  false
@@ -362,16 +368,19 @@ export const BillingInfoContainer = React.memo(
362
368
  const res = await getCountries()
363
369
  setCustomHeader(res)
364
370
  setCountries(
365
- _map(_get(res, 'data.data'), (item, key) => ({
366
- label: item,
367
- value: key,
371
+ _map(_get(res, 'data.data'), item => ({
372
+ label: item.name,
373
+ value: item.id,
374
+ code: item.code,
368
375
  }))
369
376
  )
377
+ setIsCountriesLoading(false)
370
378
  onGetCountriesSuccess(res.data)
371
379
  } catch (e) {
372
380
  if (axios.isAxiosError(e)) {
373
381
  onGetCountriesError(e)
374
382
  }
383
+ setIsCountriesLoading(false)
375
384
  }
376
385
  }
377
386
  shouldFetchCountries && fetchCountries()
@@ -512,7 +521,7 @@ export const BillingInfoContainer = React.memo(
512
521
 
513
522
  return (
514
523
  <ThemeProvider theme={themeMui}>
515
- {loading && (
524
+ {(loading || isCountriesLoading) && (
516
525
  <Backdrop
517
526
  sx={{ color: '#fff', backgroundColor: '#000000bd', zIndex: 1205 }}
518
527
  open={true}
@@ -526,482 +535,504 @@ export const BillingInfoContainer = React.memo(
526
535
  onCountdownFinish={onCountdownFinish}
527
536
  />
528
537
  )}
529
- <Formik
530
- initialValues={getInitialValues(
531
- dataWithUniqueIds,
532
- {
533
- country: _get(userData, 'country', '') || '1',
534
- state: _get(userData, 'state', '') || '1',
535
- brand_opt_in: optedInFieldValue,
536
- ttf_opt_in: ttfOptIn,
537
- ...initialValues,
538
- },
539
- userValues
540
- )}
541
- enableReinitialize={false}
542
- onSubmit={async (values, formikHelpers) => {
543
- try {
544
- if (isLoggedIn) {
545
- const checkoutBody = collectCheckoutBody(values, userData)
538
+ {!isCountriesLoading && (
539
+ <Formik
540
+ initialValues={getInitialValues(
541
+ dataWithUniqueIds,
542
+ {
543
+ country:
544
+ (
545
+ _find(
546
+ countries,
547
+ item => item.code.toLowerCase() === defaultCountry
548
+ ) || {}
549
+ ).value ||
550
+ _get(userData, 'country', '') ||
551
+ '1',
552
+ state: _get(userData, 'state', '') || '1',
553
+ brand_opt_in: optedInFieldValue,
554
+ ttf_opt_in: ttfOptIn,
555
+ ...initialValues,
556
+ },
557
+ userValues
558
+ )}
559
+ enableReinitialize={false}
560
+ onSubmit={async (values, formikHelpers) => {
561
+ try {
562
+ if (isLoggedIn) {
563
+ const checkoutBody = collectCheckoutBody(values, userData)
546
564
 
547
- if (isWindowDefined) {
548
- addAddOnsInAttributes(checkoutBody)
549
- }
565
+ if (isWindowDefined) {
566
+ addAddOnsInAttributes(checkoutBody)
567
+ }
550
568
 
551
- const res = await postOnCheckout(
552
- checkoutBody,
553
- access_token,
569
+ const res = await postOnCheckout(
570
+ checkoutBody,
571
+ access_token,
572
+ flagFreeTicket
573
+ )
574
+ removeReferralKey()
575
+ // After checkout is successful recover updated profile and store it on local storage if needed
576
+ if (isWindowDefined) {
577
+ const updatedUserData = await getProfileData(access_token)
578
+ const profileSpecifiedData = _get(
579
+ updatedUserData,
580
+ 'data.data'
581
+ )
582
+ const profileDataObj = setLoggedUserData(
583
+ profileSpecifiedData
584
+ )
585
+ window.localStorage.setItem(
586
+ 'user_data',
587
+ JSON.stringify(profileDataObj)
588
+ )
589
+ }
590
+
591
+ handleSubmit(
592
+ values,
593
+ formikHelpers as FormikHelpers<any>,
594
+ eventId,
595
+ res
596
+ )
597
+ return
598
+ }
599
+ const checkoutBodyForRegistration = createCheckoutDataBody(
600
+ ticketsQuantity.length,
601
+ values,
602
+ { emailLogged, firstNameLogged, lastNameLogged },
603
+ showDOB
604
+ )
605
+ const bodyFormData = createRegisterFormData(
606
+ values,
607
+ checkoutBodyForRegistration,
554
608
  flagFreeTicket
555
609
  )
556
- removeReferralKey()
557
- // After checkout is successful recover updated profile and store it on local storage if needed
558
- if (isWindowDefined) {
559
- const updatedUserData = await getProfileData(access_token)
560
- const profileSpecifiedData = _get(
561
- updatedUserData,
562
- 'data.data'
610
+ try {
611
+ setLoading(true)
612
+ const resRegister = await register(bodyFormData)
613
+ const xtfCookie = _get(resRegister, 'headers.x-tf-ecommerce')
614
+ const accessToken = _get(
615
+ resRegister,
616
+ 'data.data.attributes.access_token'
617
+ )
618
+ const refreshToken = _get(
619
+ resRegister,
620
+ 'data.data.attributes.refresh_token'
621
+ )
622
+ const userProfile = _get(
623
+ resRegister,
624
+ 'data.data.attributes.user_profile'
563
625
  )
564
- const profileDataObj = setLoggedUserData(profileSpecifiedData)
626
+
627
+ setIsNewUser(true)
628
+ onRegisterSuccess({
629
+ xtfCookie,
630
+ accessToken,
631
+ refreshToken,
632
+ userProfile,
633
+ })
634
+ } catch (e) {
635
+ setLoading(false)
636
+ if (axios.isAxiosError(e)) {
637
+ const error = e?.response?.data?.message
638
+ if (_includes(error, 'You must be aged')) {
639
+ formikHelpers.setFieldError('holderAge', error)
640
+ }
641
+ if (error?.password) {
642
+ formikHelpers.setFieldError('password', error.password)
643
+ formikHelpers.setFieldError(
644
+ 'confirmPassword',
645
+ error.password
646
+ )
647
+ }
648
+ if (error?.email && !onLogin) {
649
+ // False will stand for outside controll
650
+ setAlreadyHasUser(true)
651
+ setShowModalLogin(true)
652
+ }
653
+
654
+ if (
655
+ _includes(error, 'The cart is expired') &&
656
+ !hideErrorsAlertSection
657
+ ) {
658
+ setError(error)
659
+ }
660
+
661
+ onRegisterError(e, values.email)
662
+ }
663
+ return
664
+ }
665
+ const profileData = await getProfileData()
666
+ const profileSpecifiedData = _get(profileData, 'data.data')
667
+ const profileDataObj = setLoggedUserData(profileSpecifiedData)
668
+ if (isWindowDefined) {
565
669
  window.localStorage.setItem(
566
670
  'user_data',
567
671
  JSON.stringify(profileDataObj)
568
672
  )
569
673
  }
570
674
 
675
+ const checkoutBody = collectCheckoutBody(values, profileDataObj)
676
+
677
+ if (isWindowDefined) {
678
+ addAddOnsInAttributes(checkoutBody)
679
+ }
680
+
681
+ const res = await postOnCheckout(
682
+ checkoutBody,
683
+ undefined,
684
+ flagFreeTicket
685
+ )
686
+ removeReferralKey()
571
687
  handleSubmit(
572
688
  values,
573
689
  formikHelpers as FormikHelpers<any>,
574
690
  eventId,
575
691
  res
576
692
  )
577
- return
578
- }
579
- const checkoutBodyForRegistration = createCheckoutDataBody(
580
- ticketsQuantity.length,
581
- values,
582
- { emailLogged, firstNameLogged, lastNameLogged },
583
- showDOB
584
- )
585
- const bodyFormData = createRegisterFormData(
586
- values,
587
- checkoutBodyForRegistration,
588
- flagFreeTicket
589
- )
590
- try {
591
- setLoading(true)
592
- const resRegister = await register(bodyFormData)
593
- const xtfCookie = _get(resRegister, 'headers.x-tf-ecommerce')
594
- const accessToken = _get(
595
- resRegister,
596
- 'data.data.attributes.access_token'
597
- )
598
- const refreshToken = _get(
599
- resRegister,
600
- 'data.data.attributes.refresh_token'
601
- )
602
- const userProfile = _get(
603
- resRegister,
604
- 'data.data.attributes.user_profile'
605
- )
606
-
607
- setIsNewUser(true)
608
- onRegisterSuccess({
609
- xtfCookie,
610
- accessToken,
611
- refreshToken,
612
- userProfile,
613
- })
614
693
  } catch (e) {
615
694
  setLoading(false)
616
695
  if (axios.isAxiosError(e)) {
617
- const error = e?.response?.data?.message
618
- if (_includes(error, 'You must be aged')) {
619
- formikHelpers.setFieldError('holderAge', error)
620
- }
621
- if (error?.password) {
622
- formikHelpers.setFieldError('password', error.password)
623
- formikHelpers.setFieldError(
624
- 'confirmPassword',
625
- error.password
626
- )
627
- }
628
- if (error?.email && !onLogin) {
629
- // False will stand for outside controll
630
- setAlreadyHasUser(true)
631
- setShowModalLogin(true)
632
- }
633
-
634
696
  if (
635
- _includes(error, 'The cart is expired') &&
636
- !hideErrorsAlertSection
697
+ e.response?.status === 401 ||
698
+ e.response?.data?.error === 'invalid_token'
637
699
  ) {
638
- setError(error)
700
+ if (isWindowDefined) {
701
+ window.localStorage.removeItem('user_data')
702
+ window.localStorage.removeItem('access_token')
703
+ setUserExpired(true)
704
+ setShowModalLogin(true)
705
+ setIsLoggedIn(false)
706
+ setShowModalSignup(false)
707
+ setShowModalForgotPassword(false)
708
+ const event = new window.CustomEvent('tf-logout')
709
+ deleteCookieByName('X-TF-ECOMMERCE')
710
+ window.document.dispatchEvent(event)
711
+ }
639
712
  }
640
-
641
- onRegisterError(e, values.email)
642
- }
643
- return
644
- }
645
- const profileData = await getProfileData()
646
- const profileSpecifiedData = _get(profileData, 'data.data')
647
- const profileDataObj = setLoggedUserData(profileSpecifiedData)
648
- if (isWindowDefined) {
649
- window.localStorage.setItem(
650
- 'user_data',
651
- JSON.stringify(profileDataObj)
652
- )
653
- }
654
-
655
- const checkoutBody = collectCheckoutBody(values, profileDataObj)
656
-
657
- if (isWindowDefined) {
658
- addAddOnsInAttributes(checkoutBody)
659
- }
660
-
661
- const res = await postOnCheckout(
662
- checkoutBody,
663
- undefined,
664
- flagFreeTicket
665
- )
666
- removeReferralKey()
667
- handleSubmit(
668
- values,
669
- formikHelpers as FormikHelpers<any>,
670
- eventId,
671
- res
672
- )
673
- } catch (e) {
674
- setLoading(false)
675
- if (axios.isAxiosError(e)) {
676
- if (
677
- e.response?.status === 401 ||
678
- e.response?.data?.error === 'invalid_token'
679
- ) {
680
- if (isWindowDefined) {
681
- window.localStorage.removeItem('user_data')
682
- window.localStorage.removeItem('access_token')
683
- setUserExpired(true)
684
- setShowModalLogin(true)
685
- setIsLoggedIn(false)
686
- setShowModalSignup(false)
687
- setShowModalForgotPassword(false)
688
- const event = new window.CustomEvent('tf-logout')
689
- deleteCookieByName('X-TF-ECOMMERCE')
690
- window.document.dispatchEvent(event)
713
+ if (e.response?.data.message && !hideErrorsAlertSection) {
714
+ setError(_get(e, 'response.data.message'))
691
715
  }
716
+ onSubmitError(e)
692
717
  }
693
- if (e.response?.data.message && !hideErrorsAlertSection) {
694
- setError(_get(e, 'response.data.message'))
695
- }
696
- onSubmitError(e)
718
+ } finally {
719
+ setLoading(false)
697
720
  }
698
- } finally {
699
- setLoading(false)
700
- }
701
- }}
702
- >
703
- {(props: FormikProps<any>) => (
704
- <Form onSubmit={props.handleSubmit}>
705
- <ErrorFocus />
706
- <LogicRunner
707
- brandOptIn={brandOptIn}
708
- values={props.values}
709
- setStates={setStates}
710
- setFieldValue={props.setFieldValue}
711
- setValues={props.setValues}
712
- setUserValues={setUserValues}
713
- onGetStatesSuccess={onGetStatesSuccess}
714
- onGetStatesError={onGetStatesError}
715
- shouldFetchCountries={shouldFetchCountries}
716
- />
717
- <div className={`billing-info-container ${theme}`}>
718
- <SnackbarAlert
719
- type="error"
720
- isOpen={!!error}
721
- message={error || ''}
722
- onClose={() => {
723
- setError(null)
724
- onErrorClose()
725
- }}
721
+ }}
722
+ >
723
+ {(props: FormikProps<any>) => (
724
+ <Form onSubmit={props.handleSubmit}>
725
+ <ErrorFocus />
726
+ <LogicRunner
727
+ brandOptIn={brandOptIn}
728
+ values={props.values}
729
+ setStates={setStates}
730
+ setFieldValue={props.setFieldValue}
731
+ setValues={props.setValues}
732
+ setUserValues={setUserValues}
733
+ onGetStatesSuccess={onGetStatesSuccess}
734
+ onGetStatesError={onGetStatesError}
735
+ shouldFetchCountries={shouldFetchCountries}
726
736
  />
727
- {!isLoggedIn && (
728
- <div className="account-actions-block">
729
- <div className="action-item">
730
- <div>{accountInfoTitle}</div>
731
- <div>Login & skip ahead:</div>
732
- </div>
733
- <div className="action-item login-block">
734
- <button
735
- className="login-register-button"
736
- type="button"
737
- onClick={() => {
738
- // If outside login needed to skip package login functionallity
739
- if (onLogin) {
740
- onLogin()
741
- } else {
742
- setShowModalLogin(true)
743
- }
744
- }}
745
- >
746
- Login
747
- </button>
748
- {!hideLogo && (
749
- <div className="logo-image-container">
750
- <img
751
- src={
752
- theme === 'dark'
753
- ? 'https://www.ticketfairy.com/resources/images/logo-ttf.svg'
754
- : 'https://www.ticketfairy.com/resources/images/logo-ttf-black.svg'
737
+ <div className={`billing-info-container ${theme}`}>
738
+ <SnackbarAlert
739
+ type="error"
740
+ isOpen={!!error}
741
+ message={error || ''}
742
+ onClose={() => {
743
+ setError(null)
744
+ onErrorClose()
745
+ }}
746
+ />
747
+ {!isLoggedIn && (
748
+ <div className="account-actions-block">
749
+ <div className="action-item">
750
+ <div>{accountInfoTitle}</div>
751
+ <div>Login & skip ahead:</div>
752
+ </div>
753
+ <div className="action-item login-block">
754
+ <button
755
+ className="login-register-button"
756
+ type="button"
757
+ onClick={() => {
758
+ // If outside login needed to skip package login functionallity
759
+ if (onLogin) {
760
+ onLogin()
761
+ } else {
762
+ setShowModalLogin(true)
755
763
  }
756
- alt="nodata"
757
- />
758
- </div>
759
- )}
764
+ }}
765
+ >
766
+ Login
767
+ </button>
768
+ {!hideLogo && (
769
+ <div className="logo-image-container">
770
+ <img
771
+ src={
772
+ theme === 'dark'
773
+ ? 'https://www.ticketfairy.com/resources/images/logo-ttf.svg'
774
+ : 'https://www.ticketfairy.com/resources/images/logo-ttf-black.svg'
775
+ }
776
+ alt="nodata"
777
+ />
778
+ </div>
779
+ )}
780
+ </div>
760
781
  </div>
761
- </div>
762
- )}
763
- {_map(dataWithUniqueIds, item => {
764
- const { label, labelClassName, fields } = item
765
- return (
766
- <React.Fragment key={item.uniqueId}>
767
- <p className={labelClassName}>{label}</p>
768
- {_map(fields, group => {
769
- const { groupClassname, groupItems } = group
770
- return (
771
- <React.Fragment key={group.uniqueId}>
772
- <div className={groupClassname}>
773
- {_map(
774
- groupItems.filter(el => {
775
- if (el.name === 'holderAge' && !showDOB) {
776
- return false
777
- }
778
- if (
779
- el.name === 'ttf_opt_in' &&
780
- hideTtfOptIn
781
- ) {
782
- return false
783
- }
784
- if (el.name === 'phone') {
785
- if (!hidePhoneField) {
786
- el.required = flagRequirePhone
787
- } else {
782
+ )}
783
+ {_map(dataWithUniqueIds, item => {
784
+ const { label, labelClassName, fields } = item
785
+ return (
786
+ <React.Fragment key={item.uniqueId}>
787
+ <p className={labelClassName}>{label}</p>
788
+ {_map(fields, group => {
789
+ const { groupClassname, groupItems } = group
790
+ return (
791
+ <React.Fragment key={group.uniqueId}>
792
+ <div className={groupClassname}>
793
+ {_map(
794
+ groupItems.filter(el => {
795
+ if (el.name === 'holderAge' && !showDOB) {
788
796
  return false
789
797
  }
790
- }
791
- if (
792
- el.name === 'data_capture[wallet_address]'
793
- ) {
794
- if (collectMandatoryWalletAddress) {
795
- el.required = true
798
+ if (
799
+ el.name === 'ttf_opt_in' &&
800
+ hideTtfOptIn
801
+ ) {
802
+ return false
796
803
  }
797
- }
798
- if (
799
- [
800
- 'street_address',
801
- 'country',
802
- 'state',
803
- 'city',
804
- 'zip',
805
- ].includes(el.name)
806
- ) {
807
- if (flagFreeTicket) {
808
- el.required = false
804
+ if (el.name === 'phone') {
805
+ if (!hidePhoneField) {
806
+ el.required = flagRequirePhone
807
+ } else {
808
+ return false
809
+ }
810
+ }
811
+ if (
812
+ el.name === 'data_capture[wallet_address]'
813
+ ) {
814
+ if (collectMandatoryWalletAddress) {
815
+ el.required = true
816
+ }
817
+ }
818
+ if (
819
+ [
820
+ 'street_address',
821
+ 'country',
822
+ 'state',
823
+ 'city',
824
+ 'zip',
825
+ ].includes(el.name)
826
+ ) {
827
+ if (flagFreeTicket) {
828
+ el.required = false
829
+ return false
830
+ }
831
+ }
832
+ if (
833
+ hideWalletAddressField &&
834
+ el.name === 'wallet-address-info'
835
+ ) {
809
836
  return false
810
837
  }
811
- }
812
- if (
813
- hideWalletAddressField &&
814
- el.name === 'wallet-address-info'
815
- ) {
816
- return false
817
- }
818
- return true
819
- }),
820
- element =>
821
- [
822
- 'password',
823
- 'confirmPassword',
824
- 'password-info',
825
- ].includes(element.name) &&
826
- isLoggedIn ? null : [
827
- 'data_capture[wallet_address]',
838
+ return true
839
+ }),
840
+ element =>
841
+ [
842
+ 'password',
843
+ 'confirmPassword',
844
+ 'password-info',
828
845
  ].includes(element.name) &&
829
- hideWalletAddressField ? null : (
830
- <React.Fragment key={element.uniqueId}>
846
+ isLoggedIn ? null : [
847
+ 'data_capture[wallet_address]',
848
+ ].includes(element.name) &&
849
+ hideWalletAddressField ? null : (
850
+ <React.Fragment key={element.uniqueId}>
851
+ <div
852
+ className={`${
853
+ element.className
854
+ } ${props?.errors[element.name] ||
855
+ ''}`}
856
+ >
857
+ {element.component ? (
858
+ element.component
859
+ ) : (
860
+ <Field
861
+ setPhoneValidationIsLoading={
862
+ element.type === 'phone'
863
+ ? setPhoneValidationIsLoading
864
+ : undefined
865
+ }
866
+ name={element.name}
867
+ label={
868
+ element.name === 'phone'
869
+ ? `${element.label}${
870
+ flagRequirePhone
871
+ ? ''
872
+ : ' (optional)'
873
+ } `
874
+ : element.name ===
875
+ 'data_capture[wallet_address]'
876
+ ? `${element.label}${
877
+ !collectMandatoryWalletAddress
878
+ ? ' (optional)'
879
+ : ''
880
+ } `
881
+ : element.label
882
+ }
883
+ type={element.type}
884
+ fill={element.fill}
885
+ validate={getValidateFunctions(
886
+ element,
887
+ states,
888
+ props.values,
889
+ props.errors
890
+ )}
891
+ setFieldValue={
892
+ props.setFieldValue
893
+ }
894
+ onBlur={props.handleBlur}
895
+ component={
896
+ element.type === 'checkbox'
897
+ ? CheckboxField
898
+ : element.type === 'select'
899
+ ? SelectField
900
+ : element.type === 'phone'
901
+ ? PhoneNumberField
902
+ : element.type === 'date'
903
+ ? DatePickerField
904
+ : element.type === 'radio'
905
+ ? RadioGroupField
906
+ : CustomField
907
+ }
908
+ selectOptions={
909
+ element.name === 'country'
910
+ ? countries
911
+ : element.name === 'state'
912
+ ? states
913
+ : []
914
+ }
915
+ radios={element.radios}
916
+ theme={theme}
917
+ disableDropdown={
918
+ element.disableDropdown
919
+ }
920
+ defaultCountry={
921
+ defaultCountry ||
922
+ element.defaultCountry
923
+ }
924
+ dateFormat={element.format}
925
+ datePlaceholder={
926
+ element.placeholder
927
+ }
928
+ />
929
+ )}
930
+ </div>
931
+ </React.Fragment>
932
+ )
933
+ )}
934
+ </div>
935
+ </React.Fragment>
936
+ )
937
+ })}
938
+ </React.Fragment>
939
+ )
940
+ })}
941
+ {!_isEmpty(ticketHoldersFields.fields) && (
942
+ <div className="ticket-holders-fields">
943
+ <h2>{ticketHoldersFields.label}</h2>
944
+ {_map(ticketsQuantity, (_item, index) => (
945
+ <div key={_item}>
946
+ <h5>Ticket {index + 1}</h5>
947
+ {_map(ticketHoldersFields.fields, group => {
948
+ const { groupClassname, groupItems } = group
949
+ return (
950
+ <div key={group.id}>
951
+ <div className={groupClassname}>
952
+ {_map(groupItems, element => {
953
+ if (
954
+ _includes(
955
+ ['holderFirstName', 'holderLastName'],
956
+ element.name
957
+ )
958
+ ) {
959
+ element.required = showTicketHolders
960
+ }
961
+ return (
831
962
  <div
832
- className={`${element.className} ${
833
- props?.errors[element.name]
834
- }`}
963
+ className={element.className}
964
+ key={element.name}
835
965
  >
836
- {element.component ? (
837
- element.component
838
- ) : (
839
- <Field
840
- setPhoneValidationIsLoading={
841
- element.type === 'phone'
842
- ? setPhoneValidationIsLoading
843
- : undefined
844
- }
845
- name={element.name}
846
- label={
847
- element.name === 'phone'
848
- ? `${element.label}${
849
- flagRequirePhone
850
- ? ''
851
- : ' (optional)'
852
- } `
853
- : element.name ===
854
- 'data_capture[wallet_address]'
855
- ? `${element.label}${
856
- !collectMandatoryWalletAddress
857
- ? ' (optional)'
858
- : ''
859
- } `
860
- : element.label
861
- }
862
- type={element.type}
863
- fill={element.fill}
864
- validate={getValidateFunctions(
865
- element,
866
- states,
867
- props.values,
868
- props.errors
869
- )}
870
- setFieldValue={props.setFieldValue}
871
- onBlur={props.handleBlur}
872
- component={
873
- element.type === 'checkbox'
874
- ? CheckboxField
875
- : element.type === 'select'
876
- ? SelectField
877
- : element.type === 'phone'
878
- ? PhoneNumberField
879
- : element.type === 'date'
880
- ? DatePickerField
881
- : CustomField
882
- }
883
- selectOptions={
884
- element.name === 'country'
885
- ? countries
886
- : element.name === 'state'
887
- ? states
888
- : []
889
- }
890
- theme={theme}
891
- disableDropdown={
892
- element.disableDropdown
893
- }
894
- defaultCountry={
895
- element.defaultCountry
896
- }
897
- dateFormat={
898
- element.format
899
- }
900
- datePlaceholder={
901
- element.placeholder
902
- }
903
- />
904
- )}
966
+ <Field
967
+ name={`${element.name}-${index}`}
968
+ label={`${element.label}${
969
+ element.required
970
+ ? ''
971
+ : ' (optional)'
972
+ }`}
973
+ type={element.type}
974
+ component={
975
+ element.type === 'checkbox'
976
+ ? CheckboxField
977
+ : element.type === 'phone'
978
+ ? PhoneNumberField
979
+ : CustomField
980
+ }
981
+ validate={combineValidators(
982
+ element.required
983
+ ? requiredValidator
984
+ : () =>
985
+ props.errors[
986
+ `${element.name}-${index}`
987
+ ],
988
+ element.onValidate
989
+ ? element.onValidate
990
+ : () =>
991
+ props.errors[
992
+ `${element.name}-${index}`
993
+ ]
994
+ )}
995
+ disableDropdown={
996
+ element.disableDropdown
997
+ }
998
+ setPhoneValidationIsLoading={
999
+ setPhoneValidationIsLoading
1000
+ }
1001
+ defaultCountry={
1002
+ defaultCountry ||
1003
+ element.defaultCountry
1004
+ }
1005
+ />
905
1006
  </div>
906
- </React.Fragment>
907
- )
908
- )}
909
- </div>
910
- </React.Fragment>
911
- )
912
- })}
913
- </React.Fragment>
914
- )
915
- })}
916
- {!_isEmpty(ticketHoldersFields.fields) && (
917
- <div className="ticket-holders-fields">
918
- <h2>{ticketHoldersFields.label}</h2>
919
- {_map(ticketsQuantity, (_item, index) => (
920
- <div key={_item}>
921
- <h5>Ticket {index + 1}</h5>
922
- {_map(ticketHoldersFields.fields, group => {
923
- const { groupClassname, groupItems } = group
924
- return (
925
- <div key={group.id}>
926
- <div className={groupClassname}>
927
- {_map(groupItems, element => {
928
- if (
929
- _includes(
930
- ['holderFirstName', 'holderLastName'],
931
- element.name
932
1007
  )
933
- ) {
934
- element.required = showTicketHolders
935
- }
936
- return (
937
- <div
938
- className={element.className}
939
- key={element.name}
940
- >
941
- <Field
942
- name={`${element.name}-${index}`}
943
- label={`${element.label}${
944
- element.required ? '' : ' (optional)'
945
- }`}
946
- type={element.type}
947
- component={
948
- element.type === 'checkbox'
949
- ? CheckboxField
950
- : element.type === 'phone'
951
- ? PhoneNumberField
952
- : CustomField
953
- }
954
- validate={combineValidators(
955
- element.required
956
- ? requiredValidator
957
- : () =>
958
- props.errors[
959
- `${element.name}-${index}`
960
- ],
961
- element.onValidate
962
- ? element.onValidate
963
- : () =>
964
- props.errors[
965
- `${element.name}-${index}`
966
- ]
967
- )}
968
- disableDropdown={
969
- element.disableDropdown
970
- }
971
- setPhoneValidationIsLoading={
972
- setPhoneValidationIsLoading
973
- }
974
- defaultCountry={element.defaultCountry}
975
- />
976
- </div>
977
- )
978
- })}
1008
+ })}
1009
+ </div>
979
1010
  </div>
980
- </div>
981
- )
982
- })}
983
- </div>
984
- ))}
1011
+ )
1012
+ })}
1013
+ </div>
1014
+ ))}
1015
+ </div>
1016
+ )}
1017
+ <div className="button-container">
1018
+ <Button
1019
+ type="submit"
1020
+ variant="contained"
1021
+ className="login-register-button"
1022
+ disabled={props.isSubmitting || phoneValidationIsLoading}
1023
+ >
1024
+ {props.isSubmitting ? (
1025
+ <CircularProgress size={26} />
1026
+ ) : (
1027
+ buttonName
1028
+ )}
1029
+ </Button>
985
1030
  </div>
986
- )}
987
- <div className="button-container">
988
- <Button
989
- type="submit"
990
- variant="contained"
991
- className="login-register-button"
992
- disabled={props.isSubmitting || phoneValidationIsLoading}
993
- >
994
- {props.isSubmitting ? (
995
- <CircularProgress size={26} />
996
- ) : (
997
- buttonName
998
- )}
999
- </Button>
1000
1031
  </div>
1001
- </div>
1002
- </Form>
1003
- )}
1004
- </Formik>
1032
+ </Form>
1033
+ )}
1034
+ </Formik>
1035
+ )}
1005
1036
  {showModalLogin && (
1006
1037
  <LoginModal
1007
1038
  logo={logo}