tf-checkout-react 1.0.13 → 1.0.17

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.
@@ -1,6 +1,7 @@
1
1
  import React, { useState, useEffect, useRef } from 'react';
2
2
  import { Formik, Form, Field } from 'formik';
3
3
  import TextField$1 from '@mui/material/TextField';
4
+ import Button from '@mui/material/Button';
4
5
  import _identity from 'lodash-es/identity';
5
6
  import _map from 'lodash-es/map';
6
7
  import _get from 'lodash-es/get';
@@ -941,27 +942,13 @@ var postOnCheckout = function postOnCheckout(data, accessToken) {
941
942
  return res;
942
943
  };
943
944
  var authorize = function authorize(data) {
944
- return axios({
945
- method: 'post',
946
- url: 'https://www.ticketfairy.com/api/v1/oauth/authorize-rn?client_id=4792a61f2fcb49197ab4c2d2f44df570',
947
- data: data,
948
- headers: {
949
- 'Content-Type': 'multipart/form-data'
950
- }
951
- });
945
+ return publicRequest.post('/v1/oauth/authorize-rn?client_id=4792a61f2fcb49197ab4c2d2f44df570', data);
952
946
  };
953
947
  var register = function register(data) {
954
948
  return publicRequest.post('/v1/oauth/register-rn', data);
955
949
  };
956
950
  var getAccessToken = function getAccessToken(data) {
957
- return axios({
958
- method: 'post',
959
- url: 'https://www.ticketfairy.com/api/v1/oauth/access_token',
960
- data: data,
961
- headers: {
962
- 'Content-Type': 'multipart/form-data'
963
- }
964
- });
951
+ return publicRequest.post('/v1/oauth/access_token', data);
965
952
  };
966
953
  var getPaymentData = function getPaymentData(hash) {
967
954
  var response = publicRequest.get("v1/order/" + hash + "/review/")["catch"](function (error) {
@@ -1063,24 +1050,28 @@ var LoginModal = function LoginModal(_ref) {
1063
1050
  last_name: profileSpecifiedData.lastName,
1064
1051
  email: profileSpecifiedData.email
1065
1052
  };
1066
- localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1067
- localStorage.setItem('access_token', accessToken);
1053
+
1054
+ if (typeof window !== 'undefined') {
1055
+ window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1056
+ window.localStorage.setItem('access_token', accessToken);
1057
+ }
1058
+
1068
1059
  onLogin();
1069
- _context.next = 33;
1060
+ _context.next = 32;
1070
1061
  break;
1071
1062
 
1072
- case 29:
1073
- _context.prev = 29;
1063
+ case 28:
1064
+ _context.prev = 28;
1074
1065
  _context.t0 = _context["catch"](1);
1075
1066
  _error = _context.t0.response.data.message || 'Error';
1076
1067
  setError(_error);
1077
1068
 
1078
- case 33:
1069
+ case 32:
1079
1070
  case "end":
1080
1071
  return _context.stop();
1081
1072
  }
1082
1073
  }
1083
- }, _callee, null, [[1, 29]]);
1074
+ }, _callee, null, [[1, 28]]);
1084
1075
  }));
1085
1076
 
1086
1077
  function onSubmit(_x) {
@@ -1196,11 +1187,15 @@ var RegisterModal = function RegisterModal(_ref) {
1196
1187
  last_name: profileSpecifiedData.lastName,
1197
1188
  email: profileSpecifiedData.email
1198
1189
  };
1199
- localStorage.setItem('access_token', access_token);
1200
- localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1190
+
1191
+ if (typeof window !== 'undefined') {
1192
+ window.localStorage.setItem('access_token', access_token);
1193
+ window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1194
+ }
1195
+
1201
1196
  onClose();
1202
1197
 
1203
- case 22:
1198
+ case 21:
1204
1199
  case "end":
1205
1200
  return _context.stop();
1206
1201
  }
@@ -1317,7 +1312,9 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1317
1312
  _ref$buttonName = _ref.buttonName,
1318
1313
  buttonName = _ref$buttonName === void 0 ? 'Submit' : _ref$buttonName,
