tf-checkout-react 1.0.99 → 1.0.100-beta.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.
Files changed (117) hide show
  1. package/README.md +278 -1
  2. package/dist/api/index.d.ts +31 -26
  3. package/dist/components/account-settings/index.d.ts +3 -0
  4. package/dist/components/billing-info-container/index.d.ts +5 -5
  5. package/dist/components/billing-info-container/utils.d.ts +1 -0
  6. package/dist/components/common/CustomField.d.ts +1 -1
  7. package/dist/components/common/DatePickerField.d.ts +14 -0
  8. package/dist/components/common/RedirectModal.d.ts +7 -0
  9. package/dist/components/common/SnackbarAlert.d.ts +13 -0
  10. package/dist/components/confirmationContainer/index.d.ts +2 -1
  11. package/dist/components/countdown/index.d.ts +4 -1
  12. package/dist/components/myTicketsContainer/tableConfig.d.ts +0 -1
  13. package/dist/components/orderDetailsContainer/index.d.ts +5 -1
  14. package/dist/components/orderDetailsContainer/ticketsTable.d.ts +4 -1
  15. package/dist/components/paymentContainer/index.d.ts +3 -1
  16. package/dist/components/rsvpContainer/index.d.ts +7 -0
  17. package/dist/components/stripePayment/index.d.ts +2 -1
  18. package/dist/components/ticketResale/index.d.ts +5 -3
  19. package/dist/components/ticketsContainer/AccessCodeSection.d.ts +7 -0
  20. package/dist/components/ticketsContainer/PromoCodeSection.d.ts +6 -9
  21. package/dist/components/ticketsContainer/TicketsSection.d.ts +5 -3
  22. package/dist/components/ticketsContainer/index.d.ts +13 -2
  23. package/dist/components/timerWidget/index.d.ts +3 -3
  24. package/dist/env.d.ts +1 -0
  25. package/dist/images/cross.svg +44 -0
  26. package/dist/images/done.svg +3 -3
  27. package/dist/index.d.ts +2 -0
  28. package/dist/tf-checkout-react.cjs.development.js +1400 -575
  29. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  30. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  31. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  32. package/dist/tf-checkout-react.esm.js +1409 -586
  33. package/dist/tf-checkout-react.esm.js.map +1 -1
  34. package/dist/tf-checkout-styles.css +1 -1
  35. package/dist/utils/cookies.d.ts +3 -0
  36. package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +6 -1
  37. package/dist/utils/downloadPDF.d.ts +1 -1
  38. package/dist/utils/getDomain.d.ts +1 -0
  39. package/dist/utils/index.d.ts +2 -0
  40. package/package.json +89 -89
  41. package/src/.DS_Store +0 -0
  42. package/src/.d.ts +2 -2
  43. package/src/api/index.ts +313 -278
  44. package/src/assets/images/cross.svg +44 -0
  45. package/src/assets/images/done.svg +3 -3
  46. package/src/components/.DS_Store +0 -0
  47. package/src/components/account-settings/index.tsx +161 -0
  48. package/src/components/account-settings/style.css +200 -0
  49. package/src/components/billing-info-container/index.tsx +821 -777
  50. package/src/components/billing-info-container/style.css +106 -106
  51. package/src/components/billing-info-container/utils.ts +233 -223
  52. package/src/components/common/CheckboxField.tsx +41 -41
  53. package/src/components/common/CustomField.tsx +87 -84
  54. package/src/components/common/DatePickerField.tsx +98 -0
  55. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  56. package/src/components/common/Loader.tsx +9 -9
  57. package/src/components/common/RadioField.tsx +35 -35
  58. package/src/components/common/RedirectModal.tsx +43 -0
  59. package/src/components/common/SelectField.tsx +80 -80
  60. package/src/components/common/SnackbarAlert.tsx +54 -0
  61. package/src/components/common/dist/PhoneNumberField.js +96 -0
  62. package/src/components/common/index.tsx +4 -4
  63. package/src/components/confirmModal/index.tsx +51 -51
  64. package/src/components/confirmModal/style.css +21 -21
  65. package/src/components/confirmationContainer/config.ts +72 -72
  66. package/src/components/confirmationContainer/index.tsx +197 -194
  67. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  68. package/src/components/confirmationContainer/style.css +202 -202
  69. package/src/components/countdown/index.tsx +100 -89
  70. package/src/components/countdown/style.css +9 -9
  71. package/src/components/index.ts +7 -7
  72. package/src/components/loginModal/index.tsx +171 -209
  73. package/src/components/loginModal/style.css +71 -71
  74. package/src/components/myTicketsContainer/index.tsx +201 -137
  75. package/src/components/myTicketsContainer/row.tsx +41 -41
  76. package/src/components/myTicketsContainer/style.css +40 -40
  77. package/src/components/myTicketsContainer/tableConfig.tsx +32 -34
  78. package/src/components/orderDetailsContainer/index.tsx +289 -249
  79. package/src/components/orderDetailsContainer/style.css +73 -73
  80. package/src/components/orderDetailsContainer/ticketsTable.tsx +177 -124
  81. package/src/components/paymentContainer/index.tsx +352 -284
  82. package/src/components/registerModal/index.tsx +183 -190
  83. package/src/components/rsvpContainer/index.tsx +126 -0
  84. package/src/components/stripePayment/index.tsx +258 -253
  85. package/src/components/stripePayment/style.css +60 -60
  86. package/src/components/ticketResale/index.tsx +74 -56
  87. package/src/components/ticketResaleModal/index.tsx +213 -210
  88. package/src/components/ticketResaleModal/style.css +28 -28
  89. package/src/components/ticketsContainer/AccessCodeSection.tsx +50 -0
  90. package/src/components/ticketsContainer/PromoCodeSection.tsx +89 -99
  91. package/src/components/ticketsContainer/ReferralLogic.tsx +31 -33
  92. package/src/components/ticketsContainer/TicketRow.tsx +89 -83
  93. package/src/components/ticketsContainer/TicketsSection.tsx +87 -81
  94. package/src/components/ticketsContainer/index.tsx +506 -409
  95. package/src/components/ticketsContainer/style.css +181 -181
  96. package/src/components/ticketsContainer/utils.ts +11 -11
  97. package/src/components/timerWidget/index.tsx +87 -70
  98. package/src/components/timerWidget/style.css +34 -26
  99. package/src/components/waitingList/index.tsx +178 -178
  100. package/src/components/waitingList/style.css +26 -26
  101. package/src/env.ts +20 -19
  102. package/src/index.ts +15 -13
  103. package/src/normalizers/index.ts +45 -45
  104. package/src/types/billing-info-data.ts +37 -37
  105. package/src/types/payment-field.ts +7 -7
  106. package/src/types/referral-promotion.ts +7 -7
  107. package/src/utils/cookies.ts +42 -0
  108. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +71 -59
  109. package/src/utils/downloadPDF.tsx +52 -30
  110. package/src/utils/formikErrorFocus.ts +24 -24
  111. package/src/utils/getDomain.ts +15 -0
  112. package/src/utils/getImage.ts +14 -14
  113. package/src/utils/getQueryVariable.ts +13 -13
  114. package/src/utils/index.ts +7 -5
  115. package/src/utils/setConfigs.ts +26 -26
  116. package/src/utils/showZero.tsx +10 -10
  117. package/src/validators/index.ts +20 -20
