tf-checkout-react 1.0.100 → 1.0.104

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 (84) hide show
  1. package/dist/components/billing-info-container/index.d.ts +3 -1
  2. package/dist/components/common/RedirectModal.d.ts +7 -0
  3. package/dist/components/common/SnackbarAlert.d.ts +13 -0
  4. package/dist/components/confirmationContainer/index.d.ts +2 -1
  5. package/dist/components/ticketsContainer/index.d.ts +2 -1
  6. package/dist/env.d.ts +1 -0
  7. package/dist/images/done.svg +3 -3
  8. package/dist/index.d.ts +1 -0
  9. package/dist/tf-checkout-react.cjs.development.js +317 -136
  10. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  11. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  12. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  13. package/dist/tf-checkout-react.esm.js +318 -138
  14. package/dist/tf-checkout-react.esm.js.map +1 -1
  15. package/dist/tf-checkout-styles.css +1 -1
  16. package/package.json +89 -89
  17. package/src/.DS_Store +0 -0
  18. package/src/.d.ts +2 -2
  19. package/src/api/index.ts +293 -278
  20. package/src/assets/images/done.svg +3 -3
  21. package/src/components/.DS_Store +0 -0
  22. package/src/components/billing-info-container/index.tsx +796 -777
  23. package/src/components/billing-info-container/style.css +105 -105
  24. package/src/components/billing-info-container/utils.ts +224 -224
  25. package/src/components/common/CheckboxField.tsx +41 -41
  26. package/src/components/common/CustomField.tsx +84 -84
  27. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  28. package/src/components/common/Loader.tsx +9 -9
  29. package/src/components/common/RadioField.tsx +35 -35
  30. package/src/components/common/RedirectModal.tsx +43 -0
  31. package/src/components/common/SelectField.tsx +80 -80
  32. package/src/components/common/SnackbarAlert.tsx +54 -0
  33. package/src/components/common/index.tsx +4 -4
  34. package/src/components/confirmModal/index.tsx +51 -51
  35. package/src/components/confirmModal/style.css +21 -21
  36. package/src/components/confirmationContainer/config.ts +72 -72
  37. package/src/components/confirmationContainer/index.tsx +197 -194
  38. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  39. package/src/components/confirmationContainer/style.css +202 -202
  40. package/src/components/countdown/index.tsx +89 -89
  41. package/src/components/countdown/style.css +9 -9
  42. package/src/components/index.ts +7 -7
  43. package/src/components/loginModal/index.tsx +209 -209
  44. package/src/components/loginModal/style.css +71 -71
  45. package/src/components/myTicketsContainer/index.tsx +196 -137
  46. package/src/components/myTicketsContainer/row.tsx +41 -41
  47. package/src/components/myTicketsContainer/style.css +39 -39
  48. package/src/components/myTicketsContainer/tableConfig.tsx +34 -34
  49. package/src/components/orderDetailsContainer/index.tsx +249 -249
  50. package/src/components/orderDetailsContainer/style.css +72 -72
  51. package/src/components/orderDetailsContainer/ticketsTable.tsx +124 -124
  52. package/src/components/paymentContainer/index.tsx +284 -284
  53. package/src/components/registerModal/index.tsx +190 -190
  54. package/src/components/stripePayment/index.tsx +253 -253
  55. package/src/components/stripePayment/style.css +59 -59
  56. package/src/components/ticketResale/index.tsx +56 -56
  57. package/src/components/ticketResaleModal/index.tsx +210 -210
  58. package/src/components/ticketResaleModal/style.css +28 -28
  59. package/src/components/ticketsContainer/PromoCodeSection.tsx +99 -99
  60. package/src/components/ticketsContainer/ReferralLogic.tsx +33 -33
  61. package/src/components/ticketsContainer/TicketRow.tsx +83 -83
  62. package/src/components/ticketsContainer/TicketsSection.tsx +81 -81
  63. package/src/components/ticketsContainer/index.tsx +427 -409
  64. package/src/components/ticketsContainer/style.css +181 -181
  65. package/src/components/ticketsContainer/utils.ts +11 -11
  66. package/src/components/timerWidget/index.tsx +70 -70
  67. package/src/components/timerWidget/style.css +26 -26
  68. package/src/components/waitingList/index.tsx +178 -178
  69. package/src/components/waitingList/style.css +26 -26
  70. package/src/env.ts +20 -19
  71. package/src/index.ts +14 -13
  72. package/src/normalizers/index.ts +45 -45
  73. package/src/types/billing-info-data.ts +37 -37
  74. package/src/types/payment-field.ts +7 -7
  75. package/src/types/referral-promotion.ts +7 -7
  76. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +59 -59
  77. package/src/utils/downloadPDF.tsx +30 -30
  78. package/src/utils/formikErrorFocus.ts +24 -24
  79. package/src/utils/getImage.ts +14 -14
  80. package/src/utils/getQueryVariable.ts +13 -13
  81. package/src/utils/index.ts +5 -5
  82. package/src/utils/setConfigs.ts +26 -26
  83. package/src/utils/showZero.tsx +10 -10
  84. package/src/validators/index.ts +20 -20