1319
1314
  _ref$handleSubmit = _ref.handleSubmit,
1320
- handleSubmit = _ref$handleSubmit === void 0 ? _identity : _ref$handleSubmit;
1315
+ handleSubmit = _ref$handleSubmit === void 0 ? _identity : _ref$handleSubmit,
1316
+ _ref$theme = _ref.theme,
1317
+ theme = _ref$theme === void 0 ? 'light' : _ref$theme;
1321
1318
  var userData = typeof window !== 'undefined' && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
1322
1319
  var access_token = typeof window !== 'undefined' && window.localStorage.getItem('access_token') ? window.localStorage.getItem('access_token') || '' : '';
1323
1320
 
@@ -1395,7 +1392,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1395
1392
  }),
1396
1393
  onSubmit: function () {
1397
1394
  var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(values, formikHelpers) {
1398
- var _holderAge, bodyFormData, resRegister, access_token_register, profileData, profileSpecifiedData, profileDataObj, holderAge, res, error;
1395
+ var _holderAge, _res, bodyFormData, resRegister, access_token_register, profileData, profileSpecifiedData, profileDataObj, holderAge, res, error;
1399
1396
 
1400
1397
  return runtime_1.wrap(function _callee2$(_context2) {
1401
1398
  while (1) {
@@ -1404,7 +1401,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1404
1401
  _context2.prev = 0;
1405
1402
 
1406
1403
  if (!isLoggedIn) {
1407
- _context2.next = 7;
1404
+ _context2.next = 9;
1408
1405
  break;
1409
1406
  }
1410
1407
 
@@ -1427,10 +1424,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1427
1424
  }, access_token);
1428
1425
 
1429
1426
  case 5:
1430
- window.location.replace('/checkout');
1427
+ _res = _context2.sent;
1428
+ handleSubmit(values, formikHelpers, _res);
1429
+ window.location.replace('/billing/checkout');
1431
1430
  return _context2.abrupt("return");
1432
1431
 
1433
- case 7:
1432
+ case 9:
1434
1433
  bodyFormData = new FormData();
1435
1434
  bodyFormData.append('first_name', values.firstName);
1436
1435
  bodyFormData.append('last_name', values.lastName);
@@ -1439,17 +1438,17 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1439
1438
  bodyFormData.append('password_confirmation', values.confirmPassword);
1440
1439
  bodyFormData.append('client_id', '4792a61f2fcb49197ab4c2d2f44df570');
1441
1440
  bodyFormData.append('client_secret', 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9');
1442
- _context2.next = 17;
1441
+ _context2.next = 19;
1443
1442
  return register(bodyFormData);
1444
1443
 
1445
- case 17:
1444
+ case 19:
1446
1445
  resRegister = _context2.sent;
1447
1446
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
1448
1447
  handleSetAccessToken(access_token_register);
1449
- _context2.next = 22;
1448
+ _context2.next = 24;
1450
1449
  return getProfileData(access_token_register);
1451
1450
 
1452
- case 22:
1451
+ case 24:
1453
1452
  profileData = _context2.sent;
1454
1453
  profileSpecifiedData = _get(profileData, 'data.data');
1455
1454
  profileDataObj = {
@@ -1458,10 +1457,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1458
1457
  last_name: profileSpecifiedData.lastName,
1459
1458
  email: profileSpecifiedData.email
1460
1459
  };
1461
- localStorage.setItem('access_token', access_token_register);
1462
- localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1460
+
1461
+ if (typeof window !== 'undefined') {
1462
+ window.localStorage.setItem('access_token', access_token_register);
1463
+ window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1464
+ }
1465
+
1463
1466
  holderAge = new Date(values.holderAge);
1464
- _context2.next = 30;
1467
+ _context2.next = 31;
1465
1468
  return postOnCheckout({
1466
1469
  attributes: {
1467
1470
  email: values.email,
@@ -1478,14 +1481,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1478
1481
  }
1479
1482
  }, access_token_register);
1480
1483
 
1481
- case 30:
1484
+ case 31:
1482
1485
  res = _context2.sent;
1483
1486
  handleSubmit(values, formikHelpers, res);
1484
- _context2.next = 38;
1487
+ _context2.next = 39;
1485
1488
  break;
1486
1489
 
1487
- case 34:
1488
- _context2.prev = 34;
1490
+ case 35:
1491
+ _context2.prev = 35;
1489
1492
  _context2.t0 = _context2["catch"](0);
1490
1493
  error = _context2.t0.response.data.message;
1491
1494
 
@@ -1494,12 +1497,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1494
1497
  setShowModalLogin(true);
1495
1498
  }
1496
1499
 
1497
- case 38:
1500
+ case 39:
1498
1501
  case "end":
1499
1502
  return _context2.stop();
1500
1503
  }
1501
1504
  }
1502
- }, _callee2, null, [[0, 34]]);
1505
+ }, _callee2, null, [[0, 35]]);
1503
1506
  }));