@@ -1,209 +1,171 @@
1
- import React, { FC, useState } from 'react'
2
- import { AxiosError } from 'axios'
3
- import {
4
- authorize,
5
- getAccessToken,
6
- getProfileData,
7
- handleSetAccessToken,
8
- } from '../../api'
9
- import _get from 'lodash/get'
10
- import { Field, Form, Formik } from 'formik'
11
- import { requiredValidator } from '../../validators'
12
- import { TextField } from '@mui/material'
13
- import Modal from '@mui/material/Modal'
14
- import Box from '@mui/material/Box'
15
- import './style.css'
16
- import { CONFIGS } from '../../utils'
17
- import axios from 'axios'
18
-
19
- interface Props {
20
- onClose: () => void;
21
- onLogin: () => void;
22
- alreadyHasUser?: boolean;
23
- userExpired?: boolean;
24
- onAuthorizeSuccess?: (res: any) => void;
25
- onAuthorizeError?: (e: AxiosError) => void;
26
- onGetProfileDataSuccess?: (res: any) => void;
27
- onGetProfileDataError?: (e: AxiosError) => void;
28
- modalClassname?: string;
29
- }
30
-
31
- const style: React.CSSProperties = {
32
- position: 'absolute',
33
- top: '50%',
34
- left: '50%',
35
- transform: 'translate(-50%, -50%)',
36
- minWidth: 480,
37
- backgroundColor: '#e3e3e3',
38
- border: '1px solid white',
39
- outline: 'none',
40
- }
41
-
42
- export const LoginModal: FC<Props> = ({
43
- onClose,
44
- onLogin,
45
- alreadyHasUser = false,
46
- userExpired = false,
47
- onAuthorizeSuccess = () => {},
48
- onAuthorizeError = () => {},
49
- onGetProfileDataSuccess = () => {},
50
- onGetProfileDataError = () => {},
51
- modalClassname = '',
52
- }) => {
53
- const [error, setError] = useState('')
54
- const handleForgotPassword = () => {
55
- if (typeof window !== 'undefined') {
56
- window.open(`${CONFIGS.BASE_URL}/password-restore/`)
57
- }
58
- }
59
- return (
60
- <Modal
61
- open={true}
62
- onClose={onClose}
63
- aria-labelledby="modal-modal-title"
64
- aria-describedby="modal-modal-description"
65
- className={`login-modal ${modalClassname}`}
66
- >
67
- <Box style={style}>
68
- <div>
69
- <Formik
70
- initialValues={{ email: '', password: '' }}
71
- onSubmit={async ({ email, password }) => {
72
- try {
73
- const bodyFormData = new FormData()
74
- bodyFormData.append('email', email)
75
- bodyFormData.append('password', password)
76
-
77
- const resAutorize = await authorize(bodyFormData)
78
- const bodyFormDataToken = new FormData()
79
- bodyFormDataToken.append('code', resAutorize.data.data.code)
80
- bodyFormDataToken.append('scope', 'profile')
81
- bodyFormDataToken.append('grant_type', 'authorization_code')
82
- bodyFormDataToken.append(
83
- 'client_id',
84
- CONFIGS.CLIENT_ID || 'e9d8f8922797b4621e562255afe90dbf'
85
- )
86
- bodyFormDataToken.append(
87
- 'client_secret',
88
- CONFIGS.CLIENT_SECRET ||
89
- 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9'
90
- )
91
-
92
- let resAccessToken = null
93
-
94
- try {
95
- resAccessToken = await getAccessToken(bodyFormDataToken)
96
- onAuthorizeSuccess(resAccessToken.data)
97
- } catch (e) {
98
- if (axios.isAxiosError(e)) {
99
- onAuthorizeError(e)
100
- }
101
- return
102
- }
103
-
104
- const accessToken = _get(resAccessToken, 'data.access_token')
105
- handleSetAccessToken(accessToken)
106
-
107
- let profileResponse = null
108
-
109
- try {
110
- profileResponse = await getProfileData(accessToken)
111
- onGetProfileDataSuccess(profileResponse.data)
112
- } catch (e) {
113
- if (axios.isAxiosError(e)) {
114
- onGetProfileDataError(e)
115
- }
116
- return
117
- }
118
-
119
- const profileSpecifiedData = _get(profileResponse, 'data.data')
120
- const profileDataObj = {
121
- id: profileSpecifiedData.id,
122
- first_name: profileSpecifiedData.firstName,
123
- last_name: profileSpecifiedData.lastName,
124
- email: profileSpecifiedData.email,
125
- }
126
- if (typeof window !== 'undefined') {
127
- window.localStorage.setItem(
128
- 'user_data',
129
- JSON.stringify(profileDataObj)
130
- )
131
- window.localStorage.setItem('access_token', accessToken)
132
- const event = new window.CustomEvent('tf-login')
133
- window.document.dispatchEvent(event)
134
- }
135
- onLogin()
136
- } catch (e) {
137
- if (axios.isAxiosError(e)) {
138
- const error = e?.response?.data?.message || 'Error'
139
- setError(error)
140
- } else if (e instanceof Error) {
141
- setError(e?.message || 'Error')
142
- }
143
- }
144
- }}
145
- >
146
- {props => (
147
- <Form onSubmit={props.handleSubmit}>
148
- <div className="modal-title">Login</div>
149
- <img
150
- className="login-logo-tff"
151
- src="https://www.ticketfairy.com/resources/images/logo-ttf-black.svg"
152
- alt=""
153
- />
154
- <div className="server_auth__error">{error}</div>
155
- {alreadyHasUser && (
156
- <p className="info-text-for-login">
157
- It appears this email is already attached to an account.
158
- Please log in here to complete your registration.
159
- </p>
160
- )}
161
- {userExpired && (
162
- <p className="info-text-for-login">
163
- Your session has expired, please log in again.
164
- </p>
165
- )}
166
- <div className="login-modal-body">
167
- <div className="login-modal-body__email">
168
- <Field name={'email'} validate={requiredValidator}>
169
- {({ field, meta }: { [key: string]: any }) => (
170
- <TextField
171
- label={'Email'}
172
- type={'email'}
173
- fullWidth
174
- error={!!meta.error && meta.touched}
175
- helperText={meta.touched && meta.error}
176
- {...field}
177
- />
178
- )}
179
- </Field>
180
- </div>
181
- <div className="login-modal-body__password">
182
- <Field name={'password'} validate={requiredValidator}>
183
- {({ field, meta }: { [key: string]: any }) => (
184
- <TextField
185
- label="Password"
186
- type="password"
187
- fullWidth
188
- error={!!meta.error && meta.touched}
189
- helperText={meta.touched && meta.error}
190
- {...field}
191
- />
192
- )}
193
- </Field>
194
- </div>
195
- <div className="login-action-button">
196
- <button type="submit">Login</button>
197
- </div>
198
- <div className='forgot-password'>
199
- <span onClick={handleForgotPassword}>Forgot password?</span>
200
- </div>
201
- </div>
202
- </Form>
203
- )}
204
- </Formik>
205
- </div>
206
- </Box>
207
- </Modal>
208
- )
209
- }
1
+ import React, { FC, useState } from 'react'
2
+ import { AxiosError } from 'axios'
3
+ import {
4
+ authorize,
5
+ getProfileData,
6
+ } from '../../api'
7
+ import _get from 'lodash/get'
8
+ import { Field, Form, Formik } from 'formik'
9
+ import { requiredValidator } from '../../validators'
10
+ import { TextField } from '@mui/material'
11
+ import Modal from '@mui/material/Modal'
12
+ import Box from '@mui/material/Box'
13
+ import './style.css'
14
+ import { CONFIGS } from '../../utils'
15
+ import axios from 'axios'
16
+
17
+ interface Props {
18
+ onClose: () => void;
19
+ onLogin: () => void;
20
+ alreadyHasUser?: boolean;
21
+ userExpired?: boolean;
22
+ onAuthorizeSuccess?: (res: any) => void;
23
+ onAuthorizeError?: (e: AxiosError) => void;
24
+ onGetProfileDataSuccess?: (res: any) => void;
25
+ onGetProfileDataError?: (e: AxiosError) => void;
26
+ modalClassname?: string;
27
+ }
28
+
29
+ const style: React.CSSProperties = {
30
+ position: 'absolute',
31
+ top: '50%',
32
+ left: '50%',
33
+ transform: 'translate(-50%, -50%)',
34
+ minWidth: 480,
35
+ backgroundColor: '#e3e3e3',
36
+ border: '1px solid white',
37
+ outline: 'none',
38
+ }
39
+
40
+ export const LoginModal: FC<Props> = ({
41
+ onClose,
42
+ onLogin,
43
+ alreadyHasUser = false,
44
+ userExpired = false,
45
+ onGetProfileDataSuccess = () => {},
46
+ onGetProfileDataError = () => {},
47
+ modalClassname = '',
48
+ }) => {
49
+ const [error, setError] = useState('')
50
+ const handleForgotPassword = () => {
51
+ if (typeof window !== 'undefined') {
52
+ window.open(`${CONFIGS.BASE_URL}/password-restore/`)
53
+ }
54
+ }
55
+ return (
56
+ <Modal
57
+ open={true}
58
+ onClose={onClose}
59
+ aria-labelledby="modal-modal-title"
60
+ aria-describedby="modal-modal-description"
61
+ className={`login-modal ${modalClassname}`}
62
+ >
63
+ <Box style={style}>
64
+ <div>
65
+ <Formik
66
+ initialValues={{ email: '', password: '' }}
67
+ onSubmit={async ({ email, password }) => {
68
+ try {
69
+ const body = { email, password }
70
+ await authorize(body)
71
+ let profileResponse = null
72
+ try {
73
+ profileResponse = await getProfileData()
74
+ onGetProfileDataSuccess(profileResponse.data)
75
+ } catch (e) {
76
+ if (axios.isAxiosError(e)) {
77
+ onGetProfileDataError(e)
78
+ }
79
+ return
80
+ }
81
+
82
+ const profileSpecifiedData = _get(profileResponse, 'data.data')
83
+ const profileDataObj = {
84
+ id: profileSpecifiedData.id,
85
+ first_name: profileSpecifiedData.firstName,
86
+ last_name: profileSpecifiedData.lastName,
87
+ email: profileSpecifiedData.email,
88
+ }
89
+ if (typeof window !== 'undefined') {
90
+ window.localStorage.setItem(
91
+ 'user_data',
92
+ JSON.stringify(profileDataObj)
93
+ )
94
+ const event = new window.CustomEvent('tf-login')
95
+ window.document.dispatchEvent(event)
96
+ }
97
+ onLogin()
98
+ } catch (e) {
99
+ if (axios.isAxiosError(e)) {
100
+ const error = e?.response?.data?.message || 'Error'
101
+ setError(error)
102
+ } else if (e instanceof Error) {
103
+ setError(e?.message || 'Error')
104
+ }
105
+ }
106
+ }}
107
+ >
108
+ {props => (
109
+ <Form onSubmit={props.handleSubmit}>
110
+ <div className="modal-title">Login</div>
111
+ <img
112
+ className="login-logo-tff"
113
+ src="https://www.ticketfairy.com/resources/images/logo-ttf-black.svg"
114
+ alt=""
115
+ />
116
+ <div className="server_auth__error">{error}</div>
117
+ {alreadyHasUser && (
118
+ <p className="info-text-for-login">
119
+ It appears this email is already attached to an account.
120
+ Please log in here to complete your registration.
121
+ </p>
122
+ )}
123
+ {userExpired && (
124
+ <p className="info-text-for-login">
125
+ Your session has expired, please log in again.
126
+ </p>
127
+ )}
128
+ <div className="login-modal-body">
129
+ <div className="login-modal-body__email">
130
+ <Field name={'email'} validate={requiredValidator}>
131
+ {({ field, meta }: { [key: string]: any }) => (
132
+ <TextField
133
+ label={'Email'}
134
+ type={'email'}
135
+ fullWidth
136
+ error={!!meta.error && meta.touched}
137
+ helperText={meta.touched && meta.error}
138
+ {...field}
139
+ />
140
+ )}
141
+ </Field>
142
+ </div>
143
+ <div className="login-modal-body__password">
144
+ <Field name={'password'} validate={requiredValidator}>
145
+ {({ field, meta }: { [key: string]: any }) => (
146
+ <TextField
147
+ label="Password"
148
+ type="password"
149
+ fullWidth
150
+ error={!!meta.error && meta.touched}
151
+ helperText={meta.touched && meta.error}
152
+ {...field}
153
+ />
154
+ )}
155
+ </Field>
156
+ </div>
157
+ <div className="login-action-button">
158
+ <button type="submit">Login</button>
159
+ </div>
160
+ <div className='forgot-password'>
161
+ <span onClick={handleForgotPassword}>Forgot password?</span>
162
+ </div>
163
+ </div>
164
+ </Form>
165
+ )}
166
+ </Formik>
167
+ </div>
168
+ </Box>
169
+ </Modal>
170
+ )
171
+ }
@@ -1,72 +1,72 @@
1
- .modal-title {
2
- padding-left: 25px;
3
- background-color: #fff;
4
- height: 49px;
5
- display: flex;
6
- align-items: center;
7
- font-family: Inter;
8
- font-weight: 700;
9
- font-size: 18px;
10
- line-height: 22px;
11
- position: relative;
12
- }
13
-
14
- .login-modal-body {
15
- padding: 15px 25px;
16
- }
17
-
18
- .login-modal-body input {
19
- background: white !important;
20
- }
21
-
22
- .login-modal-body__email {
23
- margin-bottom: 20px;
24
- }
25
-
26
- .login-modal-body__password {
27
- margin-bottom: 20px;
28
- }
29
-
30
- .login-action-button button {
31
- padding: 10px;
32
- width: 100%;
33
- margin: 10px 0;
34
- border: none;
35
- border-radius: 0;
36
- height: 45px;
37
- font-weight: 600;
38
- font-size: 26px;
39
- line-height: 18px;
40
- color: white;
41
- cursor: pointer;
42
- outline: none;
43
- background-color: #212529;
44
- }
45
- .login-action-button button:hover {
46
- background-color: #505050;
47
- border-color: #505050;
48
- }
49
-
50
- .server_auth__error {
51
- color: red;
52
- padding-left: 25px;
53
- padding-top: 15px;
54
- font-size: 12px;
55
- font-family: Inter;
56
- font-style: normal;
57
- }
58
-
59
- .info-text-for-login {
60
- font-size: 14px;
61
- padding-left: 10px;
62
- margin-bottom: 4px;
63
- }
64
- .forgot-password {
65
- text-align: center;
66
- }
67
- .forgot-password span {
68
- cursor: pointer;
69
- }
70
- .forgot-password span:hover {
71
- text-decoration: underline;
1
+ .modal-title {
2
+ padding-left: 25px;
3
+ background-color: #fff;
4
+ height: 49px;
5
+ display: flex;
6
+ align-items: center;
7
+ font-family: Inter;
8
+ font-weight: 700;
9
+ font-size: 18px;
10
+ line-height: 22px;
11
+ position: relative;
12
+ }
13
+
14
+ .login-modal-body {
15
+ padding: 15px 25px;
16
+ }
17
+
18
+ .login-modal-body input {
19
+ background: white !important;
20
+ }
21
+
22
+ .login-modal-body__email {
23
+ margin-bottom: 20px;
24
+ }
25
+
26
+ .login-modal-body__password {
27
+ margin-bottom: 20px;
28
+ }
29
+
30
+ .login-action-button button {
31
+ padding: 10px;
32
+ width: 100%;
33
+ margin: 10px 0;
34
+ border: none;
35
+ border-radius: 0;
36
+ height: 45px;
37
+ font-weight: 600;
38
+ font-size: 26px;
39
+ line-height: 18px;
40
+ color: white;
41
+ cursor: pointer;
42
+ outline: none;
43
+ background-color: #212529;
44
+ }
45
+ .login-action-button button:hover {
46
+ background-color: #505050;
47
+ border-color: #505050;
48
+ }
49
+
50
+ .server_auth__error {
51
+ color: red;
52
+ padding-left: 25px;
53
+ padding-top: 15px;
54
+ font-size: 12px;
55
+ font-family: Inter;
56
+ font-style: normal;
57
+ }
58
+
59
+ .info-text-for-login {
60
+ font-size: 14px;
61
+ padding-left: 10px;
62
+ margin-bottom: 4px;
63
+ }
64
+ .forgot-password {
65
+ text-align: center;
66
+ }
67
+ .forgot-password span {
68
+ cursor: pointer;
69
+ }
70
+ .forgot-password span:hover {
71
+ text-decoration: underline;
72
72
  }