tf-checkout-react 1.4.26 → 1.5.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 (79) hide show
  1. package/dist/api/index.d.ts +1 -0
  2. package/dist/api/preRegistrationComplete.d.ts +3 -0
  3. package/dist/components/billing-info-container/index.d.ts +1 -3
  4. package/dist/components/common/CopyField.d.ts +12 -0
  5. package/dist/components/common/CopyMessageModal.d.ts +7 -0
  6. package/dist/components/common/index.d.ts +1 -0
  7. package/dist/components/common/socials.d.ts +10 -0
  8. package/dist/components/confirmationContainer/index.d.ts +7 -7
  9. package/dist/components/confirmationContainer/social-buttons.d.ts +5 -2
  10. package/dist/components/forgotPasswordModal/index.d.ts +2 -3
  11. package/dist/components/loginForm/index.d.ts +1 -0
  12. package/dist/components/loginModal/index.d.ts +2 -3
  13. package/dist/components/preRegistration/FieldsSection.d.ts +13 -0
  14. package/dist/components/preRegistration/Influancers.d.ts +2 -0
  15. package/dist/components/preRegistration/PreRegistrationComplete.d.ts +5 -0
  16. package/dist/components/preRegistration/PreRegistrationInformations.d.ts +2 -0
  17. package/dist/components/preRegistration/Prewards.d.ts +2 -0
  18. package/dist/components/preRegistration/ShareOptions.d.ts +2 -0
  19. package/dist/components/preRegistration/constants.d.ts +2 -0
  20. package/dist/components/preRegistration/index.d.ts +17 -0
  21. package/dist/components/preRegistration/utils.d.ts +12 -0
  22. package/dist/components/ticketsContainer/TicketRow.d.ts +3 -2
  23. package/dist/components/ticketsContainer/utils.d.ts +9 -0
  24. package/dist/hooks/index.d.ts +1 -0
  25. package/dist/hooks/useEventListener.d.ts +1 -0
  26. package/dist/hooks/useLocalStorageListener.d.ts +1 -0
  27. package/dist/images/instagram.svg +5 -0
  28. package/dist/images/spotify.svg +6 -0
  29. package/dist/index.d.ts +4 -1
  30. package/dist/tf-checkout-react.cjs.development.js +1525 -173
  31. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  32. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  33. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  34. package/dist/tf-checkout-react.esm.js +1526 -173
  35. package/dist/tf-checkout-react.esm.js.map +1 -1
  36. package/dist/utils/isValidNumber.d.ts +1 -0
  37. package/package.json +1 -1
  38. package/src/api/index.ts +28 -0
  39. package/src/api/orders.ts +3 -3
  40. package/src/api/preRegistrationComplete.ts +37 -0
  41. package/src/assets/images/instagram.svg +5 -0
  42. package/src/assets/images/spotify.svg +6 -0
  43. package/src/components/billing-info-container/index.tsx +1 -7
  44. package/src/components/common/CopyField.tsx +53 -0
  45. package/src/components/common/CopyMessageModal.tsx +34 -0
  46. package/src/components/common/NativeSelectFeild/index.tsx +1 -1
  47. package/src/components/common/index.tsx +1 -0
  48. package/src/components/common/socials.tsx +33 -0
  49. package/src/components/confirmationContainer/config.ts +62 -55
  50. package/src/components/confirmationContainer/index.tsx +11 -31
  51. package/src/components/confirmationContainer/social-buttons.tsx +43 -20
  52. package/src/components/forgotPasswordModal/index.tsx +4 -4
  53. package/src/components/loginForm/index.tsx +4 -0
  54. package/src/components/loginModal/index.tsx +5 -4
  55. package/src/components/myTicketsContainer/index.tsx +2 -2
  56. package/src/components/preRegistration/FieldsSection.tsx +142 -0
  57. package/src/components/preRegistration/Influancers.tsx +34 -0
  58. package/src/components/preRegistration/PreRegistrationComplete.tsx +164 -0
  59. package/src/components/preRegistration/PreRegistrationInformations.tsx +54 -0
  60. package/src/components/preRegistration/Prewards.tsx +41 -0
  61. package/src/components/preRegistration/ShareOptions.tsx +77 -0
  62. package/src/components/preRegistration/constants.tsx +161 -0
  63. package/src/components/preRegistration/index.tsx +274 -0
  64. package/src/components/preRegistration/utils.ts +155 -0
  65. package/src/components/ticketsContainer/ReferralLogic.tsx +1 -1
  66. package/src/components/ticketsContainer/TicketRow.tsx +17 -14
  67. package/src/components/ticketsContainer/TicketsSection.tsx +2 -0
  68. package/src/components/ticketsContainer/index.tsx +77 -8
  69. package/src/components/ticketsContainer/utils.ts +30 -6
  70. package/src/hooks/index.ts +1 -0
  71. package/src/hooks/useEventListener.ts +32 -0
  72. package/src/hooks/useLocalStorageListener.ts +27 -0
  73. package/src/index.ts +6 -2
  74. package/src/types/api/preRegistration.d.ts +11 -0
  75. package/src/types/api/preRegistrationComplete.d.ts +95 -0
  76. package/src/types/pre-registration-complete.d.ts +42 -0
  77. package/src/utils/cookies.ts +7 -7
  78. package/src/utils/isValidNumber.ts +8 -0
  79. package/src/components/common/dist/PhoneNumberField.js +0 -96