@@ -1,194 +1,197 @@
1
- /* eslint-disable react/no-unescaped-entities */
2
- import React, { useEffect, useRef, useState } from 'react'
3
- import './style.css'
4
- import _map from 'lodash/map'
5
- import _get from 'lodash/get'
6
- import { IReferralPromotion } from '../../types'
7
- import { getConfirmationData } from '../../api'
8
- import { AxiosError } from 'axios'
9
- import SocialButtons from './social-buttons'
10
-
11
- export interface IShareButton {
12
- mainLabel: string;
13
- subLabel: string;
14
- platform: string;
15
- shareData: any;
16
- }
17
-
18
- export interface IConfirmationPage {
19
- isReferralEnabled: boolean;
20
- showDefaultShareButtons: boolean;
21
- messengerAppId: string;
22
- shareButtons: IShareButton[];
23
- onGetConfirmationDataSuccess: (res: any) => void;
24
- onGetConfirmationDataError: (e: AxiosError) => void;
25
- orderHash?: string;
26
- }
27
-
28
- export const ConfirmationContainer = ({
29
- isReferralEnabled,
30
- showDefaultShareButtons,
31
- messengerAppId = '',
32
- shareButtons = [],
33
- onGetConfirmationDataSuccess = () => {},
34
- onGetConfirmationDataError = () => {},
35
- orderHash,
36
- }: IConfirmationPage) => {
37
- const inputRef = useRef(null)
38
- const [data, setData] = useState<any>(null)
39
-
40
- // 1. get payment complete data ---> v1/order/${orderHash}/payment/complete/
41
-
42
- useEffect(() => {
43
- (async () => {
44
- const dataEncoded =
45
- (typeof window !== 'undefined' &&
46
- window.localStorage.getItem('checkoutData')) ||
47
- ''
48
-
49
- const dataDecoded = dataEncoded
50
- ? JSON.parse(dataEncoded)
51
- : { hash: orderHash }
52
- const { hash } = dataDecoded
53
-
54
- if (hash) {
55
- try {
56
- const response = await getConfirmationData(hash)
57
- const data = _get(response, 'data.data.attributes')
58
- data.personal_share_sales = data.personal_share_sales.map(
59
- (d: any) => {
60
- const salesData: IReferralPromotion = {
61
- label: `If your friends buy ${d.sales} tickets`,
62
- price: '',
63
- }
64
- if (d.price === 0) {
65
- salesData.subLabel = 'Your ticket becomes'
66
- salesData.price = 'FREE!'
67
- } else {
68
- salesData.subLabel = 'Your ticket goes down to'
69
- salesData.price = data.currency.symbol + d.price?.toFixed(2)
70
- }
71
-
72
- return salesData
73
- }
74
- )
75
- data.personal_share_sales.unshift({
76
- label: 'Your ticket is currently',
77
- price: data.currency.symbol + data.product_price?.toFixed(2),
78
- })
79
- setData(data)
80
- onGetConfirmationDataSuccess(response.data)
81
- } catch (error) {
82
- onGetConfirmationDataError(error.response)
83
- }
84
- }
85
- })()
86
- }, [])
87
-
88
- const onChangeShareLink = (e: React.ChangeEvent<HTMLInputElement>) => {
89
- const newData = { ...data, personal_share_link: e.target.value }
90
- setData(newData)
91
- }
92
-
93
- return (
94
- <div className="confirmation-page">
95
- {data && (
96
- <>
97
- <p className="title">Your Tickets are Confirmed!</p>
98
- <div className="share-message-section">
99
- <span className="main">Your tickets have been emailed to you</span>
100
- <span className="helper">
101
- Please bring them with you to the event
102
- </span>
103
- </div>
104
- {data.disable_referral === false && isReferralEnabled && (
105
- <>
106
- <div className="referral_text_image_section">
107
- <div className="referral_text_section">
108
- <div className="referral_title_text">
109
- Your ticket can become
110
- <span className="strong-text"> cheaper </span>
111
- or even
112
- <span className="strong-text"> FREE!</span>
113
- </div>
114
- <div className="referral_text">
115
- <span className="strong-text"> Invite friends </span>
116
- and we'll refund up to
117
- <span className="strong-text"> 100% </span>
118
- of your ticket money, if they buy tickets as well!
119
- </div>
120
- </div>
121
- <img src={data.product_image} alt="No Data" />
122
- </div>
123
- <div className="share_wrapper">
124
- <div className="share_section">
125
- <div className="invitation_section">
126
- <div className="invitation_title">
127
- How do you invite your friends?
128
- </div>
129
- <div className="share_buttons">
130
- <div className="share-by-link">
131
- <h5 className="share-by-link label">
132
- Send them this link:
133
- </h5>
134
- <div className="share-btn-inner">
135
- <input
136
- ref={inputRef}
137
- className="share-input"
138
- value={data.personal_share_link}
139
- onChange={onChangeShareLink}
140
- />
141
- <div
142
- className="share-by-link-copy-icon"
143
- onClick={() =>
144
- navigator.clipboard.writeText(
145
- _get(inputRef, 'current.value')
146
- )
147
- }
148
- >
149
- <img
150
- src="https://img.icons8.com/office/50/000000/copy.png"
151
- alt="copy"
152
- />
153
- </div>
154
- </div>
155
- </div>
156
- {(showDefaultShareButtons || !!shareButtons.length) && (
157
- <SocialButtons
158
- showDefaultShareButtons={showDefaultShareButtons}
159
- name={data.product_name}
160
- appId={messengerAppId}
161
- shareLink={data.personal_share_link}
162
- shareButtons={shareButtons}
163
- />
164
- )}
165
- </div>
166
- </div>
167
- </div>
168
- <div className="pricing-section">
169
- <div className="invitation_title">How much cheaper?</div>
170
- {_map(data.personal_share_sales, (pricing, index) => (
171
- <div key={index} className="pricing-section_wrapper">
172
- <div className="pricing-section_label">
173
- {pricing.label}
174
- {pricing.subLabel && (
175
- <div className="pricing-section_sublabel">
176
- {pricing.subLabel}
177
- </div>
178
- )}
179
- </div>
180
- <div className="pricing-section_price">
181
- {' '}
182
- {pricing.price}
183
- </div>
184
- </div>
185
- ))}
186
- </div>
187
- </div>
188
- </>
189
- )}
190
- </>
191
- )}
192
- </div>
193
- )
194
- }
1
+ /* eslint-disable react/no-unescaped-entities */
2
+ import React, { useEffect, useRef, useState } from 'react'
3
+ import './style.css'
4
+ import _map from 'lodash/map'
5
+ import _get from 'lodash/get'
6
+ import { IReferralPromotion } from '../../types'
7
+ import { getConfirmationData } from '../../api'
8
+ import { AxiosError } from 'axios'
9
+ import SocialButtons from './social-buttons'
10
+
11
+ export interface IShareButton {
12
+ mainLabel: string;
13
+ subLabel: string;
14
+ platform: string;
15
+ shareData: any;
16
+ }
17
+
18
+ export interface IConfirmationPage {
19
+ isReferralEnabled: boolean;
20
+ showDefaultShareButtons: boolean;
21
+ messengerAppId: string;
22
+ shareButtons: IShareButton[];
23
+ onGetConfirmationDataSuccess: (res: any) => void;
24
+ onGetConfirmationDataError: (e: AxiosError) => void;
25
+ onLinkCopied: () => void;
26
+ orderHash?: string;
27
+ }
28
+
29
+ export const ConfirmationContainer = ({
30
+ isReferralEnabled,
31
+ showDefaultShareButtons,
32
+ messengerAppId = '',
33
+ shareButtons = [],
34
+ onGetConfirmationDataSuccess = () => {},
35
+ onGetConfirmationDataError = () => {},
36
+ orderHash,
37
+ onLinkCopied = () => {}
38
+ }: IConfirmationPage) => {
39
+ const inputRef = useRef(null)
40
+ const [data, setData] = useState<any>(null)
41
+
42
+ // 1. get payment complete data ---> v1/order/${orderHash}/payment/complete/
43
+
44
+ useEffect(() => {
45
+ (async () => {
46
+ const dataEncoded =
47
+ (typeof window !== 'undefined' &&
48
+ window.localStorage.getItem('checkoutData')) ||
49
+ ''
50
+
51
+ const dataDecoded = dataEncoded
52
+ ? JSON.parse(dataEncoded)
53
+ : { hash: orderHash }
54
+ const { hash } = dataDecoded
55
+
56
+ if (hash) {
57
+ try {
58
+ const response = await getConfirmationData(hash)
59
+ const data = _get(response, 'data.data.attributes')
60
+ data.personal_share_sales = data.personal_share_sales.map(
61
+ (d: any) => {
62
+ const salesData: IReferralPromotion = {
63
+ label: `If your friends buy ${d.sales} tickets`,
64
+ price: '',
65
+ }
66
+ if (d.price === 0) {
67
+ salesData.subLabel = 'Your ticket becomes'
68
+ salesData.price = 'FREE!'
69
+ } else {
70
+ salesData.subLabel = 'Your ticket goes down to'
71
+ salesData.price = data.currency.symbol + d.price?.toFixed(2)
72
+ }
73
+
74
+ return salesData
75
+ }
76
+ )
77
+ data.personal_share_sales.unshift({
78
+ label: 'Your ticket is currently',
79
+ price: data.currency.symbol + data.product_price?.toFixed(2),
80
+ })
81
+ setData(data)
82
+ onGetConfirmationDataSuccess(response.data)
83
+ } catch (error) {
84
+ onGetConfirmationDataError(error.response)
85
+ }
86
+ }
87
+ })()
88
+ }, [])
89
+
90
+ const onChangeShareLink = (e: React.ChangeEvent<HTMLInputElement>) => {
91
+ const newData = { ...data, personal_share_link: e.target.value }
92
+ setData(newData)
93
+ }
94
+
95
+ return (
96
+ <div className="confirmation-page">
97
+ {data && (
98
+ <>
99
+ <p className="title">Your Tickets are Confirmed!</p>
100
+ <div className="share-message-section">
101
+ <span className="main">Your tickets have been emailed to you</span>
102
+ <span className="helper">
103
+ Please bring them with you to the event
104
+ </span>
105
+ </div>
106
+ {data.disable_referral === false && isReferralEnabled && (
107
+ <>
108
+ <div className="referral_text_image_section">
109
+ <div className="referral_text_section">
110
+ <div className="referral_title_text">
111
+ Your ticket can become
112
+ <span className="strong-text"> cheaper </span>
113
+ or even
114
+ <span className="strong-text"> FREE!</span>
115
+ </div>
116
+ <div className="referral_text">
117
+ <span className="strong-text"> Invite friends </span>
118
+ and we'll refund up to
119
+ <span className="strong-text"> 100% </span>
120
+ of your ticket money, if they buy tickets as well!
121
+ </div>
122
+ </div>
123
+ <img src={data.product_image} alt="No Data" />
124
+ </div>
125
+ <div className="share_wrapper">
126
+ <div className="share_section">
127
+ <div className="invitation_section">
128
+ <div className="invitation_title">
129
+ How do you invite your friends?
130
+ </div>
131
+ <div className="share_buttons">
132
+ <div className="share-by-link">
133
+ <h5 className="share-by-link label">
134
+ Send them this link:
135
+ </h5>
136
+ <div className="share-btn-inner">
137
+ <input
138
+ ref={inputRef}
139
+ className="share-input"
140
+ value={data.personal_share_link}
141
+ onChange={onChangeShareLink}
142
+ />
143
+ <div
144
+ className="share-by-link-copy-icon"
145
+ onClick={() => {
146
+ navigator.clipboard.writeText(
147
+ _get(inputRef, 'current.value')
148
+ )
149
+ onLinkCopied()
150
+ }}
151
+ >
152
+ <img
153
+ src="https://img.icons8.com/office/50/000000/copy.png"
154
+ alt="copy"
155
+ />
156
+ </div>
157
+ </div>
158
+ </div>
159
+ {(showDefaultShareButtons || !!shareButtons.length) && (
160
+ <SocialButtons
161
+ showDefaultShareButtons={showDefaultShareButtons}
162
+ name={data.product_name}
163
+ appId={messengerAppId}
164
+ shareLink={data.personal_share_link}
165
+ shareButtons={shareButtons}
166
+ />
167
+ )}
168
+ </div>
169
+ </div>
170
+ </div>
171
+ <div className="pricing-section">
172
+ <div className="invitation_title">How much cheaper?</div>
173
+ {_map(data.personal_share_sales, (pricing, index) => (
174
+ <div key={index} className="pricing-section_wrapper">
175
+ <div className="pricing-section_label">
176
+ {pricing.label}
177
+ {pricing.subLabel && (
178
+ <div className="pricing-section_sublabel">
179
+ {pricing.subLabel}
180
+ </div>
181
+ )}
182
+ </div>
183
+ <div className="pricing-section_price">
184
+ {' '}
185
+ {pricing.price}
186
+ </div>
187
+ </div>
188
+ ))}
189
+ </div>
190
+ </div>
191
+ </>
192
+ )}
193
+ </>
194
+ )}
195
+ </div>
196
+ )
197
+ }
@@ -1,94 +1,94 @@
1
- import React from 'react';
2
- import { IShareButton } from'./index'
3
- import config from './config'
4
-
5
- const SocialComponent = ({ mainLabel, subLabel, platform, shareData }: IShareButton) => {
6
- const Component = config(platform)?.component
7
- const Icon = config(platform)?.icon
8
-
9
- return (
10
- <>
11
- {Component && (
12
- <Component {...shareData}>
13
- <div className='social-media-sharing'>
14
- <div className='share-icon'>
15
- <Icon size={32} round />
16
- </div>
17
- <span className="share-text">
18
- {mainLabel}
19
- <br /> {subLabel}
20
- </span>
21
- </div>
22
- </Component>
23
- )}
24
- </>
25
- )
26
- }
27
-
28
- interface SocialButtonsTypes {
29
- shareLink: string;
30
- name: string;
31
- appId: string;
32
- showDefaultShareButtons: boolean;
33
- shareButtons: IShareButton[]
34
- }
35
-
36
- const SocialButtons = ({ showDefaultShareButtons, shareLink, name, appId, shareButtons }: SocialButtonsTypes) => {
37
- return (
38
- <>
39
- <div className="convenient_buttons">
40
- or use one of these convenient buttons:
41
- </div>
42
- <div className="social-media-btns">
43
- {showDefaultShareButtons && (
44
- <>
45
- <SocialComponent
46
- mainLabel='Share on'
47
- subLabel='Facebook'
48
- platform='facebook'
49
- shareData={{
50
- quote: name,
51
- url: shareLink
52
- }}
53
- />
54
- <SocialComponent
55
- mainLabel='Tweet to your'
56
- subLabel='Followers'
57
- platform='twitter'
58
- shareData={{
59
- title: name,
60
- url: shareLink
61
- }}
62
- />
63
- <SocialComponent
64
- mainLabel='Message friends on'
65
- subLabel='Facebook'
66
- platform='messenger'
67
- shareData={{
68
- appId: appId,
69
- url: shareLink
70
- }}
71
- />
72
- <SocialComponent
73
- mainLabel='Message friends on'
74
- subLabel='Whatsapp'
75
- platform='whatsapp'
76
- shareData={{
77
- title: name,
78
- url: shareLink
79
- }}
80
- />
81
- </>
82
- )}
83
- {shareButtons.map((shareButton: IShareButton, index: number) => (
84
- <SocialComponent key={index} {...shareButton} />
85
- ))}
86
- </div>
87
- {(showDefaultShareButtons || shareButtons.length) && (
88
- <p>We <strong>never</strong> post on Facebook without your permission!</p>
89
- )}
90
- </>
91
- )
92
- }
93
-
94
- export default SocialButtons
1
+ import React from 'react';
2
+ import { IShareButton } from'./index'
3
+ import config from './config'
4
+
5
+ const SocialComponent = ({ mainLabel, subLabel, platform, shareData }: IShareButton) => {
6
+ const Component = config(platform)?.component
7
+ const Icon = config(platform)?.icon
8
+
9
+ return (
10
+ <>
11
+ {Component && (
12
+ <Component {...shareData}>
13
+ <div className='social-media-sharing'>
14
+ <div className='share-icon'>
15
+ <Icon size={32} round />
16
+ </div>
17
+ <span className="share-text">
18
+ {mainLabel}
19
+ <br /> {subLabel}
20
+ </span>
21
+ </div>
22
+ </Component>
23
+ )}
24
+ </>
25
+ )
26
+ }
27
+
28
+ interface SocialButtonsTypes {
29
+ shareLink: string;
30
+ name: string;
31
+ appId: string;
32
+ showDefaultShareButtons: boolean;
33
+ shareButtons: IShareButton[]
34
+ }
35
+
36
+ const SocialButtons = ({ showDefaultShareButtons, shareLink, name, appId, shareButtons }: SocialButtonsTypes) => {
37
+ return (
38
+ <>
39
+ <div className="convenient_buttons">
40
+ or use one of these convenient buttons:
41
+ </div>
42
+ <div className="social-media-btns">
43
+ {showDefaultShareButtons && (
44
+ <>
45
+ <SocialComponent
46
+ mainLabel='Share on'
47
+ subLabel='Facebook'
48
+ platform='facebook'
49
+ shareData={{
50
+ quote: name,
51
+ url: shareLink
52
+ }}
53
+ />
54
+ <SocialComponent
55
+ mainLabel='Tweet to your'
56
+ subLabel='Followers'
57
+ platform='twitter'
58
+ shareData={{
59
+ title: name,
60
+ url: shareLink
61
+ }}
62
+ />
63
+ <SocialComponent
64
+ mainLabel='Message friends on'
65
+ subLabel='Facebook'
66
+ platform='messenger'
67
+ shareData={{
68
+ appId: appId,
69
+ url: shareLink
70
+ }}
71
+ />
72
+ <SocialComponent
73
+ mainLabel='Message friends on'
74
+ subLabel='Whatsapp'
75
+ platform='whatsapp'
76
+ shareData={{
77
+ title: name,
78
+ url: shareLink
79
+ }}
80
+ />
81
+ </>
82
+ )}
83
+ {shareButtons.map((shareButton: IShareButton, index: number) => (
84
+ <SocialComponent key={index} {...shareButton} />
85
+ ))}
86
+ </div>
87
+ {(showDefaultShareButtons || shareButtons.length) && (
88
+ <p>We <strong>never</strong> post on Facebook without your permission!</p>
89
+ )}
90
+ </>
91
+ )
92
+ }
93
+
94
+ export default SocialButtons