tf-checkout-react-native 1.0.1 → 1.0.6
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 +235 -7
- package/assets/icons/ic_check.png +0 -0
- package/assets/icons/ic_copy.png +0 -0
- package/assets/icons/ic_dropdown.png +0 -0
- package/assets/icons/ic_error.png +0 -0
- package/assets/icons/ic_next.png +0 -0
- package/assets/images/brand.png +0 -0
- package/lib/api/ApiClient.d.ts +7 -4
- package/lib/api/ApiClient.js +119 -98
- package/lib/api/ApiClient.js.map +1 -1
- package/lib/api/Constants.d.ts +1 -0
- package/lib/api/Constants.js +1 -0
- package/lib/api/Constants.js.map +1 -1
- package/lib/api/types.d.ts +23 -3
- package/lib/api/types.js +0 -1
- package/lib/api/types.js.map +1 -1
- package/lib/components/button/Button.js +4 -4
- package/lib/components/button/Button.js.map +1 -1
- package/lib/components/checkbox/types.d.ts +1 -1
- package/lib/components/datePicker/DatePicker.d.ts +1 -1
- package/lib/components/datePicker/DatePicker.js +10 -7
- package/lib/components/datePicker/DatePicker.js.map +1 -1
- package/lib/components/datePicker/styles.d.ts +0 -1
- package/lib/components/datePicker/styles.js +0 -1
- package/lib/components/datePicker/styles.js.map +1 -1
- package/lib/components/datePicker/types.d.ts +12 -4
- package/lib/components/dropdown/Dropdown.d.ts +1 -1
- package/lib/components/dropdown/Dropdown.js +26 -14
- package/lib/components/dropdown/Dropdown.js.map +1 -1
- package/lib/components/dropdown/DropdownListItem.d.ts +1 -1
- package/lib/components/dropdown/DropdownListItem.js +7 -5
- package/lib/components/dropdown/DropdownListItem.js.map +1 -1
- package/lib/components/dropdown/styles.d.ts +15 -3
- package/lib/components/dropdown/styles.js +22 -4
- package/lib/components/dropdown/styles.js.map +1 -1
- package/lib/components/dropdown/types.d.ts +16 -7
- package/lib/components/formField/FormField.js +10 -7
- package/lib/components/formField/FormField.js.map +1 -1
- package/lib/components/formField/types.d.ts +5 -3
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/index.js.map +1 -1
- package/lib/components/input/Input.js +4 -2
- package/lib/components/input/Input.js.map +1 -1
- package/lib/components/input/types.d.ts +2 -0
- package/lib/components/loggedIn/LoggedIn.js +21 -7
- package/lib/components/loggedIn/LoggedIn.js.map +1 -1
- package/lib/components/loggedIn/types.d.ts +17 -5
- package/lib/components/login/Login.d.ts +1 -1
- package/lib/components/login/Login.js +21 -17
- package/lib/components/login/Login.js.map +1 -1
- package/lib/components/login/LoginView.d.ts +1 -1
- package/lib/components/login/LoginView.js +38 -19
- package/lib/components/login/LoginView.js.map +1 -1
- package/lib/components/login/styles.d.ts +5 -0
- package/lib/components/login/styles.js +5 -0
- package/lib/components/login/styles.js.map +1 -1
- package/lib/components/login/types.d.ts +24 -5
- package/lib/components/promoCode/PromoCode.js +9 -1
- package/lib/components/promoCode/PromoCode.js.map +1 -1
- package/lib/components/wrapper/Wrapper.d.ts +8 -0
- package/lib/components/wrapper/Wrapper.js +29 -0
- package/lib/components/wrapper/Wrapper.js.map +1 -0
- package/lib/containers/billingInfo/Billing.d.ts +3 -0
- package/lib/containers/billingInfo/Billing.js +583 -0
- package/lib/containers/billingInfo/Billing.js.map +1 -0
- package/lib/containers/billingInfo/styles.d.ts +36 -0
- package/lib/containers/billingInfo/styles.js +37 -0
- package/lib/containers/billingInfo/styles.js.map +1 -1
- package/lib/containers/billingInfo/types.d.ts +47 -4
- package/lib/containers/checkout/Checkout.d.ts +1 -1
- package/lib/containers/checkout/Checkout.js +54 -32
- package/lib/containers/checkout/Checkout.js.map +1 -1
- package/lib/containers/checkout/CheckoutData.js +9 -9
- package/lib/containers/checkout/CheckoutData.js.map +1 -1
- package/lib/containers/checkout/CheckoutView.d.ts +1 -1
- package/lib/containers/checkout/CheckoutView.js +24 -10
- package/lib/containers/checkout/CheckoutView.js.map +1 -1
- package/lib/containers/checkout/components/OrderReview.d.ts +1 -1
- package/lib/containers/checkout/components/OrderReview.js +4 -4
- package/lib/containers/checkout/components/OrderReview.js.map +1 -1
- package/lib/containers/checkout/styles.d.ts +17 -2
- package/lib/containers/checkout/styles.js +17 -2
- package/lib/containers/checkout/styles.js.map +1 -1
- package/lib/containers/checkout/types.d.ts +50 -5
- package/lib/containers/index.d.ts +1 -1
- package/lib/containers/index.js +1 -1
- package/lib/containers/index.js.map +1 -1
- package/lib/containers/myOrderDetails/MyOrderDetails.js +61 -6
- package/lib/containers/myOrderDetails/MyOrderDetails.js.map +1 -1
- package/lib/containers/myOrderDetails/MyOrderDetailsView.js +140 -36
- package/lib/containers/myOrderDetails/MyOrderDetailsView.js.map +1 -1
- package/lib/containers/myOrderDetails/components/Notification.d.ts +6 -0
- package/lib/containers/myOrderDetails/components/Notification.js +16 -0
- package/lib/containers/myOrderDetails/components/Notification.js.map +1 -0
- package/lib/containers/myOrderDetails/components/styles.d.ts +38 -0
- package/lib/containers/myOrderDetails/components/styles.js +41 -0
- package/lib/containers/myOrderDetails/components/styles.js.map +1 -0
- package/lib/containers/myOrderDetails/styles.d.ts +54 -0
- package/lib/containers/myOrderDetails/styles.js +54 -1
- package/lib/containers/myOrderDetails/styles.js.map +1 -1
- package/lib/containers/myOrderDetails/types.d.ts +70 -6
- package/lib/containers/myOrders/MyOrders.d.ts +1 -6
- package/lib/containers/myOrders/MyOrders.js +18 -15
- package/lib/containers/myOrders/MyOrders.js.map +1 -1
- package/lib/containers/myOrders/MyOrdersView.d.ts +1 -1
- package/lib/containers/myOrders/MyOrdersView.js +36 -14
- package/lib/containers/myOrders/MyOrdersView.js.map +1 -1
- package/lib/containers/myOrders/components/OrderListItem.js +1 -1
- package/lib/containers/myOrders/components/OrderListItem.js.map +1 -1
- package/lib/containers/myOrders/components/styles.d.ts +4 -0
- package/lib/containers/myOrders/components/styles.js +4 -0
- package/lib/containers/myOrders/components/styles.js.map +1 -1
- package/lib/containers/myOrders/styles.d.ts +19 -2
- package/lib/containers/myOrders/styles.js +20 -2
- package/lib/containers/myOrders/styles.js.map +1 -1
- package/lib/containers/myOrders/types.d.ts +20 -15
- package/lib/containers/purchaseConfirmation/PurchaseConfirmation.d.ts +1 -1
- package/lib/containers/purchaseConfirmation/PurchaseConfirmation.js +2 -2
- package/lib/containers/purchaseConfirmation/PurchaseConfirmation.js.map +1 -1
- package/lib/containers/purchaseConfirmation/PurchaseConfirmationView.js +4 -4
- package/lib/containers/purchaseConfirmation/PurchaseConfirmationView.js.map +1 -1
- package/lib/containers/purchaseConfirmation/types.d.ts +4 -0
- package/lib/containers/tickets/Tickets.d.ts +1 -1
- package/lib/containers/tickets/Tickets.js +22 -17
- package/lib/containers/tickets/Tickets.js.map +1 -1
- package/lib/containers/tickets/TicketsView.d.ts +1 -1
- package/lib/containers/tickets/TicketsView.js +7 -9
- package/lib/containers/tickets/TicketsView.js.map +1 -1
- package/lib/containers/tickets/components/TicketListItem.js +24 -8
- package/lib/containers/tickets/components/TicketListItem.js.map +1 -1
- package/lib/containers/tickets/types.d.ts +15 -2
- package/lib/helpers/Config.d.ts +12 -0
- package/lib/helpers/Config.js +32 -0
- package/lib/helpers/Config.js.map +1 -0
- package/lib/helpers/LocalStorage.d.ts +1 -0
- package/lib/helpers/LocalStorage.js +15 -3
- package/lib/helpers/LocalStorage.js.map +1 -1
- package/lib/helpers/Validators.d.ts +1 -0
- package/lib/helpers/Validators.js +5 -0
- package/lib/helpers/Validators.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/res/colors.d.ts +2 -0
- package/lib/res/colors.js +4 -0
- package/lib/res/colors.js.map +1 -1
- package/lib/res/icons.d.ts +1 -0
- package/lib/res/icons.js +5 -4
- package/lib/res/icons.js.map +1 -1
- package/lib/res/images.js +1 -1
- package/lib/res/images.js.map +1 -1
- package/lib/res/index.d.ts +3 -0
- package/lib/types/IUserProfile.d.ts +1 -1
- package/package.json +10 -2
- package/lib/containers/billingInfo/BillingInfo.d.ts +0 -3
- package/lib/containers/billingInfo/BillingInfo.js +0 -627
- package/lib/containers/billingInfo/BillingInfo.js.map +0 -1
- package/lib/containers/billingInfo/BillingInfoData.d.ts +0 -6
- package/lib/containers/billingInfo/BillingInfoData.js +0 -79
- package/lib/containers/billingInfo/BillingInfoData.js.map +0 -1
- package/lib/containers/billingInfo/BillingInfoView.d.ts +0 -3
- package/lib/containers/billingInfo/BillingInfoView.js +0 -23
- package/lib/containers/billingInfo/BillingInfoView.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tf-checkout-react-native",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "TheTicketFairy ReactNative Checkout library",
|
|
5
5
|
"homepage": "https://github.com/theticketfairy/tf-checkout-react-native",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"android",
|
|
12
12
|
"ios",
|
|
13
13
|
"lib",
|
|
14
|
+
"assets",
|
|
14
15
|
"tf-checkout-react-native.podspec",
|
|
15
16
|
"!android/build",
|
|
16
17
|
"!.DS_Store",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"@babel/core": "7.16.0",
|
|
37
38
|
"@babel/runtime": "7.16.3",
|
|
38
39
|
"@react-native-async-storage/async-storage": "1.15.14",
|
|
40
|
+
"@react-native-clipboard/clipboard": "1.8.5",
|
|
39
41
|
"@react-native-community/datetimepicker": "5.0.2",
|
|
40
42
|
"@react-native-community/eslint-config": "3.0.1",
|
|
41
43
|
"@stripe/stripe-react-native": "0.2.3",
|
|
@@ -45,6 +47,7 @@
|
|
|
45
47
|
"@types/react-test-renderer": "17.0.1",
|
|
46
48
|
"@types/rn-material-ui-textfield": "1.0.2",
|
|
47
49
|
"axios": "0.24.0",
|
|
50
|
+
"axios-retry": "3.2.4",
|
|
48
51
|
"babel-jest": "27.3.1",
|
|
49
52
|
"eslint": "7.14.0",
|
|
50
53
|
"eslint-plugin-simple-import-sort": "7.0.0",
|
|
@@ -54,6 +57,7 @@
|
|
|
54
57
|
"metro-react-native-babel-preset": "0.66.2",
|
|
55
58
|
"react": "17.0.2",
|
|
56
59
|
"react-native": "0.66.3",
|
|
60
|
+
"react-native-fs": "2.18.0",
|
|
57
61
|
"react-native-keyboard-aware-scroll-view": "0.9.5",
|
|
58
62
|
"react-native-modal-datetime-picker": "13.0.0",
|
|
59
63
|
"react-test-renderer": "17.0.2",
|
|
@@ -62,9 +66,13 @@
|
|
|
62
66
|
},
|
|
63
67
|
"peerDependencies": {
|
|
64
68
|
"@react-native-async-storage/async-storage": "*",
|
|
69
|
+
"@react-native-clipboard/clipboard": "*",
|
|
65
70
|
"@stripe/stripe-react-native": "*",
|
|
66
71
|
"react": "*",
|
|
67
|
-
"react-native": "*"
|
|
72
|
+
"react-native": "*",
|
|
73
|
+
"react-native-fs": "*",
|
|
74
|
+
"react-native-modal-datetime-picker": "*",
|
|
75
|
+
"@react-native-community/datetimepicker": "*"
|
|
68
76
|
},
|
|
69
77
|
"jest": {
|
|
70
78
|
"preset": "react-native",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { IBillingInfoProps } from './types';
|
|
2
|
-
declare const BillingInfo: ({ cartProps: { isAgeRequired, isNameRequired }, onRegisterSuccess, onRegisterFail, onCheckoutSuccess, onCheckoutFail, onLoginSuccess, onLoginFail, onFetchUserProfileFail, onFetchUserProfileSuccess, onFetchCartError, styles, texts, customCheckboxText, privacyPolicyLinkStyle, }: IBillingInfoProps) => JSX.Element;
|
|
3
|
-
export default BillingInfo;
|
|
@@ -1,627 +0,0 @@
|
|
|
1
|
-
//@ts-nocheck
|
|
2
|
-
import _every from 'lodash/every';
|
|
3
|
-
import _find from 'lodash/find';
|
|
4
|
-
import _get from 'lodash/get';
|
|
5
|
-
import _map from 'lodash/map';
|
|
6
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { Linking } from 'react-native';
|
|
8
|
-
import { Alert, Text } from 'react-native';
|
|
9
|
-
import { checkoutOrder, fetchCart, fetchCountries, fetchStates, fetchUserProfile, registerNewUser, } from '../../api/ApiClient';
|
|
10
|
-
import Constants from '../../api/Constants';
|
|
11
|
-
import { useDebounced } from '../../helpers/Debounced';
|
|
12
|
-
import { deleteAllData, getData, LocalStorageKeys, } from '../../helpers/LocalStorage';
|
|
13
|
-
import { validateEmail, validateEmpty, validatePasswords, } from '../../helpers/Validators';
|
|
14
|
-
import { formDataInitialState, getCheckoutBody, getRegisterFormData, } from './BillingInfoData';
|
|
15
|
-
import BillingInfoView from './BillingInfoView';
|
|
16
|
-
import s from './styles';
|
|
17
|
-
const BillingInfo = ({ cartProps: { isAgeRequired, isNameRequired }, onRegisterSuccess, onRegisterFail, onCheckoutSuccess, onCheckoutFail, onLoginSuccess, onLoginFail, onFetchUserProfileFail, onFetchUserProfileSuccess, onFetchCartError, styles, texts, customCheckboxText, privacyPolicyLinkStyle, }) => {
|
|
18
|
-
//#region Declare state variables
|
|
19
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
20
|
-
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
21
|
-
const [countries, setCountries] = useState([]);
|
|
22
|
-
const [states, setStates] = useState([]);
|
|
23
|
-
const [isLoginDialogVisible, setIsLoginDialogVisible] = useState(false);
|
|
24
|
-
const [loginMessage, setLoginMessage] = useState('');
|
|
25
|
-
const [userData, setUserData] = useState();
|
|
26
|
-
const [storedToken, setStoredToken] = useState('');
|
|
27
|
-
const [formData, setFormData] = useState(formDataInitialState);
|
|
28
|
-
const { firstName, lastName, email, confirmEmail, password, confirmPassword, phone, street, city, country, zipCode, isSubToNewsletter, ticketHoldersFields, isSubToMarketing, birthday, } = formData;
|
|
29
|
-
const firstNameError = useDebounced(firstName, validateEmpty);
|
|
30
|
-
const lastNameError = useDebounced(lastName, validateEmpty);
|
|
31
|
-
const emailError = useDebounced(email, () => validateEmail(email, confirmEmail));
|
|
32
|
-
const confirmEmailError = useDebounced(confirmEmail, () => validateEmail(confirmEmail, email));
|
|
33
|
-
const passwordError = useDebounced(password, () => validatePasswords(password, confirmPassword));
|
|
34
|
-
const confirmPasswordError = useDebounced(confirmPassword, () => validatePasswords(confirmPassword, password));
|
|
35
|
-
const phoneError = useDebounced(phone, validateEmpty);
|
|
36
|
-
const streetError = useDebounced(street, validateEmpty);
|
|
37
|
-
const cityError = useDebounced(city, validateEmpty);
|
|
38
|
-
const zipCodeError = useDebounced(zipCode, validateEmpty);
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region State setters
|
|
41
|
-
const showLoginDialog = () => setIsLoginDialogVisible(true);
|
|
42
|
-
const hideLoginDialog = () => setIsLoginDialogVisible(false);
|
|
43
|
-
const setInputData = (id, value) => {
|
|
44
|
-
console.log(`Setting InputData for ID ${id} with value ${value}`);
|
|
45
|
-
setFormData({ ...formData, [id]: value });
|
|
46
|
-
};
|
|
47
|
-
const setDatePickerData = (date) => {
|
|
48
|
-
console.log(`Setting DATEPICKER DATA ${date}`);
|
|
49
|
-
setFormData({ ...formData, birthday: date });
|
|
50
|
-
};
|
|
51
|
-
const setTicketHolderData = (index, id, value) => {
|
|
52
|
-
console.log('setTicketHolderData', value);
|
|
53
|
-
const newData = { ...formData };
|
|
54
|
-
const holder = newData.ticketHoldersFields[index];
|
|
55
|
-
holder[`${id}`] = value;
|
|
56
|
-
setFormData(newData);
|
|
57
|
-
};
|
|
58
|
-
const setDropdownData = (id, value) => {
|
|
59
|
-
console.log(`Setting DROPDOWN DATA for ID ${id} with value ${value}`);
|
|
60
|
-
setFormData({ ...formData, [id]: value });
|
|
61
|
-
};
|
|
62
|
-
const setCheckboxData = (id) => {
|
|
63
|
-
console.log(`Setting setCheckboxData DATA for ID ${id}`);
|
|
64
|
-
setFormData({ ...formData, [id]: !_get(formData, id) });
|
|
65
|
-
};
|
|
66
|
-
//#endregion
|
|
67
|
-
// Gets all fields from the form
|
|
68
|
-
const getFormFields = () => {
|
|
69
|
-
const getBirthdayField = () => {
|
|
70
|
-
return isAgeRequired
|
|
71
|
-
? [
|
|
72
|
-
{
|
|
73
|
-
id: 'age',
|
|
74
|
-
fieldType: 'datePicker',
|
|
75
|
-
datePickerProps: {
|
|
76
|
-
text: 'Ticket Holder Age',
|
|
77
|
-
onSelectDate: setDatePickerData,
|
|
78
|
-
selectedDate: birthday,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
]
|
|
82
|
-
: [];
|
|
83
|
-
};
|
|
84
|
-
const getPasswordsFields = () => {
|
|
85
|
-
return userData
|
|
86
|
-
? []
|
|
87
|
-
: [
|
|
88
|
-
{
|
|
89
|
-
fieldType: 'title',
|
|
90
|
-
title: 'Choose a password for your new TICKETFAIRY account',
|
|
91
|
-
titleStyle: {},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: 'password',
|
|
95
|
-
fieldType: 'input',
|
|
96
|
-
inputProps: {
|
|
97
|
-
onTextChanged: setInputData,
|
|
98
|
-
label: 'Password',
|
|
99
|
-
autoCapitalize: 'none',
|
|
100
|
-
secureTextEntry: true,
|
|
101
|
-
value: password,
|
|
102
|
-
error: passwordError,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 'confirmPassword',
|
|
107
|
-
fieldType: 'input',
|
|
108
|
-
inputProps: {
|
|
109
|
-
onTextChanged: setInputData,
|
|
110
|
-
label: 'Confirm Password',
|
|
111
|
-
autoCapitalize: 'none',
|
|
112
|
-
secureTextEntry: true,
|
|
113
|
-
value: confirmPassword,
|
|
114
|
-
error: confirmPasswordError,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
];
|
|
118
|
-
};
|
|
119
|
-
const getTicketHolderFields = () => {
|
|
120
|
-
if (ticketHoldersFields.length === 0) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
const ticketHolder = [
|
|
124
|
-
{
|
|
125
|
-
fieldType: 'header',
|
|
126
|
-
title: 'Ticket Holders',
|
|
127
|
-
},
|
|
128
|
-
];
|
|
129
|
-
for (let i = 0; i < ticketHoldersFields.length; i++) {
|
|
130
|
-
ticketHolder.push({
|
|
131
|
-
fieldType: 'title',
|
|
132
|
-
title: `Ticket holder ${i + 1}`,
|
|
133
|
-
}, {
|
|
134
|
-
id: 'firstName',
|
|
135
|
-
fieldType: 'input',
|
|
136
|
-
inputProps: {
|
|
137
|
-
value: ticketHoldersFields[i].firstName,
|
|
138
|
-
onTextChanged: (key, value) => setTicketHolderData(i, key, value),
|
|
139
|
-
label: 'First Name',
|
|
140
|
-
},
|
|
141
|
-
}, {
|
|
142
|
-
id: 'lastName',
|
|
143
|
-
fieldType: 'input',
|
|
144
|
-
inputProps: {
|
|
145
|
-
value: ticketHoldersFields[i].lastName,
|
|
146
|
-
onTextChanged: (key, value) => setTicketHolderData(i, key, value),
|
|
147
|
-
label: 'Last Name',
|
|
148
|
-
},
|
|
149
|
-
}, {
|
|
150
|
-
id: 'email',
|
|
151
|
-
fieldType: 'input',
|
|
152
|
-
inputProps: {
|
|
153
|
-
value: ticketHoldersFields[i].email,
|
|
154
|
-
onTextChanged: (key, value) => setTicketHolderData(i, key, value),
|
|
155
|
-
keyboardType: 'email-address',
|
|
156
|
-
label: 'Email Address (optional)',
|
|
157
|
-
},
|
|
158
|
-
}, {
|
|
159
|
-
id: 'phone',
|
|
160
|
-
fieldType: 'input',
|
|
161
|
-
inputProps: {
|
|
162
|
-
value: ticketHoldersFields[i].phone,
|
|
163
|
-
onTextChanged: (key, value) => setTicketHolderData(i, key, value),
|
|
164
|
-
keyboardType: 'phone-pad',
|
|
165
|
-
label: 'Phone (optional)',
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
return ticketHolder;
|
|
170
|
-
};
|
|
171
|
-
return [
|
|
172
|
-
{
|
|
173
|
-
fieldType: 'title',
|
|
174
|
-
title: 'Get Your Tickets',
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
fieldType: 'input',
|
|
178
|
-
id: 'firstName',
|
|
179
|
-
inputProps: {
|
|
180
|
-
value: firstName,
|
|
181
|
-
onTextChanged: setInputData,
|
|
182
|
-
label: 'First Name',
|
|
183
|
-
error: firstNameError,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
fieldType: 'input',
|
|
188
|
-
id: 'lastName',
|
|
189
|
-
inputProps: {
|
|
190
|
-
value: lastName,
|
|
191
|
-
onTextChanged: setInputData,
|
|
192
|
-
label: 'Last Name',
|
|
193
|
-
error: lastNameError,
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
fieldType: 'text',
|
|
198
|
-
id: 'notice-email',
|
|
199
|
-
title: "IMPORTANT: Please double check that your email address is correct. It's where we send your confirmation and e-tickets to!",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
fieldType: 'input',
|
|
203
|
-
id: 'email',
|
|
204
|
-
inputProps: {
|
|
205
|
-
value: email,
|
|
206
|
-
onTextChanged: setInputData,
|
|
207
|
-
label: 'Email',
|
|
208
|
-
keyboardType: 'email-address',
|
|
209
|
-
autoCapitalize: 'none',
|
|
210
|
-
autoCorrect: false,
|
|
211
|
-
error: emailError,
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
fieldType: 'input',
|
|
216
|
-
id: 'confirmEmail',
|
|
217
|
-
inputProps: {
|
|
218
|
-
value: confirmEmail,
|
|
219
|
-
onTextChanged: setInputData,
|
|
220
|
-
label: 'Confirm Email',
|
|
221
|
-
keyboardType: 'email-address',
|
|
222
|
-
autoCapitalize: 'none',
|
|
223
|
-
autoCorrect: false,
|
|
224
|
-
error: confirmEmailError,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
...getPasswordsFields(),
|
|
228
|
-
{
|
|
229
|
-
id: 'phone',
|
|
230
|
-
fieldType: 'input',
|
|
231
|
-
inputProps: {
|
|
232
|
-
onTextChanged: setInputData,
|
|
233
|
-
label: 'Phone',
|
|
234
|
-
value: phone,
|
|
235
|
-
keyboardType: 'phone-pad',
|
|
236
|
-
error: phoneError,
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
id: 'street',
|
|
241
|
-
fieldType: 'input',
|
|
242
|
-
inputProps: {
|
|
243
|
-
onTextChanged: setInputData,
|
|
244
|
-
label: 'Billing Street Address',
|
|
245
|
-
value: street,
|
|
246
|
-
error: streetError,
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
id: 'city',
|
|
251
|
-
fieldType: 'input',
|
|
252
|
-
inputProps: {
|
|
253
|
-
onTextChanged: setInputData,
|
|
254
|
-
label: 'City/Suburb',
|
|
255
|
-
value: city,
|
|
256
|
-
error: cityError,
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
id: 'country',
|
|
261
|
-
fieldType: 'dropdown',
|
|
262
|
-
dropdownProps: {
|
|
263
|
-
options: countries,
|
|
264
|
-
selectedOption: country,
|
|
265
|
-
onSelectOption: setDropdownData,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
id: 'zipCode',
|
|
270
|
-
fieldType: 'input',
|
|
271
|
-
inputProps: {
|
|
272
|
-
value: zipCode,
|
|
273
|
-
onTextChanged: setInputData,
|
|
274
|
-
label: 'Post Code/Zip',
|
|
275
|
-
keyboardType: 'number-pad',
|
|
276
|
-
error: zipCodeError,
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
id: 'state',
|
|
281
|
-
fieldType: 'dropdown',
|
|
282
|
-
dropdownProps: {
|
|
283
|
-
options: states,
|
|
284
|
-
selectedOption: formData.state,
|
|
285
|
-
onSelectOption: setDropdownData,
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
...getBirthdayField(),
|
|
289
|
-
{
|
|
290
|
-
id: 'isSubToNewsletter',
|
|
291
|
-
fieldType: 'checkbox',
|
|
292
|
-
checkboxProps: {
|
|
293
|
-
text: 'I would like to be updated on House of X news, events and offers.',
|
|
294
|
-
isActive: isSubToNewsletter,
|
|
295
|
-
onPress: setCheckboxData,
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
id: 'isSubToMarketing',
|
|
300
|
-
fieldType: 'checkbox',
|
|
301
|
-
checkboxProps: {
|
|
302
|
-
text: 'I agree that The Ticket Fairy may use the personal data that I have provided for marketing purposes, such as recommending events that I might be interested in, in accordance with its Privacy Policy.',
|
|
303
|
-
isActive: isSubToMarketing,
|
|
304
|
-
onPress: setCheckboxData,
|
|
305
|
-
customTextComp: (React.createElement(Text, { style: [s.customCheckboxText, customCheckboxText] },
|
|
306
|
-
"I agree that The Ticket Fairy may use the personal data that I have provided for marketing purposes, such as recommending events that I might be interested in, in accordance with its",
|
|
307
|
-
' ',
|
|
308
|
-
React.createElement(Text, { style: [s.privacyPolicyLink, privacyPolicyLinkStyle], onPress: handleOpenPrivacyLink }, "Privacy Policy."))),
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
...getTicketHolderFields(),
|
|
312
|
-
];
|
|
313
|
-
};
|
|
314
|
-
// Sets a Country either from User's Profile Data or from Countries list
|
|
315
|
-
const setSelectedCountry = () => {
|
|
316
|
-
console.log('setSelectedCountry COUNTRIES LENGTH', countries.length);
|
|
317
|
-
if (countries.length === 0) {
|
|
318
|
-
console.log('Not setting country X');
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const countryId = (userData === null || userData === void 0 ? void 0 : userData.country) ? userData.country : countries[0].value;
|
|
322
|
-
const sCountryItem = _find(countries, (item) => item.value === countryId);
|
|
323
|
-
console.log('countryId', countryId);
|
|
324
|
-
console.log('sCountryItem', sCountryItem);
|
|
325
|
-
if (sCountryItem) {
|
|
326
|
-
setFormData({ ...formData, country: sCountryItem });
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
const setSelectedState = useCallback(() => {
|
|
330
|
-
console.log('setSelectedState', states);
|
|
331
|
-
if (states.length === 0) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
const foundId = (userData === null || userData === void 0 ? void 0 : userData.stateId) ? userData.stateId : states[0].value;
|
|
335
|
-
console.log('foundId state', foundId);
|
|
336
|
-
const sStateItem = _find(states, (item) => item.value === foundId);
|
|
337
|
-
console.log('sStateItem', sStateItem);
|
|
338
|
-
if (sStateItem) {
|
|
339
|
-
setFormData({ ...formData, state: sStateItem });
|
|
340
|
-
}
|
|
341
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
342
|
-
}, [states, userData === null || userData === void 0 ? void 0 : userData.state]);
|
|
343
|
-
//#region API calls
|
|
344
|
-
// If there is already an AccessToken stored we can directly request User Data
|
|
345
|
-
const fetchUserDataAsync = async (accessToken) => {
|
|
346
|
-
if (!accessToken) {
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
const { userProfile: userProfileData, error: userDataError } = await fetchUserProfile(accessToken);
|
|
350
|
-
if (userDataError) {
|
|
351
|
-
await deleteAllData();
|
|
352
|
-
handleOnFetchUserDataFail(userDataError);
|
|
353
|
-
setUserData(undefined);
|
|
354
|
-
}
|
|
355
|
-
if (userProfileData) {
|
|
356
|
-
handleOnFetchUserDataSuccess(userProfileData);
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
const fetchCartAsync = async () => {
|
|
360
|
-
const { data: cartData, error: cartError } = await fetchCart();
|
|
361
|
-
if (cartError) {
|
|
362
|
-
Alert.alert('', cartError);
|
|
363
|
-
if (onFetchCartError) {
|
|
364
|
-
onFetchCartError(cartError);
|
|
365
|
-
}
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
let ticketQuantity = parseInt(cartData.quantity, 10);
|
|
369
|
-
// Ticket holders initial data
|
|
370
|
-
const newTicketHolderFields = [];
|
|
371
|
-
for (let i = 0; i < ticketQuantity; i++) {
|
|
372
|
-
newTicketHolderFields.push({
|
|
373
|
-
firstName: i === 0 && userData ? userData.firstName : '',
|
|
374
|
-
lastName: i === 0 && userData ? userData.lastName : '',
|
|
375
|
-
email: i === 0 && userData ? userData.email : '',
|
|
376
|
-
phone: i === 0 && userData ? userData.phone : '',
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
setFormData({
|
|
380
|
-
...formData,
|
|
381
|
-
ticketHoldersFields: newTicketHolderFields,
|
|
382
|
-
});
|
|
383
|
-
};
|
|
384
|
-
const fetchCountriesAsync = async () => {
|
|
385
|
-
setIsLoading(true);
|
|
386
|
-
const { data: countriesData, error: countriesError } = await fetchCountries();
|
|
387
|
-
console.log('fetchCountriesAsync countriesResponse', countriesData);
|
|
388
|
-
setIsLoading(false);
|
|
389
|
-
if (countriesError) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const parsedCountries = _map(countriesData, (item, index) => {
|
|
393
|
-
return { label: item, value: index };
|
|
394
|
-
});
|
|
395
|
-
setCountries(parsedCountries);
|
|
396
|
-
};
|
|
397
|
-
const fetchStatesAsync = async (selectedCountryId) => {
|
|
398
|
-
setIsLoading(true);
|
|
399
|
-
const { data: statesData, error: statesError } = await fetchStates(selectedCountryId);
|
|
400
|
-
setIsLoading(false);
|
|
401
|
-
if (statesError) {
|
|
402
|
-
Alert.alert('', statesError);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const parsedStates = _map(statesData, (item, index) => {
|
|
406
|
-
return { label: item, value: index };
|
|
407
|
-
});
|
|
408
|
-
setStates(parsedStates);
|
|
409
|
-
};
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region UseEffects
|
|
412
|
-
//Initial useEffect, to fetch Cart and Countries list.
|
|
413
|
-
useEffect(() => {
|
|
414
|
-
const fetchInitialData = async () => {
|
|
415
|
-
setIsLoading(true);
|
|
416
|
-
const tkn = await getData(LocalStorageKeys.ACCESS_TOKEN);
|
|
417
|
-
console.log('tkn', tkn);
|
|
418
|
-
if (tkn) {
|
|
419
|
-
setStoredToken(tkn);
|
|
420
|
-
}
|
|
421
|
-
await fetchCartAsync();
|
|
422
|
-
setIsLoading(false);
|
|
423
|
-
};
|
|
424
|
-
fetchInitialData();
|
|
425
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
426
|
-
}, []);
|
|
427
|
-
// Fetch userData
|
|
428
|
-
useEffect(() => {
|
|
429
|
-
const fetchUserData = async () => {
|
|
430
|
-
console.log('.fetchUserData.');
|
|
431
|
-
setIsLoading(true);
|
|
432
|
-
await fetchUserDataAsync(storedToken);
|
|
433
|
-
setIsLoading(false);
|
|
434
|
-
};
|
|
435
|
-
if (ticketHoldersFields.length > 0 && storedToken && !userData) {
|
|
436
|
-
fetchUserData();
|
|
437
|
-
}
|
|
438
|
-
else if (ticketHoldersFields.length > 0 && !storedToken) {
|
|
439
|
-
fetchCountriesAsync();
|
|
440
|
-
}
|
|
441
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
442
|
-
}, [ticketHoldersFields, storedToken, userData]);
|
|
443
|
-
// Fetch Countries
|
|
444
|
-
useEffect(() => {
|
|
445
|
-
const getCountries = async () => {
|
|
446
|
-
await fetchCountriesAsync();
|
|
447
|
-
};
|
|
448
|
-
if (countries.length === 0 && userData) {
|
|
449
|
-
getCountries();
|
|
450
|
-
}
|
|
451
|
-
}, [userData, countries]);
|
|
452
|
-
//Once Countries is fullfilled, useEffect to set Country item.
|
|
453
|
-
useEffect(() => {
|
|
454
|
-
console.log('USE COUNTRIES', countries);
|
|
455
|
-
setSelectedCountry();
|
|
456
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
457
|
-
}, [countries]);
|
|
458
|
-
// Fetch States list.
|
|
459
|
-
useEffect(() => {
|
|
460
|
-
console.log('COUNTRY WAS SET TO: ', country);
|
|
461
|
-
if (country === null || country === void 0 ? void 0 : country.value) {
|
|
462
|
-
console.log('Gona FETCH States');
|
|
463
|
-
fetchStatesAsync(country.value);
|
|
464
|
-
}
|
|
465
|
-
}, [country, userData]);
|
|
466
|
-
// Set State item.
|
|
467
|
-
useEffect(() => {
|
|
468
|
-
if (countries.length > 0 && states && states.length > 1) {
|
|
469
|
-
console.log('Gonna set STATE', states);
|
|
470
|
-
setSelectedState();
|
|
471
|
-
}
|
|
472
|
-
}, [countries, states, setSelectedState, userData]);
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region Handlers
|
|
475
|
-
const handleOpenPrivacyLink = async () => {
|
|
476
|
-
const canOpenLink = await Linking.canOpenURL(Constants.PRIVACY_POLICY_LINK);
|
|
477
|
-
if (canOpenLink) {
|
|
478
|
-
await Linking.openURL(Constants.PRIVACY_POLICY_LINK);
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
const handleOnFetchUserDataSuccess = (userProfile) => {
|
|
482
|
-
console.log('handleOnFetchUserDataSuccess', userProfile);
|
|
483
|
-
if (onFetchUserProfileSuccess) {
|
|
484
|
-
onFetchUserProfileSuccess(userProfile);
|
|
485
|
-
}
|
|
486
|
-
setUserData(userProfile);
|
|
487
|
-
console.log('formData.ticketHoldersFields', ticketHoldersFields);
|
|
488
|
-
const newTicketHolderFields = [...ticketHoldersFields];
|
|
489
|
-
console.log('******* newTicketHolderFields ****', newTicketHolderFields);
|
|
490
|
-
newTicketHolderFields[0] = {
|
|
491
|
-
email: userProfile.email,
|
|
492
|
-
firstName: userProfile.firstName,
|
|
493
|
-
lastName: userProfile.lastName,
|
|
494
|
-
phone: userProfile.phone,
|
|
495
|
-
};
|
|
496
|
-
setFormData({
|
|
497
|
-
...formData,
|
|
498
|
-
firstName: userProfile.firstName,
|
|
499
|
-
lastName: userProfile.lastName,
|
|
500
|
-
email: userProfile.email,
|
|
501
|
-
confirmEmail: userProfile.email,
|
|
502
|
-
phone: userProfile.phone,
|
|
503
|
-
street: userProfile.streetAddress,
|
|
504
|
-
zipCode: userProfile.zipCode,
|
|
505
|
-
city: userProfile.city,
|
|
506
|
-
ticketHoldersFields: newTicketHolderFields,
|
|
507
|
-
});
|
|
508
|
-
};
|
|
509
|
-
const handleOnLogoutSuccess = () => {
|
|
510
|
-
setStoredToken('');
|
|
511
|
-
setUserData(undefined);
|
|
512
|
-
setTimeout(() => {
|
|
513
|
-
setFormData(formDataInitialState);
|
|
514
|
-
}, 200);
|
|
515
|
-
};
|
|
516
|
-
const handleOnLoginSuccess = (userProfile, accessToken) => {
|
|
517
|
-
console.log('\x1b[34m%s\x1b[0m', 'BillingInfo.tsx line:609 handleOnLoginSuccessful');
|
|
518
|
-
setStoredToken(accessToken);
|
|
519
|
-
onLoginSuccess({
|
|
520
|
-
accessToken: accessToken,
|
|
521
|
-
userData: userProfile,
|
|
522
|
-
});
|
|
523
|
-
handleOnFetchUserDataSuccess(userProfile);
|
|
524
|
-
};
|
|
525
|
-
const handleOnLoginFail = (error) => {
|
|
526
|
-
if (onLoginFail) {
|
|
527
|
-
onLoginFail(error);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
const handleOnFetchUserDataFail = (error) => {
|
|
531
|
-
if (onFetchUserProfileFail) {
|
|
532
|
-
onFetchUserProfileFail(error);
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
const handleOnSubmit = async () => {
|
|
536
|
-
setIsSubmitLoading(true);
|
|
537
|
-
console.log('UserData', userData);
|
|
538
|
-
const checkoutBody = getCheckoutBody(formData, userData, isAgeRequired);
|
|
539
|
-
console.log('CheckoutBody', checkoutBody);
|
|
540
|
-
if (userData && storedToken) {
|
|
541
|
-
await performCheckout(checkoutBody);
|
|
542
|
-
}
|
|
543
|
-
else {
|
|
544
|
-
await performNewUserRegister(checkoutBody);
|
|
545
|
-
}
|
|
546
|
-
setIsSubmitLoading(false);
|
|
547
|
-
};
|
|
548
|
-
//#endregion
|
|
549
|
-
const isDataValid = () => {
|
|
550
|
-
if (validateEmpty(firstName) ||
|
|
551
|
-
validateEmpty(lastName) ||
|
|
552
|
-
validateEmail(email, confirmEmail) ||
|
|
553
|
-
validateEmail(confirmEmail, email) ||
|
|
554
|
-
validateEmpty(street) ||
|
|
555
|
-
validateEmpty(phone) ||
|
|
556
|
-
validateEmpty(city) ||
|
|
557
|
-
validateEmpty(zipCode)) {
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
if (isAgeRequired && !birthday) {
|
|
561
|
-
return false;
|
|
562
|
-
}
|
|
563
|
-
const thValid = _map(ticketHoldersFields, (th) => validateEmpty(th.firstName) || validateEmpty(th.lastName));
|
|
564
|
-
return _every(thValid, (itm) => itm === '');
|
|
565
|
-
};
|
|
566
|
-
const handleOnRegisterFail = (rawError) => {
|
|
567
|
-
if (onRegisterFail) {
|
|
568
|
-
onRegisterFail(rawError);
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
const performCheckout = async (checkoutBody, pToken) => {
|
|
572
|
-
console.log('performCheckout - with storedToken', storedToken);
|
|
573
|
-
console.log('performCheckout - with pToken', pToken);
|
|
574
|
-
const { error: checkoutError, data: checkoutData } = await checkoutOrder(checkoutBody, pToken || storedToken);
|
|
575
|
-
console.log('performCheckout Error', checkoutError);
|
|
576
|
-
console.log('performCheckout Data', checkoutData);
|
|
577
|
-
if (checkoutError) {
|
|
578
|
-
Alert.alert('', checkoutError);
|
|
579
|
-
if (onCheckoutFail) {
|
|
580
|
-
onCheckoutFail(checkoutError);
|
|
581
|
-
}
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const data = {
|
|
585
|
-
id: checkoutData.data.data.attributes.id,
|
|
586
|
-
hash: checkoutData.data.data.attributes.hash,
|
|
587
|
-
total: checkoutData.data.data.attributes.total,
|
|
588
|
-
status: checkoutData.data.data.attributes.status,
|
|
589
|
-
};
|
|
590
|
-
if (onCheckoutSuccess) {
|
|
591
|
-
onCheckoutSuccess(data);
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
const performNewUserRegister = async (checkoutBody) => {
|
|
595
|
-
console.log('performNewUserRegister', checkoutBody);
|
|
596
|
-
const registerForm = getRegisterFormData(checkoutBody);
|
|
597
|
-
console.log('registerForm', registerForm);
|
|
598
|
-
const { data: registerResponseData, error: registerResponseError } = await registerNewUser(registerForm);
|
|
599
|
-
if (registerResponseError) {
|
|
600
|
-
if (registerResponseError.isAlreadyRegistered) {
|
|
601
|
-
setLoginMessage(registerResponseError.message);
|
|
602
|
-
showLoginDialog();
|
|
603
|
-
return handleOnRegisterFail(registerResponseError.raw);
|
|
604
|
-
}
|
|
605
|
-
handleOnRegisterFail(registerResponseError.raw);
|
|
606
|
-
return Alert.alert('', registerResponseError.message);
|
|
607
|
-
}
|
|
608
|
-
if (!registerResponseData) {
|
|
609
|
-
handleOnRegisterFail('Register returned no data');
|
|
610
|
-
return Alert.alert('', 'Register returned no data');
|
|
611
|
-
}
|
|
612
|
-
const tokens = {
|
|
613
|
-
accessToken: registerResponseData.access_token,
|
|
614
|
-
refreshToken: registerResponseData.refresh_token,
|
|
615
|
-
};
|
|
616
|
-
setStoredToken(tokens.accessToken);
|
|
617
|
-
if (onRegisterSuccess) {
|
|
618
|
-
onRegisterSuccess(tokens);
|
|
619
|
-
}
|
|
620
|
-
console.log('Tokens', tokens);
|
|
621
|
-
performCheckout(checkoutBody, tokens.accessToken);
|
|
622
|
-
};
|
|
623
|
-
const formFields = getFormFields();
|
|
624
|
-
return (React.createElement(BillingInfoView, { formFields: formFields, isLoading: isLoading, onSubmit: handleOnSubmit, onLoginSuccessful: handleOnLoginSuccess, isDataValid: isDataValid(), isLoginDialogVisible: isLoginDialogVisible, showLoginDialog: showLoginDialog, hideLoginDialog: hideLoginDialog, loginMessage: loginMessage, onLoginFail: handleOnLoginFail, userProfile: userData, isSubmitLoading: isSubmitLoading, onLogoutSuccess: handleOnLogoutSuccess, styles: styles, texts: texts }));
|
|
625
|
-
};
|
|
626
|
-
export default BillingInfo;
|
|
627
|
-
//# sourceMappingURL=BillingInfo.js.map
|