@@ -7,6 +7,7 @@ import React, { FC, useState } from 'react'
7
7
  import { authorize, getProfileData } from '../../api'
8
8
  import { combineValidators, emailValidator, requiredValidator } from '../../validators'
9
9
  import { CustomField } from '../common'
10
+ import { PoweredBy } from '../common/PoweredBy'
10
11
 
11
12
  export interface ILoginFormProps {
12
13
  alreadyHasUser?: boolean;
@@ -24,6 +25,7 @@ export interface ILoginFormProps {
24
25
  logo?: string;
25
26
  showForgotPasswordButton?: boolean;
26
27
  showSignUpButton?: boolean;
28
+ showPoweredByImage?: boolean;
27
29
  }
28
30
 
29
31
  // interface IUserData {
@@ -72,6 +74,7 @@ export const LoginForm: FC<ILoginFormProps> = ({
72
74
  logo,
73
75
  showForgotPasswordButton = false,
74
76
  showSignUpButton = false,
77
+ showPoweredByImage = false,
75
78
  }) => {
76
79
  const [error, setError] = useState('')
77
80
  return (
@@ -173,6 +176,7 @@ export const LoginForm: FC<ILoginFormProps> = ({
173
176
  </span>
174
177
  </div>
175
178
  )}
179
+ {showPoweredByImage ? <PoweredBy /> : null}
176
180
  </div>
177
181
  </Form>
178
182
  )}
@@ -5,6 +5,7 @@ import Box from '@mui/material/Box'
5
5
  import Modal from '@mui/material/Modal'
6
6
  import axios, { AxiosError } from 'axios'
7
7
  import { Field, Form, Formik } from 'formik'
8
+ import _get from 'lodash/get'
8
9
  import _identity from 'lodash/identity'
9
10
  import React, { FC, useState } from 'react'
10
11
 
@@ -13,9 +14,9 @@ import { isBrowser, setLoggedUserData } from '../../utils'
13
14
  import { requiredValidator } from '../../validators'
14
15
  import { PoweredBy } from '../common/PoweredBy'
15
16
 
16
- interface Props {
17
+ export interface Props {
17
18
  onClose: () => void;
18
- onLogin: () => void;
19
+ onLogin: (res: IProfileData) => void;
19
20
  alreadyHasUser?: boolean;
20
21
  userExpired?: boolean;
21
22
  onAuthorizeSuccess?: (res: any) => void;
@@ -73,7 +74,7 @@ export const LoginModal: FC<Props> = ({
73
74
  onSubmit={async ({ email, password }) => {
74
75
  try {
75
76
  const body = { email, password }
76
- await authorize(body)
77
+ const authRes = await authorize(body)
77
78
  let profileResponse = null
78
79
  try {
79
80
  profileResponse = await getProfileData()
@@ -92,7 +93,7 @@ export const LoginModal: FC<Props> = ({
92
93
  const event = new window.CustomEvent('tf-login')
93
94
  window.document.dispatchEvent(event)
94
95
  }
95
- onLogin()
96
+ onLogin(_get(authRes, 'data.data'))
96
97
  } catch (e) {
97
98
  if (axios.isAxiosError(e)) {
98
99
  const error = e?.response?.data?.message || 'Error'
@@ -67,10 +67,10 @@ export const MyTicketsContainer = ({
67
67
  fetchData(1, limit, filter)
68
68
  }, [isLogged])
69
69
 
70
- const fetchData = async (page: number, limit: number, filter: string) => {
70
+ const fetchData = async (page: number, limit: number, eventSlug: string) => {
71
71
  try {
72
72
  setLoading(true)
73
- const response = await getOrders(page, limit, filter)
73
+ const response = await getOrders(page, limit, eventSlug)
74
74
  onGetOrdersSuccess(response)
75
75
 
76
76
  const data = _get(response, 'data.attributes')
@@ -0,0 +1,142 @@
1
+ import { Field, FormikValues } from 'formik'
2
+ import _map from 'lodash/map'
3
+ import React, { FC } from 'react'
4
+
5
+ import { replaceVarInString } from '../../utils'
6
+ import {
7
+ CheckboxField,
8
+ CustomField,
9
+ NativeSelectField,
10
+ PhoneNumberField,
11
+ } from '../common'
12
+ import { DatePickerField } from '../common/DatePickerField'
13
+ import { getValidateFunctions } from './utils'
14
+
15
+ const isDocumentDefined = typeof document !== 'undefined'
16
+
17
+ export interface IFieldsSectionProps {
18
+ formFields?: IFormFieldsSection[];
19
+ values: FormikValues;
20
+ setFieldValue: (
21
+ field: string,
22
+ value: FormikValues,
23
+ shouldValidate?: boolean | undefined
24
+ ) => void;
25
+
26
+ countries?: { [key: string]: string | number }[];
27
+ theme?: 'dark' | 'light';
28
+ containerClass?: string;
29
+ }
30
+
31
+ const SectionContainer: FC<{ className: string }> = ({
32
+ children,
33
+ className,
34
+ }) => <div className={className}>{children}</div>
35
+
36
+ const insertHTML = (elementId: string, text = '') => {
37
+ if (isDocumentDefined) {
38
+ const elem = document && document.getElementById(elementId)
39
+
40
+ if (!elem?.childNodes.length) {
41
+ elem?.insertAdjacentHTML('afterbegin', text)
42
+ }
43
+ }
44
+
45
+ return null
46
+ }
47
+
48
+ const getFieldClassNames = (id: string, existingClassNames: string) => {
49
+ if (isDocumentDefined) {
50
+ const elem = document && document.getElementById(id)
51
+
52
+ if ((elem?.parentElement?.clientWidth || 0) < 375) {
53
+ return existingClassNames + ' full-width'
54
+ }
55
+ }
56
+
57
+ return existingClassNames
58
+ }
59
+
60
+ export const FieldsSection = ({
61
+ formFields = [],
62
+
63
+ countries = [],
64
+
65
+ values,
66
+ setFieldValue,
67
+ theme,
68
+ containerClass = '',
69
+ }: IFieldsSectionProps) => (
70
+ <>
71
+ {_map(formFields, (item, index) => {
72
+ const {
73
+ name,
74
+ groupLabel,
75
+ groupLabelVars = [],
76
+ groupLabelClassName,
77
+ groupClassName = '',
78
+ fields,
79
+ } = item
80
+ return (
81
+ <SectionContainer key={name} className={groupClassName}>
82
+ <span id={`group_label_${index}`} className={groupLabelClassName}>
83
+ {typeof groupLabel === 'string'
84
+ ? insertHTML(
85
+ `group_label_${index}`,
86
+ replaceVarInString(groupLabel, groupLabelVars)
87
+ )
88
+ : groupLabel}
89
+ </span>
90
+ <div className={`fields-container ${groupClassName}`}>
91
+ {_map(fields, (fieldData, fieldIndex) => {
92
+ const {
93
+ name,
94
+ label,
95
+ className = 'full-width',
96
+ type,
97
+ component,
98
+ options = [],
99
+ } = fieldData
100
+ const id = `${name}-${fieldIndex}`
101
+ const classNames = `${containerClass}-container__field ${className}`
102
+
103
+ return (
104
+ component || (
105
+ <div
106
+ key={name}
107
+ id={id}
108
+ className={getFieldClassNames(id, classNames)}
109
+ >
110
+ <Field
111
+ name={name}
112
+ label={label}
113
+ type={type}
114
+ validate={getValidateFunctions({
115
+ element: fieldData,
116
+ values,
117
+ })}
118
+ setFieldValue={setFieldValue}
119
+ component={
120
+ type === 'checkbox'
121
+ ? CheckboxField
122
+ : type === 'select'
123
+ ? NativeSelectField
124
+ : type === 'phone'
125
+ ? PhoneNumberField
126
+ : type === 'date'
127
+ ? DatePickerField
128
+ : CustomField
129
+ }
130
+ selectOptions={name === 'country' ? countries : options}
131
+ theme={theme}
132
+ />
133
+ </div>
134
+ )
135
+ )
136
+ })}
137
+ </div>
138
+ </SectionContainer>
139
+ )
140
+ })}
141
+ </>
142
+ )
@@ -0,0 +1,34 @@
1
+ import _isEmpty from 'lodash/isEmpty'
2
+ import _map from 'lodash/map'
3
+ import React from 'react'
4
+
5
+ export const Influancers = (props: IInfluancersProps) => {
6
+ const {
7
+ data,
8
+ classNamePrefix,
9
+ headerNode = (
10
+ <>
11
+ TOP
12
+ <span>&nbsp;INFLUANCERS</span>
13
+ </>
14
+ ),
15
+ } = props
16
+ return (
17
+ <div className={`${classNamePrefix}_influencers_container`}>
18
+ {!_isEmpty(data) && (
19
+ <div className={`${classNamePrefix}_influencers_header`}>{headerNode}</div>
20
+ )}
21
+ <div className={`${classNamePrefix}_influencers`}>
22
+ {_map(data, (influencer, index) => (
23
+ <div key={influencer.prereg_id} className={`${classNamePrefix}_influencer`}>
24
+ <span className={`${classNamePrefix}_influencer_index`}>{index + 1}</span>
25
+ <span className={`${classNamePrefix}_influencer_title`}>INFLUENCER</span>
26
+ <span className={`${classNamePrefix}_influencer_name`}>
27
+ {influencer.name}
28
+ </span>
29
+ </div>
30
+ ))}
31
+ </div>
32
+ </div>
33
+ )
34
+ }
@@ -0,0 +1,164 @@
1
+ import axios, { AxiosError } from 'axios'
2
+ import _get from 'lodash/get'
3
+ import _identity from 'lodash/identity'
4
+ import _isEmpaty from 'lodash/isEmpty'
5
+ import React, { FC, useEffect, useState } from 'react'
6
+
7
+ import {
8
+ getPreRegistrationInfluancers,
9
+ getPreRegistrationShareOptions,
10
+ } from '../../api/preRegistrationComplete'
11
+ import { X_TF_ECOMMERCE } from '../../constants'
12
+ import { useCookieListener } from '../../hooks'
13
+ import { getCookieByName, getQueryVariable } from '../../utils'
14
+ import { CopyMessageModal } from '../common'
15
+ import ConfirmModal from '../confirmModal'
16
+ import { LoginModal } from '../loginModal'
17
+ import { Prewards } from './Prewards'
18
+ import { ShareOptions } from './ShareOptions'
19
+
20
+ const isWindowDefined = typeof window !== 'undefined'
21
+
22
+ export const PreRegistrationComplete: FC<
23
+ IPreRegistrationCompleteProps & {
24
+ onGetConfirmationDataError?: (error: AxiosError) => void;
25
+ }
26
+ > = ({
27
+ eventId: pEventId,
28
+ classNamePrefix = '',
29
+ onLinkCopied = _identity,
30
+ hasCopyIcon = false,
31
+ pageHeader = 'Pre-Registration Confirmation',
32
+ onGetConfirmationDataError = _identity,
33
+ onGetConfirmationDataSuccess = _identity,
34
+ pageMessage = 'Pre registration was successful!',
35
+ onLoginSuccess = _identity,
36
+ logo,
37
+ }) => {
38
+ const localStorageHash = isWindowDefined
39
+ ? localStorage.getItem('pre-registration-hash')
40
+ : ''
41
+ const queryHash = getQueryVariable('hash') || ''
42
+ queryHash &&
43
+ isWindowDefined &&
44
+ window.localStorage.setItem('pre-registration-hash', queryHash)
45
+ const hash = queryHash || localStorageHash
46
+ const [isLoggedIn, setIsLoggedIn] = useState(Boolean(getCookieByName(X_TF_ECOMMERCE)))
47
+ const [showModalLogin, setShowModalLogin] = useState(!isLoggedIn)
48
+ const [showCopyModal, setShowCopyModal] = useState(false)
49
+ const [prizes, setPrizes] = useState([] as Array<IPrizeData>)
50
+ const [shareOptions, setShareOptions] = useState({} as IShareOptionsData)
51
+ const [shareActionData, setShareActionData] = useState(
52
+ {} as ISubmitShareActionAttributes
53
+ )
54
+ const [error, setError] = useState({} as AxiosError)
55
+ useCookieListener(X_TF_ECOMMERCE, value => setIsLoggedIn(Boolean(value)))
56
+ useEffect(() => {
57
+ const fetchConfirmationData = async () => {
58
+ try {
59
+ if (hash && isLoggedIn) {
60
+ const shareOptionsData = await getPreRegistrationShareOptions({
61
+ hash,
62
+ })
63
+ const { attributes } = shareOptionsData.data
64
+ setShareOptions(shareOptionsData.data)
65
+ setShareActionData({
66
+ shareActionToken: attributes.shareActionToken,
67
+ tokenShuffleMethod: attributes.tokenShuffleMethod,
68
+ })
69
+ const eventId = _get(shareOptionsData, 'data.attributes.eventId')
70
+ if (eventId || pEventId) {
71
+ const influencersData = await getPreRegistrationInfluancers({
72
+ eventId: eventId || pEventId,
73
+ })
74
+ setPrizes(influencersData.data.attributes.prizes)
75
+ }
76
+ onGetConfirmationDataSuccess()
77
+ }
78
+ } catch (error) {
79
+ if (axios.isAxiosError(error)) {
80
+ setError(error.response?.data)
81
+ }
82
+ }
83
+ }
84
+ fetchConfirmationData()
85
+ }, [
86
+ pEventId,
87
+ hash,
88
+ onGetConfirmationDataError,
89
+ onGetConfirmationDataSuccess,
90
+ isLoggedIn,
91
+ ])
92
+
93
+ const onClose = () => {
94
+ setShowCopyModal(false)
95
+ }
96
+
97
+ const updateShareActionData = async () => {
98
+ if (hash) {
99
+ const shareOptionsData = await getPreRegistrationShareOptions({
100
+ hash,
101
+ })
102
+ setShareOptions(shareOptionsData.data)
103
+ setShareActionData({
104
+ shareActionToken: shareOptionsData.data.attributes.shareActionToken,
105
+ tokenShuffleMethod: shareOptionsData.data.attributes.tokenShuffleMethod,
106
+ })
107
+ }
108
+ }
109
+ return (
110
+ <>
111
+ {isLoggedIn && _isEmpaty(error) ? (
112
+ <div className={`${classNamePrefix}_pre_registration_complete_container`}>
113
+ <CopyMessageModal showCopyModal={showCopyModal} onClose={onClose} />
114
+ <p className={`${classNamePrefix}_pre_registration_complete_header`}>
115
+ {pageHeader}
116
+ </p>
117
+ <div className={`${classNamePrefix}_pre_registration_complete_message`}>
118
+ {pageMessage}
119
+ </div>
120
+ <div className={`${classNamePrefix}_pre_registration_complete_body`}>
121
+ {!_isEmpaty(prizes) && (
122
+ <Prewards classNamePrefix={classNamePrefix} data={prizes} />
123
+ )}
124
+
125
+ {!_isEmpaty(shareOptions) && (
126
+ <ShareOptions
127
+ classNamePrefix={classNamePrefix}
128
+ data={shareOptions}
129
+ onLinkCopied={() => {
130
+ setShowCopyModal(true)
131
+ onLinkCopied()
132
+ }}
133
+ shareActionData={shareActionData}
134
+ updateShareActionData={updateShareActionData}
135
+ hasCopyIcon={hasCopyIcon}
136
+ hash={hash}
137
+ />
138
+ )}
139
+ </div>
140
+ </div>
141
+ ) : (
142
+ showModalLogin && (
143
+ <LoginModal
144
+ logo={logo}
145
+ onClose={() => {
146
+ setShowModalLogin(false)
147
+ }}
148
+ onLogin={res => {
149
+ setShowModalLogin(false)
150
+ onLoginSuccess(res)
151
+ }}
152
+ />
153
+ )
154
+ )}
155
+ {!_isEmpaty(error) && (
156
+ <ConfirmModal
157
+ hideCancelBtn
158
+ message={error.message}
159
+ onConfirm={() => onGetConfirmationDataError(error)}
160
+ />
161
+ )}
162
+ </>
163
+ )
164
+ }
@@ -0,0 +1,54 @@
1
+ import _identity from 'lodash/identity'
2
+ import _slice from 'lodash/slice'
3
+ import React, { useEffect, useState } from 'react'
4
+
5
+ import { getPreRegistrationInfluancers } from '../../api/preRegistrationComplete'
6
+ import { Influancers } from './Influancers'
7
+ import { Prewards } from './Prewards'
8
+
9
+ export const PreRegistrationInformations = (props: IPreRegistrationInformationProps) => {
10
+ const {
11
+ classNamePrefix,
12
+ eventId,
13
+ onGetPreregistrationDataSuccess = _identity,
14
+ onGetPreregistrationDataError = _identity,
15
+ influancersHeaderNode,
16
+ prewardsHeaderNode,
17
+ } = props
18
+
19
+ const [prizes, setPrizes] = useState([] as Array<IPrizeData>)
20
+ const [influencers, setInfluencers] = useState([] as Array<IInfluancerData>)
21
+ const topInfluancers = _slice(influencers, 0, 10)
22
+ useEffect(() => {
23
+ const fetchPreregistrationData = async () => {
24
+ try {
25
+ const preregistrationData = await getPreRegistrationInfluancers({
26
+ eventId,
27
+ })
28
+ setPrizes(preregistrationData.data.attributes.prizes)
29
+ setInfluencers(preregistrationData.data.attributes.influencers)
30
+ onGetPreregistrationDataSuccess()
31
+ } catch (error) {
32
+ if (error) {
33
+ onGetPreregistrationDataError()
34
+ }
35
+ }
36
+ }
37
+ fetchPreregistrationData()
38
+ }, [eventId, onGetPreregistrationDataError, onGetPreregistrationDataSuccess])
39
+
40
+ return (
41
+ <div className={`${classNamePrefix}_pre_registration_info_container`}>
42
+ <Prewards
43
+ headerNode={prewardsHeaderNode}
44
+ data={prizes}
45
+ classNamePrefix={classNamePrefix}
46
+ />
47
+ <Influancers
48
+ headerNode={influancersHeaderNode}
49
+ data={topInfluancers}
50
+ classNamePrefix={classNamePrefix}
51
+ />
52
+ </div>
53
+ )
54
+ }
@@ -0,0 +1,41 @@
1
+ import _isEmpty from 'lodash/isEmpty'
2
+ import _map from 'lodash/map'
3
+ import React from 'react'
4
+
5
+ export const Prewards = (props: IPrewardsProps) => {
6
+ const {
7
+ data,
8
+ classNamePrefix = '',
9
+ headerNode = (
10
+ <>
11
+ PRE
12
+ <span>WARDS™</span>
13
+ </>
14
+ ),
15
+ } = props
16
+ return (
17
+ <div className={`${classNamePrefix}_prewards`}>
18
+ {!_isEmpty(data) && (
19
+ <div className={`${classNamePrefix}_prewards_heder`}>{headerNode}</div>
20
+ )}
21
+ <div className={`${classNamePrefix}_prizes`}>
22
+ {_map(data, prize => {
23
+ const { description, name, image, id } = prize
24
+ return (
25
+ <div className={`${classNamePrefix}_prize`} key={id}>
26
+ {image && <img className={`${classNamePrefix}_image`} alt="" src={image} />}
27
+ <div className={`${classNamePrefix}_info`}>
28
+ <h4 className={`${classNamePrefix}_name`}>{name}</h4>
29
+ {description && (
30
+ <article className={`${classNamePrefix}_description`}>
31
+ {description}
32
+ </article>
33
+ )}
34
+ </div>
35
+ </div>
36
+ )
37
+ })}
38
+ </div>
39
+ </div>
40
+ )
41
+ }
@@ -0,0 +1,77 @@
1
+ import _identity from 'lodash/identity'
2
+ import _isEmpty from 'lodash/isEmpty'
3
+ import _some from 'lodash/some'
4
+ import React from 'react'
5
+
6
+ import { submitShareAction } from '../../api/preRegistrationComplete'
7
+ import { CopyField } from '../common/CopyField'
8
+ import SocialButtons from '../confirmationContainer/social-buttons'
9
+ import { getShuffleMethodByName, shareOptionsAdapter } from './utils'
10
+
11
+ export const ShareOptions = (props: IShareOptionsProps) => {
12
+ const {
13
+ classNamePrefix,
14
+ data,
15
+ hasCopyIcon = true,
16
+ onLinkCopied = _identity,
17
+ headerText = 'Share with your friends here ...',
18
+ hash,
19
+ updateShareActionData,
20
+ shareActionData,
21
+ } = props
22
+
23
+ const {
24
+ attributes: { actions, shareUrl },
25
+ } = data
26
+
27
+ const shareButtons = shareOptionsAdapter(actions, shareUrl)
28
+ const isShareLinkEnabled = _some(
29
+ actions,
30
+ (item: IShareOptionsActionData) => item.action === 'shared_url'
31
+ )
32
+ const onAfterShare = async (eventActionId: string | undefined) => {
33
+ const { shareActionToken, tokenShuffleMethod } = shareActionData
34
+ const accessToken = getShuffleMethodByName(tokenShuffleMethod)(shareActionToken)
35
+ if (typeof eventActionId === 'string') {
36
+ await submitShareAction({
37
+ eventActionId,
38
+ accessToken,
39
+ hash,
40
+ })
41
+ updateShareActionData()
42
+ }
43
+ }
44
+
45
+ return (
46
+ <div className={`${classNamePrefix}_share_options`}>
47
+ {!_isEmpty(actions) && (
48
+ <>
49
+ <div className={`${classNamePrefix}_share_header`}>{headerText}</div>
50
+ <SocialButtons
51
+ shareLink={data.attributes.shareUrl}
52
+ name=""
53
+ appId=""
54
+ showDefaultShareButtons={false}
55
+ shareButtons={shareButtons}
56
+ titleText=""
57
+ footerText=""
58
+ onAfterShare={(eventActionId: string | undefined) =>
59
+ onAfterShare(eventActionId)
60
+ }
61
+ />
62
+ {isShareLinkEnabled && (
63
+ <div className={`${classNamePrefix}_share_btn_inner`}>
64
+ <CopyField
65
+ copyValue={shareUrl}
66
+ onLinkCopied={onLinkCopied}
67
+ hasCopyIcon={hasCopyIcon}
68
+ classNamePrefix={classNamePrefix}
69
+ messageText="Share your link"
70
+ />
71
+ </div>
72
+ )}
73
+ </>
74
+ )}
75
+ </div>
76
+ )
77
+ }