tf-checkout-react 1.0.106 → 1.2.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.
- package/README.md +278 -1
- package/dist/api/index.d.ts +40 -28
- package/dist/components/account-settings/index.d.ts +3 -0
- package/dist/components/billing-info-container/index.d.ts +11 -8
- package/dist/components/common/PhoneNumberField.d.ts +9 -0
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/confirmationContainer/index.d.ts +2 -1
- package/dist/components/countdown/index.d.ts +2 -1
- package/dist/components/forgotPasswordModal/index.d.ts +11 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/loginModal/index.d.ts +35 -2
- package/dist/components/myTicketsContainer/index.d.ts +2 -1
- package/dist/components/myTicketsContainer/tableConfig.d.ts +1 -1
- package/dist/components/orderDetailsContainer/index.d.ts +6 -1
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +2 -1
- package/dist/components/paymentContainer/index.d.ts +2 -1
- package/dist/components/resetPasswordContainer/index.d.ts +10 -0
- package/dist/components/signupModal/index.d.ts +14 -0
- package/dist/components/ticketsContainer/PromoCodeSection.d.ts +3 -2
- package/dist/components/ticketsContainer/TicketsSection.d.ts +1 -2
- package/dist/components/ticketsContainer/index.d.ts +7 -3
- package/dist/index.d.ts +2 -0
- package/dist/tf-checkout-react.cjs.development.js +2177 -1482
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +2166 -1473
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/dist/utils/cookies.d.ts +3 -0
- package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +6 -1
- package/dist/utils/downloadPDF.d.ts +1 -1
- package/dist/utils/getDomain.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/package.json +12 -1
- package/src/api/index.ts +100 -29
- package/src/components/account-settings/index.tsx +161 -0
- package/src/components/account-settings/style.css +200 -0
- package/src/components/billing-info-container/index.tsx +145 -99
- package/src/components/billing-info-container/style.css +1 -1
- package/src/components/billing-info-container/utils.ts +11 -3
- package/src/components/common/PhoneNumberField.tsx +68 -0
- package/src/components/common/SnackbarAlert.tsx +1 -1
- package/src/components/common/dist/PhoneNumberField.js +96 -0
- package/src/components/common/index.tsx +1 -0
- package/src/components/confirmationContainer/index.tsx +19 -9
- package/src/components/countdown/index.tsx +3 -1
- package/src/components/forgotPasswordModal/index.tsx +107 -0
- package/src/components/forgotPasswordModal/style.css +47 -0
- package/src/components/index.ts +1 -0
- package/src/components/loginModal/index.tsx +72 -71
- package/src/components/myTicketsContainer/index.tsx +99 -95
- package/src/components/myTicketsContainer/style.css +2 -2
- package/src/components/myTicketsContainer/tableConfig.tsx +3 -6
- package/src/components/orderDetailsContainer/index.tsx +80 -21
- package/src/components/orderDetailsContainer/style.css +7 -3
- package/src/components/orderDetailsContainer/ticketsTable.tsx +130 -83
- package/src/components/paymentContainer/index.tsx +114 -49
- package/src/components/registerModal/index.tsx +3 -10
- package/src/components/resetPasswordContainer/index.tsx +96 -0
- package/src/components/resetPasswordContainer/style.css +36 -0
- package/src/components/signupModal/index.tsx +195 -0
- package/src/components/signupModal/style.css +58 -0
- package/src/components/stripePayment/index.tsx +14 -12
- package/src/components/stripePayment/style.css +3 -3
- package/src/components/ticketResaleModal/index.tsx +12 -14
- package/src/components/ticketsContainer/PromoCodeSection.tsx +8 -7
- package/src/components/ticketsContainer/TicketRow.tsx +12 -6
- package/src/components/ticketsContainer/TicketsSection.tsx +0 -3
- package/src/components/ticketsContainer/index.tsx +155 -86
- package/src/env.ts +3 -3
- package/src/index.ts +3 -1
- package/src/utils/cookies.ts +42 -0
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +16 -4
- package/src/utils/downloadPDF.tsx +28 -6
- package/src/utils/getDomain.ts +15 -0
- package/src/utils/index.ts +2 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.PhoneNumberField = void 0;
|
|
51
|
+
var TextField_1 = require("@mui/material/TextField");
|
|
52
|
+
var debounce_1 = require("lodash/debounce");
|
|
53
|
+
var get_1 = require("lodash/get");
|
|
54
|
+
var react_1 = require("react");
|
|
55
|
+
var api_1 = require("../../api");
|
|
56
|
+
exports.PhoneNumberField = function (_a) {
|
|
57
|
+
var label = _a.label, _b = _a.type, type = _b === void 0 ? 'text' : _b, field = _a.field, _c = _a.form, errors = _c.errors, setFieldError = _c.setFieldError, setStatus = _c.setStatus;
|
|
58
|
+
var error = get_1["default"](errors, field.name);
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
var debounceCb = react_1.useCallback(debounce_1["default"](function (cb) { return void cb(); }, 1000), []);
|
|
61
|
+
react_1.useEffect(function () {
|
|
62
|
+
var _a;
|
|
63
|
+
if (field.value) {
|
|
64
|
+
setStatus((_a = {}, _a[field.name] = true, _a));
|
|
65
|
+
}
|
|
66
|
+
debounceCb(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
+
var error_1, message;
|
|
68
|
+
var _a;
|
|
69
|
+
return __generator(this, function (_b) {
|
|
70
|
+
switch (_b.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
_b.trys.push([0, 3, 4, 5]);
|
|
73
|
+
if (!field.value) return [3 /*break*/, 2];
|
|
74
|
+
return [4 /*yield*/, api_1.validatePhoneNumber(field.value)];
|
|
75
|
+
case 1:
|
|
76
|
+
_b.sent();
|
|
77
|
+
_b.label = 2;
|
|
78
|
+
case 2:
|
|
79
|
+
setFieldError(field.name, '');
|
|
80
|
+
return [3 /*break*/, 5];
|
|
81
|
+
case 3:
|
|
82
|
+
error_1 = _b.sent();
|
|
83
|
+
message = get_1["default"](error_1, 'response.data.message', 'Invalid phone number');
|
|
84
|
+
setFieldError(field.name, message);
|
|
85
|
+
return [3 /*break*/, 5];
|
|
86
|
+
case 4:
|
|
87
|
+
setStatus((_a = {}, _a[field.name] = false, _a));
|
|
88
|
+
return [7 /*endfinally*/];
|
|
89
|
+
case 5: return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}); });
|
|
93
|
+
// eslint-disable-next-line
|
|
94
|
+
}, [field.value]);
|
|
95
|
+
return (react_1["default"].createElement(TextField_1["default"], __assign({}, field, { id: field.name, label: label, type: type, fullWidth: true, error: !!error, helperText: error, value: field.value || '', inputProps: { pattern: '[+0-9]/d+' } })));
|
|
96
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CheckboxField } from './CheckboxField'
|
|
2
2
|
export { CustomField } from './CustomField'
|
|
3
3
|
export { FormikPhoneNumberField } from './FormikPhoneNumberField'
|
|
4
|
+
export { PhoneNumberField } from './PhoneNumberField'
|
|
4
5
|
export { Loader } from './Loader'
|
|
5
6
|
export { SelectField } from './SelectField'
|
|
@@ -16,6 +16,7 @@ export interface IShareButton {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface IConfirmationPage {
|
|
19
|
+
hasCopyIcon?: boolean;
|
|
19
20
|
isReferralEnabled: boolean;
|
|
20
21
|
showDefaultShareButtons: boolean;
|
|
21
22
|
messengerAppId: string;
|
|
@@ -27,6 +28,7 @@ export interface IConfirmationPage {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export const ConfirmationContainer = ({
|
|
31
|
+
hasCopyIcon = true,
|
|
30
32
|
isReferralEnabled,
|
|
31
33
|
showDefaultShareButtons,
|
|
32
34
|
messengerAppId = '',
|
|
@@ -96,12 +98,19 @@ export const ConfirmationContainer = ({
|
|
|
96
98
|
<div className="confirmation-page">
|
|
97
99
|
{data && (
|
|
98
100
|
<>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
<div className='header-container'>
|
|
102
|
+
<div className='header-product-image'>
|
|
103
|
+
<img className='product-image' src={data.product_image}/>
|
|
104
|
+
</div>
|
|
105
|
+
<div className="header-product-text">
|
|
106
|
+
<p className="title">Your Tickets are Confirmed!</p>
|
|
107
|
+
<div className="share-message-section">
|
|
108
|
+
<span className="main">Your tickets have been emailed to you</span>
|
|
109
|
+
<span className="helper">
|
|
110
|
+
Please bring them with you to the event
|
|
111
|
+
</span>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
105
114
|
</div>
|
|
106
115
|
{data.disable_referral === false && isReferralEnabled && (
|
|
107
116
|
<>
|
|
@@ -120,7 +129,7 @@ export const ConfirmationContainer = ({
|
|
|
120
129
|
of your ticket money, if they buy tickets as well!
|
|
121
130
|
</div>
|
|
122
131
|
</div>
|
|
123
|
-
<img src={data.product_image} alt="No Data" />
|
|
132
|
+
<img className='body-product-image' src={data.product_image} alt="No Data" />
|
|
124
133
|
</div>
|
|
125
134
|
<div className="share_wrapper">
|
|
126
135
|
<div className="share_section">
|
|
@@ -149,10 +158,11 @@ export const ConfirmationContainer = ({
|
|
|
149
158
|
onLinkCopied()
|
|
150
159
|
}}
|
|
151
160
|
>
|
|
152
|
-
<img
|
|
161
|
+
{hasCopyIcon ? <img
|
|
153
162
|
src="https://img.icons8.com/office/50/000000/copy.png"
|
|
154
163
|
alt="copy"
|
|
155
|
-
|
|
164
|
+
/>: <span className='copy-icon'>Copy</span>}
|
|
165
|
+
|
|
156
166
|
</div>
|
|
157
167
|
</div>
|
|
158
168
|
</div>
|
|
@@ -7,6 +7,7 @@ interface CountdownTypes {
|
|
|
7
7
|
timezone?: string;
|
|
8
8
|
title?: string;
|
|
9
9
|
message?: string;
|
|
10
|
+
showMessage?: boolean;
|
|
10
11
|
disableLeadingZero?: boolean;
|
|
11
12
|
callback?: () => void;
|
|
12
13
|
isLoggedIn?: boolean;
|
|
@@ -21,6 +22,7 @@ function Countdown({
|
|
|
21
22
|
timezone = moment.tz.guess(),
|
|
22
23
|
title = '',
|
|
23
24
|
message = '',
|
|
25
|
+
showMessage = false,
|
|
24
26
|
disableLeadingZero = false,
|
|
25
27
|
callback = () => {},
|
|
26
28
|
isLoggedIn
|
|
@@ -88,7 +90,7 @@ function Countdown({
|
|
|
88
90
|
<p className='title'>{title}</p>
|
|
89
91
|
<p>{duration}</p>
|
|
90
92
|
</div>
|
|
91
|
-
<p className='message'>{message}</p>
|
|
93
|
+
{showMessage && <p className='message'>{message}</p>}
|
|
92
94
|
</div>
|
|
93
95
|
)}
|
|
94
96
|
</>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { FC, useState } from 'react'
|
|
2
|
+
import { Field, Form, Formik } from 'formik'
|
|
3
|
+
import axios, { AxiosError } from 'axios'
|
|
4
|
+
import { Modal, Box, CircularProgress } from '@mui/material'
|
|
5
|
+
import { CustomField } from '../common/CustomField'
|
|
6
|
+
import * as Yup from 'yup'
|
|
7
|
+
import { forgotPassword } from '../../api'
|
|
8
|
+
import './style.css'
|
|
9
|
+
|
|
10
|
+
interface IForgotPasswordProps {
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
onLogin: () => void;
|
|
13
|
+
onForgotPasswordSuccess: (res: any) => void;
|
|
14
|
+
onForgotPasswordError: (e: AxiosError) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ValuesTypes {
|
|
18
|
+
email: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const style: React.CSSProperties = {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: '50%',
|
|
24
|
+
left: '50%',
|
|
25
|
+
transform: 'translate(-50%, -50%)',
|
|
26
|
+
minWidth: 480,
|
|
27
|
+
backgroundColor: '#fff',
|
|
28
|
+
border: '1px solid white',
|
|
29
|
+
outline: 'none',
|
|
30
|
+
padding: '14px',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const Schema = Yup.object().shape({
|
|
34
|
+
email: Yup.string()
|
|
35
|
+
.email('Invalid email')
|
|
36
|
+
.required('Required'),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export const ForgotPasswordModal: FC<IForgotPasswordProps> = ({
|
|
40
|
+
onClose = () => {},
|
|
41
|
+
onLogin = () => {},
|
|
42
|
+
onForgotPasswordSuccess = () => {},
|
|
43
|
+
onForgotPasswordError = () => {},
|
|
44
|
+
}) => {
|
|
45
|
+
const [loading, setLoading] = useState(false)
|
|
46
|
+
|
|
47
|
+
const onForgotPassword = async ({ email }: ValuesTypes) => {
|
|
48
|
+
try {
|
|
49
|
+
setLoading(true)
|
|
50
|
+
const { data } = await forgotPassword(email)
|
|
51
|
+
|
|
52
|
+
onForgotPasswordSuccess(data)
|
|
53
|
+
onClose()
|
|
54
|
+
} catch (e) {
|
|
55
|
+
if (axios.isAxiosError(e)) {
|
|
56
|
+
onForgotPasswordError(e)
|
|
57
|
+
}
|
|
58
|
+
} finally {
|
|
59
|
+
setLoading(false)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const _onClose = loading ? () => {} : onClose
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Modal
|
|
67
|
+
open={true}
|
|
68
|
+
onClose={_onClose}
|
|
69
|
+
aria-labelledby="modal-modal-title"
|
|
70
|
+
aria-describedby="modal-modal-description"
|
|
71
|
+
className="forgot-password-modal"
|
|
72
|
+
>
|
|
73
|
+
<Box style={style}>
|
|
74
|
+
<div>
|
|
75
|
+
<Formik
|
|
76
|
+
initialValues={{ email: '' }}
|
|
77
|
+
validationSchema={Schema}
|
|
78
|
+
onSubmit={onForgotPassword}
|
|
79
|
+
>
|
|
80
|
+
{({ isValid, dirty, handleSubmit }) => (
|
|
81
|
+
<Form onSubmit={handleSubmit}>
|
|
82
|
+
<div className="forgot-password-container">
|
|
83
|
+
<div className="title">Password Reset</div>
|
|
84
|
+
<div className="forgot-password-container__singleField">
|
|
85
|
+
<Field
|
|
86
|
+
name="email"
|
|
87
|
+
label="Email"
|
|
88
|
+
component={CustomField}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
<div className="forgot-password-action-button">
|
|
93
|
+
<button type="submit" disabled={!(isValid && dirty)}>
|
|
94
|
+
{loading ? <CircularProgress size="22px" /> : 'Submit'}
|
|
95
|
+
</button>
|
|
96
|
+
</div>
|
|
97
|
+
<div className="login">
|
|
98
|
+
<span onClick={onLogin}>Back to Log In</span>
|
|
99
|
+
</div>
|
|
100
|
+
</Form>
|
|
101
|
+
)}
|
|
102
|
+
</Formik>
|
|
103
|
+
</div>
|
|
104
|
+
</Box>
|
|
105
|
+
</Modal>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.forgot-password-modal .forgot-password-container {
|
|
2
|
+
max-width: 800px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
}
|
|
5
|
+
.forgot-password-modal .title {
|
|
6
|
+
background-color: #fff;
|
|
7
|
+
font-family: Inter;
|
|
8
|
+
font-weight: 700;
|
|
9
|
+
font-size: 18px;
|
|
10
|
+
}
|
|
11
|
+
.forgot-password-modal .forgot-password-container__singleField {
|
|
12
|
+
margin-top: 15px;
|
|
13
|
+
}
|
|
14
|
+
.forgot-password-modal .forgot-password-action-button button {
|
|
15
|
+
padding: 10px;
|
|
16
|
+
width: 100%;
|
|
17
|
+
margin-top: 10px;
|
|
18
|
+
border: none;
|
|
19
|
+
border-radius: 0;
|
|
20
|
+
height: 45px;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
font-size: 26px;
|
|
23
|
+
line-height: 18px;
|
|
24
|
+
color: white;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
outline: none;
|
|
27
|
+
background-color: #212529;
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
}
|
|
30
|
+
.forgot-password-modal .forgot-password-action-button button:hover:enabled {
|
|
31
|
+
background-color: #505050;
|
|
32
|
+
border-color: #505050;
|
|
33
|
+
}
|
|
34
|
+
.forgot-password-modal .login {
|
|
35
|
+
text-align: center;
|
|
36
|
+
margin-top: 10px;
|
|
37
|
+
}
|
|
38
|
+
.forgot-password-modal .login span {
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
.forgot-password-modal .login span:hover {
|
|
42
|
+
text-decoration: underline;
|
|
43
|
+
}
|
|
44
|
+
.forgot-password-modal button[disabled] {
|
|
45
|
+
opacity: .7;
|
|
46
|
+
cursor: unset;
|
|
47
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { PaymentContainer } from './paymentContainer'
|
|
|
4
4
|
export { TicketsContainer } from './ticketsContainer'
|
|
5
5
|
export { MyTicketsContainer } from './myTicketsContainer'
|
|
6
6
|
export { OrderDetailsContainer } from './orderDetailsContainer'
|
|
7
|
+
export { ResetPasswordContainer } from './resetPasswordContainer'
|
|
7
8
|
export { TicketResaleContainer } from './ticketResale'
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
+
import './style.css'
|
|
2
|
+
|
|
3
|
+
import { TextField } from '@mui/material'
|
|
4
|
+
import Box from '@mui/material/Box'
|
|
5
|
+
import Modal from '@mui/material/Modal'
|
|
6
|
+
import axios, { AxiosError } from 'axios'
|
|
7
|
+
import { Field, Form, Formik } from 'formik'
|
|
8
|
+
import _get from 'lodash/get'
|
|
9
|
+
import _identity from 'lodash/identity'
|
|
1
10
|
import React, { FC, useState } from 'react'
|
|
2
|
-
|
|
11
|
+
|
|
3
12
|
import {
|
|
4
13
|
authorize,
|
|
5
|
-
getAccessToken,
|
|
6
14
|
getProfileData,
|
|
7
|
-
handleSetAccessToken,
|
|
8
15
|
} from '../../api'
|
|
9
|
-
import _get from 'lodash/get'
|
|
10
|
-
import { Field, Form, Formik } from 'formik'
|
|
11
16
|
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
17
|
|
|
19
18
|
interface Props {
|
|
20
19
|
onClose: () => void;
|
|
@@ -25,7 +24,12 @@ interface Props {
|
|
|
25
24
|
onAuthorizeError?: (e: AxiosError) => void;
|
|
26
25
|
onGetProfileDataSuccess?: (res: any) => void;
|
|
27
26
|
onGetProfileDataError?: (e: AxiosError) => void;
|
|
27
|
+
onForgotPassword?: () => void;
|
|
28
|
+
onSignup?: () => void;
|
|
28
29
|
modalClassname?: string;
|
|
30
|
+
logo?: string;
|
|
31
|
+
showForgotPasswordButton?: boolean;
|
|
32
|
+
showSignUpButton?: boolean;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
const style: React.CSSProperties = {
|
|
@@ -38,24 +42,51 @@ const style: React.CSSProperties = {
|
|
|
38
42
|
border: '1px solid white',
|
|
39
43
|
outline: 'none',
|
|
40
44
|
}
|
|
45
|
+
interface IUserData {
|
|
46
|
+
id: string;
|
|
47
|
+
firstName: string;
|
|
48
|
+
lastName: string;
|
|
49
|
+
email: string;
|
|
50
|
+
city?: string;
|
|
51
|
+
country?: string;
|
|
52
|
+
countryId?: string;
|
|
53
|
+
phone?: string;
|
|
54
|
+
streetAddress?: string;
|
|
55
|
+
state?: string;
|
|
56
|
+
zip?: string;
|
|
57
|
+
zipCode?: string;
|
|
58
|
+
stateId?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const setLoggedUserData = (data: IUserData) => ({
|
|
62
|
+
id: data.id,
|
|
63
|
+
first_name: data.firstName,
|
|
64
|
+
last_name: data.lastName,
|
|
65
|
+
email: data.email,
|
|
66
|
+
confirmEmail: data.email,
|
|
67
|
+
city: data?.city || '',
|
|
68
|
+
country: data?.countryId || data?.country || '',
|
|
69
|
+
phone: data?.phone || '',
|
|
70
|
+
street_address: data?.streetAddress || '',
|
|
71
|
+
state: data?.stateId || '',
|
|
72
|
+
zip: data?.zip || data?.zipCode || '',
|
|
73
|
+
})
|
|
41
74
|
|
|
42
75
|
export const LoginModal: FC<Props> = ({
|
|
43
76
|
onClose,
|
|
44
77
|
onLogin,
|
|
45
78
|
alreadyHasUser = false,
|
|
46
79
|
userExpired = false,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
80
|
+
onGetProfileDataSuccess = _identity,
|
|
81
|
+
onGetProfileDataError = _identity,
|
|
82
|
+
onForgotPassword = _identity,
|
|
83
|
+
onSignup = _identity,
|
|
51
84
|
modalClassname = '',
|
|
85
|
+
logo,
|
|
86
|
+
showForgotPasswordButton = false,
|
|
87
|
+
showSignUpButton = false,
|
|
52
88
|
}) => {
|
|
53
89
|
const [error, setError] = useState('')
|
|
54
|
-
const handleForgotPassword = () => {
|
|
55
|
-
if (typeof window !== 'undefined') {
|
|
56
|
-
window.open(`${CONFIGS.BASE_URL}/password-restore/`)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
90
|
return (
|
|
60
91
|
<Modal
|
|
61
92
|
open={true}
|
|
@@ -70,44 +101,11 @@ export const LoginModal: FC<Props> = ({
|
|
|
70
101
|
initialValues={{ email: '', password: '' }}
|
|
71
102
|
onSubmit={async ({ email, password }) => {
|
|
72
103
|
try {
|
|
73
|
-
const
|
|
74
|
-
|
|
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
|
-
|
|
104
|
+
const body = { email, password }
|
|
105
|
+
await authorize(body)
|
|
107
106
|
let profileResponse = null
|
|
108
|
-
|
|
109
107
|
try {
|
|
110
|
-
profileResponse = await getProfileData(
|
|
108
|
+
profileResponse = await getProfileData()
|
|
111
109
|
onGetProfileDataSuccess(profileResponse.data)
|
|
112
110
|
} catch (e) {
|
|
113
111
|
if (axios.isAxiosError(e)) {
|
|
@@ -117,18 +115,12 @@ export const LoginModal: FC<Props> = ({
|
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
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
|
-
}
|
|
118
|
+
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
126
119
|
if (typeof window !== 'undefined') {
|
|
127
120
|
window.localStorage.setItem(
|
|
128
121
|
'user_data',
|
|
129
122
|
JSON.stringify(profileDataObj)
|
|
130
123
|
)
|
|
131
|
-
window.localStorage.setItem('access_token', accessToken)
|
|
132
124
|
const event = new window.CustomEvent('tf-login')
|
|
133
125
|
window.document.dispatchEvent(event)
|
|
134
126
|
}
|
|
@@ -146,11 +138,13 @@ export const LoginModal: FC<Props> = ({
|
|
|
146
138
|
{props => (
|
|
147
139
|
<Form onSubmit={props.handleSubmit}>
|
|
148
140
|
<div className="modal-title">Login</div>
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
141
|
+
<div className='login-logo-container'>
|
|
142
|
+
<img
|
|
143
|
+
className="login-logo-tff"
|
|
144
|
+
src={logo || "https://www.ticketfairy.com/resources/images/logo-ttf-black.svg"}
|
|
145
|
+
alt="logo"
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
154
148
|
<div className="server_auth__error">{error}</div>
|
|
155
149
|
{alreadyHasUser && (
|
|
156
150
|
<p className="info-text-for-login">
|
|
@@ -195,9 +189,16 @@ export const LoginModal: FC<Props> = ({
|
|
|
195
189
|
<div className="login-action-button">
|
|
196
190
|
<button type="submit">Login</button>
|
|
197
191
|
</div>
|
|
198
|
-
|
|
199
|
-
<
|
|
200
|
-
|
|
192
|
+
{showForgotPasswordButton && (
|
|
193
|
+
<div className="forgot-password">
|
|
194
|
+
<span aria-hidden="true" onClick={onForgotPassword}>Forgot password?</span>
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
197
|
+
{showSignUpButton && (
|
|
198
|
+
<div className="forgot-password">
|
|
199
|
+
<span aria-hidden="true" onClick={onSignup}>Sign up</span>
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
201
202
|
</div>
|
|
202
203
|
</Form>
|
|
203
204
|
)}
|