1504
1507
 
1505
1508
  function onSubmit(_x, _x2) {
@@ -1512,7 +1515,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1512
1515
  return React.createElement(Form, {
1513
1516
  onSubmit: props.handleSubmit
1514
1517
  }, React.createElement("div", {
1515
- className: "billing-info-container"
1518
+ className: "billing-info-container " + theme
1516
1519
  }, !isLoggedIn && React.createElement("div", {
1517
1520
  className: "account-actions-block"
1518
1521
  }, React.createElement("div", null, "Got a Restless Nites account?"), React.createElement("div", null, "Login & skip ahead:"), React.createElement("div", {
@@ -1556,14 +1559,25 @@ var BillingInfoContainer = function BillingInfoContainer(_ref) {
1556
1559
  type: element.type,
1557
1560
  fullWidth: true,
1558
1561
  error: !!meta.error && meta.touched,
1559
- helperText: meta.touched && meta.error
1562
+ helperText: meta.touched && meta.error,
1563
+ InputLabelProps: element.type === 'date' ? {
1564
+ shrink: true
1565
+ } : {}
1560
1566
  }, field));
1561
1567
  }));
1562
1568
  }));
1563
1569
  }));
1564
- }), React.createElement("button", {
1565
- type: "submit"
1566
- }, buttonName)));
1570
+ }), React.createElement("div", {
1571
+ style: {
1572
+ display: 'flex',
1573
+ padding: 20,
1574
+ justifyContent: 'center'
1575
+ }
1576
+ }, React.createElement(Button, {
1577
+ type: "submit",
1578
+ variant: "contained",
1579
+ className: "login-register-button"
1580
+ }, buttonName))));
1567
1581
  }), showModalLogin && React.createElement(LoginModal, {
1568
1582
  onClose: function onClose() {
1569
1583
  setShowModalLogin(false);
@@ -1791,26 +1805,27 @@ var PaymentContainer = function PaymentContainer(_ref) {
1791
1805
 
1792
1806
  case 8:
1793
1807
  paymentResponse = _context2.sent;
1808
+ console.log(paymentResponse);
1794
1809
 
1795
1810
  if (paymentResponse.status === 200) {
1796
1811
  handlePayment(paymentResponse);
1797
1812
  }
1798
1813
 
1799
- _context2.next = 15;
1814
+ _context2.next = 16;
1800
1815
  break;
1801
1816
 
1802
- case 12:
1803
- _context2.prev = 12;
1817
+ case 13:
1818
+ _context2.prev = 13;
1804
1819
  _context2.t0 = _context2["catch"](1);
1805
1820
  //Handle payment errors
1806
1821
  console.log(_context2.t0);
1807
1822
 
1808
- case 15:
1823
+ case 16:
1809
1824
  case "end":
1810
1825
  return _context2.stop();
1811
1826
  }
1812
1827
  }
1813
- }, _callee2, null, [[1, 12]]);
1828
+ }, _callee2, null, [[1, 13]]);
1814
1829
  }));
1815
1830
 
1816
1831
  return function handlePaymentMiddleWare(_x) {