tf-checkout-react 1.0.74 → 1.0.78

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 (47) hide show
  1. package/dist/api/index.d.ts +2 -0
  2. package/dist/components/billing-info-container/index.d.ts +9 -3
  3. package/dist/components/billing-info-container/utils.d.ts +1 -0
  4. package/dist/components/common/FormikPhoneNumberField.d.ts +1 -1
  5. package/dist/components/confirmationContainer/index.d.ts +2 -1
  6. package/dist/components/countdown/index.d.ts +11 -0
  7. package/dist/components/orderDetailsContainer/ticketsTable.d.ts +13 -1
  8. package/dist/components/paymentContainer/index.d.ts +8 -3
  9. package/dist/components/stripePayment/index.d.ts +2 -1
  10. package/dist/components/ticketsContainer/index.d.ts +3 -1
  11. package/dist/components/waitingList/index.d.ts +1 -2
  12. package/dist/tf-checkout-react.cjs.development.js +549 -218
  13. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  14. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  15. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  16. package/dist/tf-checkout-react.esm.js +541 -210
  17. package/dist/tf-checkout-react.esm.js.map +1 -1
  18. package/dist/tf-checkout-styles.css +1 -1
  19. package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +7 -0
  20. package/dist/utils/downloadPDF.d.ts +1 -0
  21. package/dist/utils/index.d.ts +2 -0
  22. package/dist/utils/setConfigs.d.ts +2 -1
  23. package/package.json +2 -1
  24. package/src/api/index.ts +15 -20
  25. package/src/components/billing-info-container/index.tsx +39 -36
  26. package/src/components/billing-info-container/utils.ts +2 -1
  27. package/src/components/common/CheckboxField.tsx +15 -8
  28. package/src/components/common/CustomField.tsx +7 -0
  29. package/src/components/common/FormikPhoneNumberField.tsx +11 -1
  30. package/src/components/common/SelectField.tsx +5 -1
  31. package/src/components/confirmationContainer/index.tsx +59 -43
  32. package/src/components/countdown/index.tsx +89 -0
  33. package/src/components/countdown/style.css +10 -0
  34. package/src/components/loginModal/index.tsx +2 -0
  35. package/src/components/orderDetailsContainer/ticketsTable.tsx +66 -60
  36. package/src/components/paymentContainer/index.tsx +8 -10
  37. package/src/components/stripePayment/index.tsx +24 -16
  38. package/src/components/ticketsContainer/PromoCodeSection.tsx +3 -2
  39. package/src/components/ticketsContainer/TicketsSection.tsx +10 -6
  40. package/src/components/ticketsContainer/index.tsx +193 -42
  41. package/src/components/ticketsContainer/style.css +7 -0
  42. package/src/components/waitingList/index.tsx +3 -9
  43. package/src/components/waitingList/style.css +4 -2
  44. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +51 -0
  45. package/src/utils/downloadPDF.tsx +22 -0
  46. package/src/utils/index.ts +2 -0
  47. package/src/utils/setConfigs.ts +7 -2
@@ -1,6 +1,6 @@
1
1
  import React, { Component, useState, useCallback, useEffect, useRef, Fragment } from 'react';
2
2
  import { connect, Formik, Form, Field } from 'formik';
3
- import LoadingButton from '@mui/lab/LoadingButton';
3
+ import Button from '@mui/material/Button';
4
4
  import _identity from 'lodash-es/identity';
5
5
  import _map from 'lodash-es/map';
6
6
  import _get from 'lodash-es/get';
@@ -14,6 +14,7 @@ import _flatMapDeep from 'lodash-es/flatMapDeep';
14
14
  import _isArray from 'lodash-es/isArray';
15
15
  import { nanoid } from 'nanoid';
16
16
  import TextField$1 from '@mui/material/TextField';
17
+ import { useTheme } from '@mui/styles';
17
18
  import FormGroup from '@mui/material/FormGroup';
18
19
  import FormControlLabel from '@mui/material/FormControlLabel';
19
20
  import Checkbox from '@mui/material/Checkbox';
@@ -35,8 +36,8 @@ import _sortBy from 'lodash-es/sortBy';
35
36
  import _has from 'lodash-es/has';
36
37
  import FormControl$1 from '@mui/material/FormControl';
37
38
  import MenuItem from '@mui/material/MenuItem';
38
- import Button from '@mui/material/Button';
39
39
  import SVG from 'react-inlinesvg';
40
+ import moment from 'moment-timezone';
40
41
  import Table from '@mui/material/Table';
41
42
  import TableBody from '@mui/material/TableBody';
42
43
  import TableCell from '@mui/material/TableCell';
@@ -925,6 +926,10 @@ var setConfigs = function setConfigs(configs) {
925
926
  });
926
927
 
927
928
  publicRequest.setBaseUrl(CONFIGS.BASE_URL);
929
+
930
+ if (CONFIGS.X_SOURCE_ORIGIN) {
931
+ setXSourceOrigin(CONFIGS.X_SOURCE_ORIGIN);
932
+ }
928
933
  };
929
934
 
930
935
  var getQueryVariable = function getQueryVariable(variable) {
@@ -983,9 +988,85 @@ var ErrorFocusInternal = /*#__PURE__*/function (_Component) {
983
988
 
984
989
  var ErrorFocus = /*#__PURE__*/connect(ErrorFocusInternal);
985
990
 
991
+ var downloadPDF = function downloadPDF(pdfUrl) {
992
+ if (typeof window === 'undefined') return;
993
+ var accessToken = localStorage.getItem('access_token');
994
+ if (!accessToken) return;
995
+ fetch(pdfUrl, {
996
+ headers: {
997
+ Authorization: "Bearer " + accessToken
998
+ }
999
+ }).then( /*#__PURE__*/function () {
1000
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(response) {
1001
+ var blobValue;
1002
+ return runtime_1.wrap(function _callee$(_context) {
1003
+ while (1) {
1004
+ switch (_context.prev = _context.next) {
1005
+ case 0:
1006
+ _context.next = 2;
1007
+ return response.blob();
1008
+
1009
+ case 2:
1010
+ blobValue = _context.sent;
1011
+ return _context.abrupt("return", blobValue);
1012
+
1013
+ case 4:
1014
+ case "end":
1015
+ return _context.stop();
1016
+ }
1017
+ }
1018
+ }, _callee);
1019
+ }));
1020
+
1021
+ return function (_x) {
1022
+ return _ref.apply(this, arguments);
1023
+ };
1024
+ }()).then(function (blobValue) {
1025
+ var file = new Blob([blobValue], {
1026
+ type: 'application/pdf'
1027
+ });
1028
+ var fileURL = URL.createObjectURL(file);
1029
+ window.open(fileURL);
1030
+ });
1031
+ };
1032
+
1033
+ var createCheckoutDataBodyWithDefaultHolder = function createCheckoutDataBodyWithDefaultHolder(ticketsQuantity, logedInValues) {
1034
+ var ticket_holders = [];
1035
+ var first_name = _get(logedInValues, 'firstName') || _get(logedInValues, 'first_name') || '';
1036
+ var last_name = _get(logedInValues, 'lastName', '') || _get(logedInValues, 'last_name') || '';
1037
+
1038
+ var phone = _get(logedInValues, 'phone', '');
1039
+
1040
+ var email = _get(logedInValues, 'email', '');
1041
+
1042
+ for (var i = 0; i <= ticketsQuantity - 1; i++) {
1043
+ var individualHolder = i ? {
1044
+ first_name: '',
1045
+ last_name: '',
1046
+ phone: '',
1047
+ email: ''
1048
+ } : {
1049
+ first_name: first_name,
1050
+ last_name: last_name,
1051
+ phone: phone,
1052
+ email: email
1053
+ };
1054
+ ticket_holders.push(individualHolder);
1055
+ }
1056
+
1057
+ var body = {
1058
+ attributes: _extends({}, logedInValues, {
1059
+ email: email,
1060
+ confirm_email: email,
1061
+ first_name: first_name,
1062
+ last_name: last_name,
1063
+ ticket_holders: ticket_holders
1064
+ })
1065
+ };
1066
+ return body;
1067
+ };
1068
+
986
1069
  var isWindowDefined = typeof window !== 'undefined';
987
- var discardedOrigins = ['http://localhost', 'gtsb.io', 'gatsbyjs.io', 'https://www.houseofx.nyc', 'https://tickets-staging.houseofx.nyc'];
988
- var origin = isWindowDefined && window.location.origin;
989
1070
  var ttfHeaders = {
990
1071
  Accept: 'application/vnd.api+json',
991
1072
  'Content-Type': 'application/vnd.api+json'
@@ -995,12 +1076,6 @@ if (isWindowDefined && localStorage.getItem('auth_guest_token')) {
995
1076
  ttfHeaders['Authorization-Guest'] = /*#__PURE__*/localStorage.getItem('auth_guest_token');
996
1077
  }
997
1078
 
998
- if (isWindowDefined && !discardedOrigins.some(function (el) {
999
- return origin && origin.includes(el);
1000
- })) {
1001
- ttfHeaders['X-Source-Origin'] = 'houseofx.nyc';
1002
- }
1003
-
1004
1079
  var publicRequest = /*#__PURE__*/axios.create({
1005
1080
  baseURL: CONFIGS.BASE_URL || "https://www.ticketfairy.com/api",
1006
1081
  headers: ttfHeaders
@@ -1043,11 +1118,9 @@ publicRequest.interceptors.request.use(function (config) {
1043
1118
  config.headers = _updatedHeaders;
1044
1119
  }
1045
1120
 
1046
- if (isWindowDefined && !discardedOrigins.some(function (el) {
1047
- return origin && origin.includes(el);
1048
- })) {
1121
+ if (CONFIGS.X_SOURCE_ORIGIN) {
1049
1122
  var _updatedHeaders2 = _extends({}, config.headers, {
1050
- 'X-Source-Origin': 'houseofx.nyc'
1123
+ 'X-Source-Origin': CONFIGS.X_SOURCE_ORIGIN
1051
1124
  });
1052
1125
 
1053
1126
  config.headers = _updatedHeaders2;
@@ -1072,6 +1145,9 @@ publicRequest.setAccessToken = function (token) {
1072
1145
  return publicRequest.defaults.headers.common.Authorization = token;
1073
1146
  };
1074
1147
 
1148
+ var setXSourceOrigin = function setXSourceOrigin(sourceOrigin) {
1149
+ ttfHeaders['X-Source-Origin'] = sourceOrigin;
1150
+ };
1075
1151
  var setCustomHeader = function setCustomHeader(response) {
1076
1152
  var guestHeaderResponseValue = _get(response, 'headers.authorization-guest');
1077
1153
 
@@ -1094,6 +1170,14 @@ var handleSetAccessToken = function handleSetAccessToken(token) {
1094
1170
  }
1095
1171
  }
1096
1172
  };
1173
+ function getEvent(id) {
1174
+ var response = publicRequest.get("v1/event/" + id, {
1175
+ headers: ttfHeaders
1176
+ })["catch"](function (error) {
1177
+ throw error;
1178
+ });
1179
+ return response;
1180
+ }
1097
1181
  function getTickets(id, promoCode) {
1098
1182
  var response = publicRequest.get("v1/event/" + id + "/tickets/", {
1099
1183
  headers: promoCode ? _extends({}, ttfHeaders, {
@@ -1229,7 +1313,7 @@ var LoginModal = function LoginModal(_ref) {
1229
1313
  },
1230
1314
  onSubmit: function () {
1231
1315
  var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2) {
1232
- var email, password, bodyFormData, resAutorize, bodyFormDataToken, resAccessToken, accessToken, profileResponse, profileSpecifiedData, profileDataObj, _e$response, _e$response$data, _error;
1316
+ var email, password, bodyFormData, resAutorize, bodyFormDataToken, resAccessToken, accessToken, profileResponse, profileSpecifiedData, profileDataObj, event, _e$response, _e$response$data, _error;
1233
1317
 
1234
1318
  return runtime_1.wrap(function _callee$(_context) {
1235
1319
  while (1) {
@@ -1308,6 +1392,8 @@ var LoginModal = function LoginModal(_ref) {
1308
1392
  if (typeof window !== 'undefined') {
1309
1393
  window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
1310
1394
  window.localStorage.setItem('access_token', accessToken);
1395
+ event = new window.CustomEvent('tf-login');
1396
+ window.document.dispatchEvent(event);
1311
1397
  }
1312
1398
 
1313
1399
  onLogin();
@@ -1654,7 +1740,7 @@ var setLoggedUserData = function setLoggedUserData(data) {
1654
1740
  country: (data == null ? void 0 : data.country) || '',
1655
1741
  phone: (data == null ? void 0 : data.phone) || '',
1656
1742
  street_address: (data == null ? void 0 : data.streetAddress) || '',
1657
- state: (data == null ? void 0 : data.state) || '',
1743
+ state: (data == null ? void 0 : data.stateId) || '',
1658
1744
  zip: (data == null ? void 0 : data.zip) || (data == null ? void 0 : data.zipCode) || ''
1659
1745
  };
1660
1746
  };
@@ -1780,6 +1866,7 @@ var CustomField = function CustomField(_ref) {
1780
1866
  var error = _get(errors, field.name);
1781
1867
 
1782
1868
  var isTouched = Boolean(_get(touched, field.name)) || _includes(field.name, 'holder') && !!error && !!submitCount;
1869
+ var customTheme = useTheme();
1783
1870
  return React.createElement(TextField$1, Object.assign({
1784
1871
  id: field.name,
1785
1872
  label: label,
@@ -1794,6 +1881,12 @@ var CustomField = function CustomField(_ref) {
1794
1881
  MenuProps: {
1795
1882
  className: theme
1796
1883
  }
1884
+ },
1885
+ InputLabelProps: {
1886
+ sx: customTheme == null ? void 0 : customTheme.input
1887
+ },
1888
+ inputProps: {
1889
+ sx: customTheme == null ? void 0 : customTheme.input
1797
1890
  }
1798
1891
  }, field), isSelectField ? _map(selectOptions, function (option) {
1799
1892
  return React.createElement("option", {
@@ -1810,9 +1903,13 @@ var CheckboxField = function CheckboxField(_ref) {
1810
1903
  field = _ref.field,
1811
1904
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
1812
1905
 
1906
+ var customTheme = useTheme();
1813
1907
  return React.createElement(FormGroup, null, React.createElement(FormControlLabel, {
1814
1908
  control: React.createElement(Checkbox, Object.assign({}, field, rest)),
1815
- label: label
1909
+ label: label,
1910
+ componentsProps: {
1911
+ typography: customTheme == null ? void 0 : customTheme.checkbox
1912
+ }
1816
1913
  }));
1817
1914
  };
1818
1915
 
@@ -1831,9 +1928,11 @@ var SelectField = function SelectField(_ref) {
1831
1928
 
1832
1929
  var error = _get(errors, field.name);
1833
1930
 
1931
+ var customTheme = useTheme();
1834
1932
  return React.createElement(FormControl, {
1835
1933
  fullWidth: true
1836
1934
  }, React.createElement(InputLabel, {
1935
+ style: customTheme == null ? void 0 : customTheme.input,
1837
1936
  htmlFor: field.name,
1838
1937
  error: !!error && isTouched,
1839
1938
  shrink: true
@@ -1851,7 +1950,9 @@ var SelectField = function SelectField(_ref) {
1851
1950
  MenuProps: {
1852
1951
  className: theme
1853
1952
  }
1854
- }, field), _map(selectOptions, function (option) {
1953
+ }, field, {
1954
+ style: customTheme == null ? void 0 : customTheme.input
1955
+ }), _map(selectOptions, function (option) {
1855
1956
  return React.createElement("option", {
1856
1957
  key: option.value,
1857
1958
  value: option.value,
@@ -1943,14 +2044,17 @@ var FormikPhoneNumberField = function FormikPhoneNumberField(_ref) {
1943
2044
  _ref$form = _ref.form,
1944
2045
  touched = _ref$form.touched,
1945
2046
  errors = _ref$form.errors,
2047
+ initialValues = _ref$form.initialValues,
1946
2048
  setFieldValue = _ref.setFieldValue,
1947
2049
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
1948
2050
 
1949
2051
  var error = _get(errors, field.name);
1950
2052
 
1951
2053
  var isTouched = Boolean(_get(touched, field.name));
2054
+ var customTheme = useTheme();
1952
2055
  return React.createElement(MuiPhoneNumber, Object.assign({
1953
2056
  name: 'phone',
2057
+ value: initialValues.phone,
1954
2058
  onChange: function onChange(e) {
1955
2059
  return setFieldValue("phone", removePlusSign(e));
1956
2060
  },
@@ -1961,6 +2065,12 @@ var FormikPhoneNumberField = function FormikPhoneNumberField(_ref) {
1961
2065
  error: !!error && isTouched,
1962
2066
  helperText: isTouched && error,
1963
2067
  fullWidth: true,
2068
+ InputLabelProps: {
2069
+ sx: customTheme == null ? void 0 : customTheme.input
2070
+ },
2071
+ InputProps: {
2072
+ sx: customTheme == null ? void 0 : customTheme.input
2073
+ },
1964
2074
  autoFormat: false
1965
2075
  }, rest));
1966
2076
  };
@@ -1973,10 +2083,11 @@ var LogicRunner = function LogicRunner(_ref) {
1973
2083
  setUserValues = _ref.setUserValues,
1974
2084
  onGetStatesSuccess = _ref.onGetStatesSuccess,
1975
2085
  onGetStatesError = _ref.onGetStatesError;
2086
+ var prevCountry = useRef(values.country);
1976
2087
  useEffect(function () {
1977
2088
  var fetchStates = /*#__PURE__*/function () {
1978
2089
  var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1979
- var _mappedStates$0$value, _mappedStates$, res, mappedStates;
2090
+ var res, mappedStates, _mappedStates$0$value, _mappedStates$;
1980
2091
 
1981
2092
  return runtime_1.wrap(function _callee$(_context) {
1982
2093
  while (1) {
@@ -1995,7 +2106,12 @@ var LogicRunner = function LogicRunner(_ref) {
1995
2106
  };
1996
2107
  });
1997
2108
  setStates(mappedStates);
1998
- setFieldValue('state', (_mappedStates$0$value = (_mappedStates$ = mappedStates[0]) == null ? void 0 : _mappedStates$.value) != null ? _mappedStates$0$value : '');
2109
+
2110
+ if (prevCountry.current !== values.country) {
2111
+ setFieldValue('state', (_mappedStates$0$value = (_mappedStates$ = mappedStates[0]) == null ? void 0 : _mappedStates$.value) != null ? _mappedStates$0$value : '');
2112
+ prevCountry.current = values.country;
2113
+ }
2114
+
1999
2115
  onGetStatesSuccess(res.data);
2000
2116
  _context.next = 13;
2001
2117
  break;
@@ -2033,13 +2149,13 @@ var LogicRunner = function LogicRunner(_ref) {
2033
2149
  var parsedData = JSON.parse(userDataEncoded);
2034
2150
  var mappedValues = {
2035
2151
  firstName: (parsedData == null ? void 0 : parsedData.first_name) || '',
2036
- lastName: parsedData == null ? void 0 : parsedData.last_name,
2152
+ lastName: (parsedData == null ? void 0 : parsedData.last_name) || '',
2037
2153
  email: (parsedData == null ? void 0 : parsedData.email) || '',
2038
2154
  phone: (parsedData == null ? void 0 : parsedData.phone) || '',
2039
2155
  confirmEmail: (parsedData == null ? void 0 : parsedData.email) || '',
2040
2156
  state: (parsedData == null ? void 0 : parsedData.state) || '',
2041
2157
  street_address: (parsedData == null ? void 0 : parsedData.street_address) || '',
2042
- country: (parsedData == null ? void 0 : parsedData.country) || 1,
2158
+ country: (parsedData == null ? void 0 : parsedData.country) || "1",
2043
2159
  zip: (parsedData == null ? void 0 : parsedData.zip) || '',
2044
2160
  brand_opt_in: (parsedData == null ? void 0 : parsedData.brand_opt_in) || '',
2045
2161
  city: (parsedData == null ? void 0 : parsedData.city) || '',
@@ -2103,21 +2219,16 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2103
2219
  onAuthorizeSuccess = _ref3$onAuthorizeSucc === void 0 ? function () {} : _ref3$onAuthorizeSucc,
2104
2220
  _ref3$onAuthorizeErro = _ref3.onAuthorizeError,
2105
2221
  onAuthorizeError = _ref3$onAuthorizeErro === void 0 ? function () {} : _ref3$onAuthorizeErro,
2106
- _ref3$onLogin = _ref3.onLogin,
2107
- onLogin = _ref3$onLogin === void 0 ? function () {} : _ref3$onLogin,
2222
+ onLogin = _ref3.onLogin,
2108
2223
  _ref3$onLoginSuccess = _ref3.onLoginSuccess,
2109
2224
  onLoginSuccess = _ref3$onLoginSuccess === void 0 ? function () {} : _ref3$onLoginSuccess,
2110
2225
  _ref3$isLoggedIn = _ref3.isLoggedIn,
2111
2226
  pIsLoggedIn = _ref3$isLoggedIn === void 0 ? false : _ref3$isLoggedIn,
2112
- fontFamily = _ref3.fontFamily,
2113
- hideLogo = _ref3.hideLogo;
2114
- var themeMui = createTheme({
2115
- typography: {
2116
- allVariants: {
2117
- fontFamily: fontFamily
2118
- }
2119
- }
2120
- });
2227
+ _ref3$accountInfoTitl = _ref3.accountInfoTitle,
2228
+ accountInfoTitle = _ref3$accountInfoTitl === void 0 ? '' : _ref3$accountInfoTitl,
2229
+ hideLogo = _ref3.hideLogo,
2230
+ themeOptions = _ref3.themeOptions;
2231
+ var themeMui = createTheme(themeOptions);
2121
2232
  var isWindowDefined = typeof window !== 'undefined';
2122
2233
  var userData = isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
2123
2234
  var access_token = isWindowDefined && window.localStorage.getItem('access_token') ? window.localStorage.getItem('access_token') || '' : '';
@@ -2243,7 +2354,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2243
2354
  setCountries(_map(_get(res, 'data.data'), function (item, key) {
2244
2355
  return {
2245
2356
  label: item,
2246
- value: Number(key)
2357
+ value: key
2247
2358
  };
2248
2359
  }));
2249
2360
  onGetCountriesSuccess(res.data);
@@ -2343,7 +2454,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2343
2454
  userDataResponse = _context4.sent;
2344
2455
  profileSpecifiedData = _get(userDataResponse, 'data.data');
2345
2456
  profileDataObj = setLoggedUserData(profileSpecifiedData);
2346
- setUserValues(profileDataObj);
2457
+ setUserValues(_extends({}, profileDataObj, {
2458
+ firstName: profileDataObj.first_name,
2459
+ lastName: profileDataObj.last_name
2460
+ }));
2347
2461
  window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
2348
2462
  onGetProfileDataSuccess(userDataResponse.data);
2349
2463
 
@@ -2379,9 +2493,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2379
2493
  theme: themeMui
2380
2494
  }, React.createElement(Formik, {
2381
2495
  initialValues: getInitialValues(dataWithUniqueIds, _extends({}, initialValues, {
2382
- firstName: firstNameLogged,
2383
- lastName: lastNameLogged,
2384
- country: 1,
2496
+ country: _get(userData, 'country', '') || "1",
2497
+ state: _get(userData, 'state', '') || "1",
2385
2498
  brand_opt_in: optedInFieldValue
2386
2499
  }), userValues),
2387
2500
  enableReinitialize: true,
@@ -2472,12 +2585,13 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2472
2585
  formikHelpers.setFieldError('confirmPassword', error.password);
2473
2586
  }
2474
2587
 
2475
- if (error != null && error.email) {
2588
+ if (error != null && error.email && !onLogin) {
2589
+ // False will stand for outside controll
2476
2590
  setAlreadyHasUser(true);
2477
2591
  setShowModalLogin(true);
2478
2592
  }
2479
2593
 
2480
- onRegisterError(_context5.t0);
2594
+ onRegisterError(_context5.t0, values.email);
2481
2595
  }
2482
2596
 
2483
2597
  return _context5.abrupt("return");
@@ -2555,14 +2669,18 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2555
2669
  className: "billing-info-container " + theme
2556
2670
  }, !isLoggedIn && React.createElement("div", {
2557
2671
  className: "account-actions-block"
2558
- }, React.createElement("div", null, "Got a ", React.createElement("strong", null, "TICKET"), "FAIRY account?"), React.createElement("div", null, "Login & skip ahead:"), React.createElement("div", {
2672
+ }, React.createElement("div", null, accountInfoTitle), React.createElement("div", null, "Login & skip ahead:"), React.createElement("div", {
2559
2673
  className: "login-block"
2560
2674
  }, React.createElement("button", {
2561
2675
  className: "login-register-button",
2562
2676
  type: "button",
2563
2677
  onClick: function onClick() {
2564
- onLogin();
2565
- setShowModalLogin(true);
2678
+ // If outside login needed to skip package login functionallity
2679
+ if (onLogin) {
2680
+ onLogin();
2681
+ } else {
2682
+ setShowModalLogin(true);
2683
+ }
2566
2684
  }
2567
2685
  }, "Login"), !hideLogo && React.createElement("div", {
2568
2686
  className: "logo-image-container"
@@ -2640,17 +2758,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2640
2758
  }));
2641
2759
  })), React.createElement("div", {
2642
2760
  className: "button-container"
2643
- }, React.createElement(LoadingButton, {
2761
+ }, React.createElement(Button, {
2644
2762
  type: "submit",
2645
2763
  variant: "contained",
2646
2764
  className: "login-register-button",
2647
- loadingIndicator: React.createElement(CircularProgress, {
2648
- color: "inherit",
2649
- size: 26
2650
- }),
2651
- loading: props.isSubmitting,
2652
2765
  disabled: props.isSubmitting
2653
- }, buttonName))));
2766
+ }, props.isSubmitting ? React.createElement(CircularProgress, {
2767
+ size: 26
2768
+ }) : buttonName))));
2654
2769
  }), showModalLogin && React.createElement(LoginModal, {
2655
2770
  onClose: function onClose() {
2656
2771
  setShowModalLogin(false);
@@ -2714,7 +2829,8 @@ var CheckoutForm = function CheckoutForm(_ref) {
2714
2829
  _ref$handleSetLoading = _ref.handleSetLoading,
2715
2830
  handleSetLoading = _ref$handleSetLoading === void 0 ? function () {} : _ref$handleSetLoading,
2716
2831
  _ref$conditions = _ref.conditions,
2717
- conditions = _ref$conditions === void 0 ? [] : _ref$conditions;
2832
+ conditions = _ref$conditions === void 0 ? [] : _ref$conditions,
2833
+ disableZipSection = _ref.disableZipSection;
2718
2834
  var stripe = useStripe();
2719
2835
  var elements = useElements();
2720
2836
 
@@ -2746,7 +2862,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
2746
2862
  _context.prev = 1;
2747
2863
  event.preventDefault();
2748
2864
 
2749
- if (postalCode) {
2865
+ if (!(!postalCode && !disableZipSection)) {
2750
2866
  _context.next = 7;
2751
2867
  break;
2752
2868
  }
@@ -2771,10 +2887,14 @@ var CheckoutForm = function CheckoutForm(_ref) {
2771
2887
  address = {
2772
2888
  city: billing_info.city,
2773
2889
  line1: billing_info.street_address,
2774
- state: billing_info.state,
2775
- postal_code: postalCode
2890
+ state: billing_info.state
2776
2891
  };
2777
- _context.next = 14;
2892
+
2893
+ if (!disableZipSection) {
2894
+ address.postal_code = postalCode;
2895
+ }
2896
+
2897
+ _context.next = 15;
2778
2898
  return stripe.createPaymentMethod({
2779
2899
  type: 'card',
2780
2900
  card: card || {
@@ -2785,11 +2905,11 @@ var CheckoutForm = function CheckoutForm(_ref) {
2785
2905
  }
2786
2906
  });
2787
2907
 
2788
- case 14:
2908
+ case 15:
2789
2909
  paymentMethodReq = _context.sent;
2790
2910
 
2791
2911
  if (!paymentMethodReq.error) {
2792
- _context.next = 19;
2912
+ _context.next = 20;
2793
2913
  break;
2794
2914
  }
2795
2915
 
@@ -2797,18 +2917,18 @@ var CheckoutForm = function CheckoutForm(_ref) {
2797
2917
  handleSetLoading(false);
2798
2918
  return _context.abrupt("return");
2799
2919
 
2800
- case 19:
2801
- _context.next = 21;
2920
+ case 20:
2921
+ _context.next = 22;
2802
2922
  return stripe.confirmCardPayment(stripe_client_secret, {
2803
2923
  payment_method: paymentMethodReq.paymentMethod.id
2804
2924
  });
2805
2925
 
2806
- case 21:
2926
+ case 22:
2807
2927
  _yield$stripe$confirm = _context.sent;
2808
2928
  _error = _yield$stripe$confirm.error;
2809
2929
 
2810
2930
  if (!_error) {
2811
- _context.next = 27;
2931
+ _context.next = 28;
2812
2932
  break;
2813
2933
  }
2814
2934
 
@@ -2816,22 +2936,22 @@ var CheckoutForm = function CheckoutForm(_ref) {
2816
2936
  handleSetLoading(false);
2817
2937
  return _context.abrupt("return");
2818
2938
 
2819
- case 27:
2939
+ case 28:
2820
2940
  onSubmit(null);
2821
- _context.next = 33;
2941
+ _context.next = 34;
2822
2942
  break;
2823
2943
 
2824
- case 30:
2825
- _context.prev = 30;
2944
+ case 31:
2945
+ _context.prev = 31;
2826
2946
  _context.t0 = _context["catch"](1);
2827
2947
  onSubmit(_context.t0);
2828
2948
 
2829
- case 33:
2949
+ case 34:
2830
2950
  case "end":
2831
2951
  return _context.stop();
2832
2952
  }
2833
2953
  }
2834
- }, _callee, null, [[1, 30]]);
2954
+ }, _callee, null, [[1, 31]]);
2835
2955
  }));
2836
2956
 
2837
2957
  return function handleSubmit(_x) {
@@ -2892,7 +3012,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
2892
3012
  }, React.createElement("span", {
2893
3013
  className: "card_label_text"
2894
3014
  }, "Card number"), React.createElement(CardNumberElement, {
2895
- options: _extends({}, options, stripeCardOptions),
3015
+ options: _extends({}, options.style, stripeCardOptions),
2896
3016
  onReady: _identity,
2897
3017
  onChange: _identity,
2898
3018
  onBlur: _identity,
@@ -2902,14 +3022,14 @@ var CheckoutForm = function CheckoutForm(_ref) {
2902
3022
  }, React.createElement("span", {
2903
3023
  className: "card_label_text"
2904
3024
  }, "Expiration date"), React.createElement(CardExpiryElement, {
2905
- options: _extends({}, options, stripeCardOptions)
3025
+ options: _extends({}, options.style, stripeCardOptions)
2906
3026
  })), React.createElement("label", {
2907
3027
  className: "cvc_element"
2908
3028
  }, React.createElement("span", {
2909
3029
  className: "card_label_text"
2910
3030
  }, "CVC"), React.createElement(CardCvcElement, {
2911
- options: _extends({}, options, stripeCardOptions)
2912
- })), React.createElement("label", {
3031
+ options: _extends({}, options.style, stripeCardOptions)
3032
+ })), !disableZipSection && React.createElement("label", {
2913
3033
  className: "zip_element"
2914
3034
  }, React.createElement("p", {
2915
3035
  className: "card_label_text"
@@ -2936,7 +3056,9 @@ var CheckoutForm = function CheckoutForm(_ref) {
2936
3056
  }, React.createElement("button", {
2937
3057
  disabled: buttonIsDiabled,
2938
3058
  type: "submit"
2939
- }, isLoading ? React.createElement(CircularProgress$1, null) : "Pay " + getCurrencySymbolByCurrency(currency) + total))));
3059
+ }, isLoading ? React.createElement(CircularProgress$1, {
3060
+ size: 26
3061
+ }) : "Pay " + getCurrencySymbolByCurrency(currency) + total))));
2940
3062
  };
2941
3063
 
2942
3064
  var publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || '';
@@ -2996,7 +3118,9 @@ var PaymentContainer = function PaymentContainer(_ref) {
2996
3118
  onPaymentError = _ref$onPaymentError === void 0 ? function () {} : _ref$onPaymentError,
2997
3119
  _ref$stripeCardOption = _ref.stripeCardOptions,
2998
3120
  stripeCardOptions = _ref$stripeCardOption === void 0 ? {} : _ref$stripeCardOption,
2999
- fontFamily = _ref.fontFamily;
3121
+ _ref$disableZipSectio = _ref.disableZipSection,
3122
+ disableZipSection = _ref$disableZipSectio === void 0 ? false : _ref$disableZipSectio,
3123
+ themeOptions = _ref.themeOptions;
3000
3124
 
3001
3125
  var _useState = useState(initialReviewValues),
3002
3126
  reviewData = _useState[0],
@@ -3180,13 +3304,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
3180
3304
  };
3181
3305
  }();
3182
3306
 
3183
- var themeMui = createTheme({
3184
- typography: {
3185
- allVariants: {
3186
- fontFamily: fontFamily
3187
- }
3188
- }
3189
- });
3307
+ var themeMui = createTheme(themeOptions);
3190
3308
  return React.createElement(ThemeProvider, {
3191
3309
  theme: themeMui
3192
3310
  }, React.createElement("div", {
@@ -3236,7 +3354,8 @@ var PaymentContainer = function PaymentContainer(_ref) {
3236
3354
  return setPaymentIsLoading(value);
3237
3355
  },
3238
3356
  conditions: conditions,
3239
- stripeCardOptions: stripeCardOptions
3357
+ stripeCardOptions: stripeCardOptions,
3358
+ disableZipSection: disableZipSection
3240
3359
  })))))));
3241
3360
  };
3242
3361
 
@@ -3410,7 +3529,8 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
3410
3529
  _ref$onGetConfirmatio = _ref.onGetConfirmationDataSuccess,
3411
3530
  onGetConfirmationDataSuccess = _ref$onGetConfirmatio === void 0 ? function () {} : _ref$onGetConfirmatio,
3412
3531
  _ref$onGetConfirmatio2 = _ref.onGetConfirmationDataError,
3413
- onGetConfirmationDataError = _ref$onGetConfirmatio2 === void 0 ? function () {} : _ref$onGetConfirmatio2;
3532
+ onGetConfirmationDataError = _ref$onGetConfirmatio2 === void 0 ? function () {} : _ref$onGetConfirmatio2,
3533
+ orderHash = _ref.orderHash;
3414
3534
  var inputRef = useRef(null);
3415
3535
 
3416
3536
  var _useState = useState(null),
@@ -3426,15 +3546,17 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
3426
3546
  while (1) {
3427
3547
  switch (_context.prev = _context.next) {
3428
3548
  case 0:
3429
- dataEncoded = typeof window !== 'undefined' && window.localStorage.getItem('checkoutData');
3549
+ dataEncoded = typeof window !== 'undefined' && window.localStorage.getItem('checkoutData') || '';
3550
+ dataDecoded = dataEncoded ? JSON.parse(dataEncoded) : {
3551
+ hash: orderHash
3552
+ };
3553
+ hash = dataDecoded.hash;
3430
3554
 
3431
- if (!dataEncoded) {
3555
+ if (!hash) {
3432
3556
  _context.next = 18;
3433
3557
  break;
3434
3558
  }
3435
3559
 
3436
- dataDecoded = JSON.parse(dataEncoded);
3437
- hash = dataDecoded.hash;
3438
3560
  _context.prev = 4;
3439
3561
  _context.next = 7;
3440
3562
  return getConfirmationData(hash);
@@ -3544,13 +3666,13 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
3544
3666
  value: data.personal_share_link,
3545
3667
  onChange: onChangeShareLink
3546
3668
  }), React.createElement("div", {
3547
- className: 'share-by-link-copy-icon',
3669
+ className: "share-by-link-copy-icon",
3548
3670
  onClick: function onClick() {
3549
3671
  return navigator.clipboard.writeText(_get(inputRef, 'current.value'));
3550
3672
  }
3551
3673
  }, React.createElement("img", {
3552
3674
  src: "https://img.icons8.com/office/50/000000/copy.png",
3553
- alt: 'copy'
3675
+ alt: "copy"
3554
3676
  })))), (showDefaultShareButtons || !!shareButtons.length) && React.createElement(SocialButtons, {
3555
3677
  showDefaultShareButtons: showDefaultShareButtons,
3556
3678
  name: data.product_name,
@@ -3564,7 +3686,7 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
3564
3686
  }, "How much cheaper?"), _map(data.personal_share_sales, function (pricing, index) {
3565
3687
  return React.createElement("div", {
3566
3688
  key: index,
3567
- className: 'pricing-section_wrapper'
3689
+ className: "pricing-section_wrapper"
3568
3690
  }, React.createElement("div", {
3569
3691
  className: "pricing-section_label"
3570
3692
  }, pricing.label, pricing.subLabel && React.createElement("div", {
@@ -3702,12 +3824,14 @@ var TicketsSection = function TicketsSection(_ref) {
3702
3824
  style: {
3703
3825
  minWidth: 55
3704
3826
  }
3705
- }, React.createElement(TicketRow, {
3827
+ }, ticket.salesStarted ? React.createElement(TicketRow, {
3706
3828
  ticketTier: ticket,
3707
3829
  prevTicketTier: arr[i - 1],
3708
3830
  selectedTickets: selectedTickets,
3709
3831
  handleTicketSelect: ticketSelect
3710
- }))));
3832
+ }) : React.createElement("p", {
3833
+ className: 'ticket-not-started-message'
3834
+ }, "Sales not started"))));
3711
3835
  }));
3712
3836
  };
3713
3837
 
@@ -3727,8 +3851,7 @@ var generateQuantity = function generateQuantity(n) {
3727
3851
  var WaitingList = function WaitingList(_ref) {
3728
3852
  var _ref$tickets = _ref.tickets,
3729
3853
  tickets = _ref$tickets === void 0 ? {} : _ref$tickets,
3730
- eventId = _ref.eventId,
3731
- isPromotionsEnabled = _ref.isPromotionsEnabled;
3854
+ eventId = _ref.eventId;
3732
3855
 
3733
3856
  var _useState = useState(false),
3734
3857
  showSuccessMessage = _useState[0],
@@ -3803,9 +3926,7 @@ var WaitingList = function WaitingList(_ref) {
3803
3926
  className: "success-message"
3804
3927
  }, React.createElement("p", {
3805
3928
  className: "added-success-message"
3806
- }, "You've been added to the waiting list!"), React.createElement("p", null, "You'll be notified if tickets become available.")) : React.createElement(React.Fragment, null, !isPromotionsEnabled && React.createElement("p", {
3807
- className: "no-tickets-text"
3808
- }, "No tickets are currently available for this event."), React.createElement("h2", null, "WAITING LIST"), React.createElement(Formik, {
3929
+ }, "You've been added to the waiting list!"), React.createElement("p", null, "You'll be notified if tickets become available.")) : React.createElement(React.Fragment, null, React.createElement("h2", null, "WAITING LIST"), React.createElement(Formik, {
3809
3930
  initialValues: {
3810
3931
  ticketTypeId: '',
3811
3932
  quantity: '',
@@ -3911,10 +4032,12 @@ var PromoCodeSection = function PromoCodeSection(_ref) {
3911
4032
  preProcessor: function preProcessor(code) {
3912
4033
  return code.replace(/fill=".*?"/g, 'fill="currentColor"');
3913
4034
  }
3914
- }), React.createElement("p", null, "PROMO CODE APPLIED SUCCESSFULLY")) : null, showPromoInput && React.createElement("div", {
4035
+ }), React.createElement("p", {
4036
+ className: "promo-code-success"
4037
+ }, "PROMO CODE APPLIED SUCCESSFULLY")) : null, showPromoInput && React.createElement("div", {
3915
4038
  className: "promo-code-block"
3916
- }, React.createElement("input", {
3917
- placeholder: "Promo Code",
4039
+ }, React.createElement("label", null, "PROMO CODE"), React.createElement("input", {
4040
+ placeholder: "",
3918
4041
  onChange: function onChange(e) {
3919
4042
  setPromoCode(e.target.value);
3920
4043
  },
@@ -3940,6 +4063,84 @@ var PromoCodeSection = function PromoCodeSection(_ref) {
3940
4063
  }, "Got a promo code? Click here") : null);
3941
4064
  };
3942
4065
 
4066
+ var isTimeExpired = function isTimeExpired(startDate, timezone) {
4067
+ return !moment(startDate).isAfter(moment.tz(moment(), timezone).format('YYYY-MM-DD HH:mm:ss'));
4068
+ };
4069
+
4070
+ function Countdown(_ref) {
4071
+ var startDate = _ref.startDate,
4072
+ _ref$timezone = _ref.timezone,
4073
+ timezone = _ref$timezone === void 0 ? moment.tz.guess() : _ref$timezone,
4074
+ _ref$title = _ref.title,
4075
+ title = _ref$title === void 0 ? '' : _ref$title,
4076
+ _ref$message = _ref.message,
4077
+ message = _ref$message === void 0 ? '' : _ref$message,
4078
+ _ref$callback = _ref.callback,
4079
+ callback = _ref$callback === void 0 ? function () {} : _ref$callback;
4080
+
4081
+ var _useState = useState(''),
4082
+ duration = _useState[0],
4083
+ setDuration = _useState[1];
4084
+
4085
+ var _useState2 = useState(false),
4086
+ timeExpired = _useState2[0],
4087
+ setTimeExpired = _useState2[1];
4088
+
4089
+ useEffect(function () {
4090
+ setTimeExpired(isTimeExpired(startDate, timezone));
4091
+ }, []);
4092
+ useEffect(function () {
4093
+ var timer;
4094
+
4095
+ if (!timeExpired) {
4096
+ timer = setInterval(function () {
4097
+ if (isTimeExpired(startDate, timezone)) {
4098
+ clearInterval(timer);
4099
+ setTimeExpired(true);
4100
+ callback();
4101
+ }
4102
+
4103
+ var currentDate = moment.tz(moment(), timezone).format('YYYY-MM-DD HH:mm:ss');
4104
+ var diffTime = moment(startDate).diff(currentDate);
4105
+ var duration = moment.duration(diffTime);
4106
+ var dateArr = {
4107
+ year: duration.years(),
4108
+ month: duration.months(),
4109
+ day: duration.days(),
4110
+ hour: duration.hours(),
4111
+ minute: duration.minutes(),
4112
+ second: duration.seconds()
4113
+ };
4114
+ var timeLeft = '';
4115
+
4116
+ for (var date in dateArr) {
4117
+ var unit = dateArr[date] === 1 ? date : date + 's';
4118
+ var val = String(dateArr[date]).length === 1 ? '0' + dateArr[date] : dateArr[date];
4119
+
4120
+ if (timeLeft) {
4121
+ timeLeft += ", " + val + " " + unit;
4122
+ } else if (dateArr[date]) {
4123
+ timeLeft += val + " " + unit;
4124
+ }
4125
+ }
4126
+
4127
+ setDuration(timeLeft);
4128
+ }, 1000);
4129
+ }
4130
+
4131
+ return function () {
4132
+ clearInterval(timer);
4133
+ };
4134
+ }, [timeExpired]);
4135
+ return React.createElement(React.Fragment, null, !timeExpired && duration && React.createElement("div", {
4136
+ className: 'countdown'
4137
+ }, React.createElement("div", null, React.createElement("p", {
4138
+ className: 'title'
4139
+ }, title), React.createElement("p", null, duration)), React.createElement("p", {
4140
+ className: 'message'
4141
+ }, message)));
4142
+ }
4143
+
3943
4144
  function Loader$1() {
3944
4145
  return React.createElement("div", {
3945
4146
  className: "loader-container"
@@ -3947,7 +4148,8 @@ function Loader$1() {
3947
4148
  }
3948
4149
 
3949
4150
  var TicketsContainer = function TicketsContainer(_ref) {
3950
- var getTicketsLabel = _ref.getTicketsLabel,
4151
+ var onLoginSuccess = _ref.onLoginSuccess,
4152
+ getTicketsLabel = _ref.getTicketsLabel,
3951
4153
  eventId = _ref.eventId,
3952
4154
  onAddToCartSuccess = _ref.onAddToCartSuccess,
3953
4155
  _ref$contentStyle = _ref.contentStyle,
@@ -3969,37 +4171,51 @@ var TicketsContainer = function TicketsContainer(_ref) {
3969
4171
  selectedTickets = _useState[0],
3970
4172
  setSelectedTickets = _useState[1];
3971
4173
 
3972
- var _useState2 = useState([]),
3973
- tickets = _useState2[0],
3974
- setTickets = _useState2[1];
4174
+ var isWindowDefined = typeof window !== 'undefined';
3975
4175
 
3976
- var _useState3 = useState(false),
3977
- showWaitingList = _useState3[0],
3978
- setShowWaitingList = _useState3[1];
4176
+ var _useState2 = useState(isWindowDefined ? !!window.localStorage.getItem('access_token') : false),
4177
+ isLogged = _useState2[0],
4178
+ setIsLogged = _useState2[1];
3979
4179
 
3980
- var _useState4 = useState(false),
3981
- isLoading = _useState4[0],
3982
- setIsLoading = _useState4[1];
4180
+ var _React$useState = React.useState(false),
4181
+ showLoginModal = _React$useState[0],
4182
+ setShowLoginModal = _React$useState[1];
4183
+
4184
+ var _useState3 = useState([]),
4185
+ tickets = _useState3[0],
4186
+ setTickets = _useState3[1];
4187
+
4188
+ var _useState4 = useState(null),
4189
+ event = _useState4[0],
4190
+ setEvent = _useState4[1];
3983
4191
 
3984
4192
  var _useState5 = useState(false),
3985
- handleBookIsLoading = _useState5[0],
3986
- setHandleBookIsLoading = _useState5[1];
4193
+ showWaitingList = _useState5[0],
4194
+ setShowWaitingList = _useState5[1];
3987
4195
 
3988
- var _useState6 = useState(''),
3989
- promoCode = _useState6[0],
3990
- setPromoCode = _useState6[1];
4196
+ var _useState6 = useState(false),
4197
+ isLoading = _useState6[0],
4198
+ setIsLoading = _useState6[1];
3991
4199
 
3992
- var _useState7 = useState(queryPromoCode),
3993
- promoCodeUpdated = _useState7[0],
3994
- setPromoCodeUpdated = _useState7[1];
4200
+ var _useState7 = useState(false),
4201
+ handleBookIsLoading = _useState7[0],
4202
+ setHandleBookIsLoading = _useState7[1];
3995
4203
 
3996
- var _useState8 = useState(false),
3997
- showPromoInput = _useState8[0],
3998
- setShowPromoInput = _useState8[1];
4204
+ var _useState8 = useState(''),
4205
+ promoCode = _useState8[0],
4206
+ setPromoCode = _useState8[1];
3999
4207
 
4000
- var _useState9 = useState(false),
4001
- promoCodeIsApplied = _useState9[0],
4002
- setPromoCodeIsApplied = _useState9[1];
4208
+ var _useState9 = useState(queryPromoCode),
4209
+ promoCodeUpdated = _useState9[0],
4210
+ setPromoCodeUpdated = _useState9[1];
4211
+
4212
+ var _useState10 = useState(false),
4213
+ showPromoInput = _useState10[0],
4214
+ setShowPromoInput = _useState10[1];
4215
+
4216
+ var _useState11 = useState(false),
4217
+ promoCodeIsApplied = _useState11[0],
4218
+ setPromoCodeIsApplied = _useState11[1];
4003
4219
 
4004
4220
  useEffect(function () {
4005
4221
  if (typeof window !== 'undefined') {
@@ -4016,62 +4232,102 @@ var TicketsContainer = function TicketsContainer(_ref) {
4016
4232
  }
4017
4233
  }, []);
4018
4234
  useEffect(function () {
4019
- function getTicketsApi() {
4020
- return _getTicketsApi.apply(this, arguments);
4021
- }
4235
+ getTicketsApi();
4236
+ }, [eventId, promoCodeUpdated]);
4022
4237
 
4023
- function _getTicketsApi() {
4024
- _getTicketsApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
4025
- var response, attributes;
4026
- return runtime_1.wrap(function _callee$(_context) {
4027
- while (1) {
4028
- switch (_context.prev = _context.next) {
4029
- case 0:
4030
- _context.prev = 0;
4031
- setIsLoading(true);
4032
- _context.next = 4;
4033
- return getTickets(eventId, promoCodeUpdated);
4034
-
4035
- case 4:
4036
- response = _context.sent;
4037
-
4038
- if (response.data.success) {
4039
- setCustomHeader(response);
4040
- attributes = _get(response, 'data.data.attributes');
4041
- setPromoCodeIsApplied(attributes.ValidPromoCode);
4042
- setTickets(_get(attributes, 'tickets'));
4043
- setShowWaitingList(attributes.showWaitingList);
4044
- onGetTicketsSuccess(response.data);
4045
- }
4238
+ var handleLogout = function handleLogout() {
4239
+ if (isWindowDefined) {
4240
+ window.localStorage.removeItem('access_token');
4241
+ window.localStorage.removeItem('user_data');
4242
+ setIsLogged(false);
4046
4243
 
4047
- _context.next = 11;
4048
- break;
4244
+ var _event = new window.CustomEvent('tf-logout');
4049
4245
 
4050
- case 8:
4051
- _context.prev = 8;
4052
- _context.t0 = _context["catch"](0);
4246
+ window.document.dispatchEvent(_event);
4247
+ }
4248
+ };
4053
4249
 
4054
- if (axios.isAxiosError(_context.t0)) {
4055
- onGetTicketsError(_context.t0);
4056
- }
4250
+ var handleExternalLogin = function handleExternalLogin() {
4251
+ setIsLogged(true);
4252
+ };
4057
4253
 
4058
- case 11:
4059
- _context.prev = 11;
4060
- setIsLoading(false);
4061
- return _context.finish(11);
4254
+ var handleOnClose = function handleOnClose() {
4255
+ setShowLoginModal(false);
4256
+ };
4062
4257
 
4063
- case 14:
4064
- case "end":
4065
- return _context.stop();
4066
- }
4067
- }
4068
- }, _callee, null, [[0, 8, 11, 14]]);
4069
- }));
4070
- return _getTicketsApi.apply(this, arguments);
4258
+ var handleOnLogin = function handleOnLogin() {
4259
+ setShowLoginModal(false);
4260
+ setIsLogged(true);
4261
+
4262
+ if (onLoginSuccess) {
4263
+ onLoginSuccess();
4071
4264
  }
4265
+ };
4072
4266
 
4073
- getTicketsApi();
4074
- }, [eventId, promoCodeUpdated]);
4267
+ function getTicketsApi() {
4268
+ return _getTicketsApi.apply(this, arguments);
4269
+ }
4270
+
4271
+ function _getTicketsApi() {
4272
+ _getTicketsApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
4273
+ var response, eventResponse, attributes, _event2;
4274
+
4275
+ return runtime_1.wrap(function _callee2$(_context2) {
4276
+ while (1) {
4277
+ switch (_context2.prev = _context2.next) {
4278
+ case 0:
4279
+ _context2.prev = 0;
4280
+ setIsLoading(true);
4281
+ _context2.next = 4;
4282
+ return getTickets(eventId, promoCodeUpdated);
4283
+
4284
+ case 4:
4285
+ response = _context2.sent;
4286
+ _context2.next = 7;
4287
+ return getEvent(eventId);
4288
+
4289
+ case 7:
4290
+ eventResponse = _context2.sent;
4291
+
4292
+ if (response.data.success) {
4293
+ setCustomHeader(response);
4294
+ attributes = _get(response, 'data.data.attributes');
4295
+ setPromoCodeIsApplied(attributes.ValidPromoCode);
4296
+ setTickets(_get(attributes, 'tickets'));
4297
+ setShowWaitingList(attributes.showWaitingList);
4298
+ onGetTicketsSuccess(response.data);
4299
+ }
4300
+
4301
+ if (eventResponse.data.success) {
4302
+ _event2 = _get(eventResponse, 'data.data.attributes');
4303
+ setEvent(_event2);
4304
+ }
4305
+
4306
+ _context2.next = 15;
4307
+ break;
4308
+
4309
+ case 12:
4310
+ _context2.prev = 12;
4311
+ _context2.t0 = _context2["catch"](0);
4312
+
4313
+ if (axios.isAxiosError(_context2.t0)) {
4314
+ onGetTicketsError(_context2.t0);
4315
+ }
4316
+
4317
+ case 15:
4318
+ _context2.prev = 15;
4319
+ setIsLoading(false);
4320
+ return _context2.finish(15);
4321
+
4322
+ case 18:
4323
+ case "end":
4324
+ return _context2.stop();
4325
+ }
4326
+ }
4327
+ }, _callee2, null, [[0, 12, 15, 18]]);
4328
+ }));
4329
+ return _getTicketsApi.apply(this, arguments);
4330
+ }
4075
4331
 
4076
4332
  var handleTicketSelect = function handleTicketSelect(key, value) {
4077
4333
  setSelectedTickets(function (prevState) {
@@ -4085,15 +4341,21 @@ var TicketsContainer = function TicketsContainer(_ref) {
4085
4341
  });
4086
4342
  };
4087
4343
 
4344
+ var handleOrdersClick = function handleOrdersClick() {
4345
+ if (isWindowDefined) {
4346
+ window.location.href = '/orders';
4347
+ }
4348
+ };
4349
+
4088
4350
  var handleBook = /*#__PURE__*/function () {
4089
- var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
4351
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
4090
4352
  var _product_options, _product_options2, _ticket_types;
4091
4353
 
4092
- var ticket, optionName, ticketId, ticketQuantity, data, result, _result$data$data$att, _result$data, _result$data$data, _result$data$data$att2, _result$data$data$att3, _result$data2, _result$data2$data, _result$data2$data$at, _result$data$data$att4, _result$data3, _result$data3$data, _result$data3$data$at;
4354
+ var ticket, optionName, ticketId, ticketQuantity, data, result, _result$data$data$att, _result$data, _result$data$data, _result$data$data$att2, _result$data$data$att3, _result$data2, _result$data2$data, _result$data2$data$at, _result$data$data$att4, _result$data3, _result$data3$data, _result$data3$data$at, skipBillingPage, nameIsRequired, ageIsRequired, hash, _isWindowDefined, userData, access_token, ticketsQuantity, checkoutBody, checkoutResult;
4093
4355
 
4094
- return runtime_1.wrap(function _callee2$(_context2) {
4356
+ return runtime_1.wrap(function _callee$(_context) {
4095
4357
  while (1) {
4096
- switch (_context2.prev = _context2.next) {
4358
+ switch (_context.prev = _context.next) {
4097
4359
  case 0:
4098
4360
  setHandleBookIsLoading(true);
4099
4361
  ticket = _find(tickets, function (item) {
@@ -4114,45 +4376,74 @@ var TicketsContainer = function TicketsContainer(_ref) {
4114
4376
  }, _ticket_types)
4115
4377
  }
4116
4378
  };
4117
- _context2.prev = 6;
4118
- _context2.next = 9;
4379
+ _context.prev = 6;
4380
+ _context.next = 9;
4119
4381
  return addToCart(eventId, data);
4120
4382
 
4121
4383
  case 9:
4122
- result = _context2.sent;
4123
-
4124
- if (result.status === 200) {
4125
- setCustomHeader(result);
4126
- onAddToCartSuccess({
4127
- skip_billing_page: (_result$data$data$att = result == null ? void 0 : (_result$data = result.data) == null ? void 0 : (_result$data$data = _result$data.data) == null ? void 0 : (_result$data$data$att2 = _result$data$data.attributes) == null ? void 0 : _result$data$data$att2.skip_billing_page) != null ? _result$data$data$att : false,
4128
- names_required: (_result$data$data$att3 = result == null ? void 0 : (_result$data2 = result.data) == null ? void 0 : (_result$data2$data = _result$data2.data) == null ? void 0 : (_result$data2$data$at = _result$data2$data.attributes) == null ? void 0 : _result$data2$data$at.names_required) != null ? _result$data$data$att3 : false,
4129
- age_required: (_result$data$data$att4 = result == null ? void 0 : (_result$data3 = result.data) == null ? void 0 : (_result$data3$data = _result$data3.data) == null ? void 0 : (_result$data3$data$at = _result$data3$data.attributes) == null ? void 0 : _result$data3$data$at.age_required) != null ? _result$data$data$att4 : false,
4130
- event_id: String(eventId)
4131
- });
4384
+ result = _context.sent;
4385
+
4386
+ if (!(result.status === 200)) {
4387
+ _context.next = 27;
4388
+ break;
4132
4389
  }
4133
4390
 
4134
- _context2.next = 16;
4391
+ setCustomHeader(result);
4392
+ skipBillingPage = (_result$data$data$att = result == null ? void 0 : (_result$data = result.data) == null ? void 0 : (_result$data$data = _result$data.data) == null ? void 0 : (_result$data$data$att2 = _result$data$data.attributes) == null ? void 0 : _result$data$data$att2.skip_billing_page) != null ? _result$data$data$att : false;
4393
+ nameIsRequired = (_result$data$data$att3 = result == null ? void 0 : (_result$data2 = result.data) == null ? void 0 : (_result$data2$data = _result$data2.data) == null ? void 0 : (_result$data2$data$at = _result$data2$data.attributes) == null ? void 0 : _result$data2$data$at.names_required) != null ? _result$data$data$att3 : false;
4394
+ ageIsRequired = (_result$data$data$att4 = result == null ? void 0 : (_result$data3 = result.data) == null ? void 0 : (_result$data3$data = _result$data3.data) == null ? void 0 : (_result$data3$data$at = _result$data3$data.attributes) == null ? void 0 : _result$data3$data$at.age_required) != null ? _result$data$data$att4 : false;
4395
+ hash = '';
4396
+
4397
+ if (!skipBillingPage) {
4398
+ _context.next = 26;
4399
+ break;
4400
+ }
4401
+
4402
+ // Get user data for checkout data
4403
+ _isWindowDefined = typeof window !== 'undefined';
4404
+ userData = _isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
4405
+ access_token = _isWindowDefined && window.localStorage.getItem('access_token') ? window.localStorage.getItem('access_token') || '' : '';
4406
+ ticketsQuantity = Object.keys(selectedTickets).length;
4407
+ checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketsQuantity, userData);
4408
+ _context.next = 24;
4409
+ return postOnCheckout(checkoutBody, access_token);
4410
+
4411
+ case 24:
4412
+ checkoutResult = _context.sent;
4413
+ hash = _get(checkoutResult, 'data.data.attributes.hash');
4414
+
4415
+ case 26:
4416
+ onAddToCartSuccess({
4417
+ skip_billing_page: skipBillingPage,
4418
+ names_required: nameIsRequired,
4419
+ age_required: ageIsRequired,
4420
+ event_id: String(eventId),
4421
+ hash: hash
4422
+ });
4423
+
4424
+ case 27:
4425
+ _context.next = 32;
4135
4426
  break;
4136
4427
 
4137
- case 13:
4138
- _context2.prev = 13;
4139
- _context2.t0 = _context2["catch"](6);
4428
+ case 29:
4429
+ _context.prev = 29;
4430
+ _context.t0 = _context["catch"](6);
4140
4431
 
4141
- if (axios.isAxiosError(_context2.t0)) {
4142
- onAddToCartError(_context2.t0);
4432
+ if (axios.isAxiosError(_context.t0)) {
4433
+ onAddToCartError(_context.t0);
4143
4434
  }
4144
4435
 
4145
- case 16:
4146
- _context2.prev = 16;
4436
+ case 32:
4437
+ _context.prev = 32;
4147
4438
  setHandleBookIsLoading(false);
4148
- return _context2.finish(16);
4439
+ return _context.finish(32);
4149
4440
 
4150
- case 19:
4441
+ case 35:
4151
4442
  case "end":
4152
- return _context2.stop();
4443
+ return _context.stop();
4153
4444
  }
4154
4445
  }
4155
- }, _callee2, null, [[6, 13, 16, 19]]);
4446
+ }, _callee, null, [[6, 29, 32, 35]]);
4156
4447
  }));
4157
4448
 
4158
4449
  return function handleBook() {
@@ -4160,9 +4451,25 @@ var TicketsContainer = function TicketsContainer(_ref) {
4160
4451
  };
4161
4452
  }();
4162
4453
 
4454
+ var updateTickets = function updateTickets() {
4455
+ getTicketsApi();
4456
+ };
4457
+
4163
4458
  var isAllTicketsSoldOut = !_some(tickets, function (item) {
4164
4459
  return !(item.sold_out || item.soldOut);
4165
4460
  });
4461
+ useEffect(function () {
4462
+ isWindowDefined && window.document.addEventListener('custom-logout', handleLogout);
4463
+ return function () {
4464
+ isWindowDefined && window.document.removeEventListener('custom-logout', handleLogout);
4465
+ };
4466
+ }, []);
4467
+ useEffect(function () {
4468
+ isWindowDefined && window.document.addEventListener('custom-login', handleExternalLogin);
4469
+ return function () {
4470
+ isWindowDefined && window.document.removeEventListener('custom-login', handleExternalLogin);
4471
+ };
4472
+ }, []);
4166
4473
  return React.createElement("div", {
4167
4474
  className: "get-tickets-page " + theme,
4168
4475
  style: contentStyle
@@ -4171,10 +4478,15 @@ var TicketsContainer = function TicketsContainer(_ref) {
4171
4478
  selectedTickets: selectedTickets,
4172
4479
  handleTicketSelect: handleTicketSelect,
4173
4480
  promoCodeIsApplied: promoCodeIsApplied
4174
- }), showWaitingList && React.createElement(WaitingList, {
4481
+ }), event != null && event.salesEnded ? React.createElement("p", null, "Sales for this event are closed.") : event != null && event.salesStart ? React.createElement(Countdown, {
4482
+ startDate: event.salesStart,
4483
+ timezone: event.timezone,
4484
+ title: "Sales start in:",
4485
+ message: "No tickets are currently available for this event.",
4486
+ callback: updateTickets
4487
+ }) : null, showWaitingList && React.createElement(WaitingList, {
4175
4488
  tickets: tickets,
4176
- eventId: eventId,
4177
- isPromotionsEnabled: isPromotionsEnabled
4489
+ eventId: eventId
4178
4490
  }), React.createElement(PromoCodeSection, {
4179
4491
  promoCode: promoCode,
4180
4492
  promoCodeIsApplied: promoCodeIsApplied,
@@ -4188,7 +4500,24 @@ var TicketsContainer = function TicketsContainer(_ref) {
4188
4500
  "aria-hidden": true,
4189
4501
  className: "book-button " + (handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0 ? 'disabled' : ''),
4190
4502
  onClick: !handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0 ? handleBook : function () {}
4191
- }, getTicketsLabel || 'GET TICKETS')));
4503
+ }, getTicketsLabel || 'GET TICKETS'), isLogged ? React.createElement("div", {
4504
+ className: "session-wrapper"
4505
+ }, React.createElement("span", {
4506
+ className: "session-container"
4507
+ }, React.createElement(Button$1, {
4508
+ variant: "outline-light",
4509
+ className: "session-buttons",
4510
+ onClick: handleOrdersClick
4511
+ }, "My Orders")), React.createElement("span", {
4512
+ className: "session-container"
4513
+ }, React.createElement(Button$1, {
4514
+ variant: "outline-light",
4515
+ className: "session-buttons",
4516
+ onClick: handleLogout
4517
+ }, "Log out"))) : ''), showLoginModal ? React.createElement(LoginModal, {
4518
+ onClose: handleOnClose,
4519
+ onLogin: handleOnLogin
4520
+ }) : null);
4192
4521
  };
4193
4522
 
4194
4523
  var EventInfoItem = function EventInfoItem(_ref) {
@@ -4396,9 +4725,9 @@ var TicketsTable = function TicketsTable(_ref) {
4396
4725
  var _ref$tickets = _ref.tickets,
4397
4726
  tickets = _ref$tickets === void 0 ? [] : _ref$tickets;
4398
4727
  return React.createElement("div", {
4399
- className: 'tickets-box'
4728
+ className: "tickets-box"
4400
4729
  }, React.createElement("h4", {
4401
- className: 'sub-title'
4730
+ className: "sub-title"
4402
4731
  }, "Your Tickets"), React.createElement(TableContainer, {
4403
4732
  component: Paper
4404
4733
  }, React.createElement(Table, {
@@ -4408,14 +4737,16 @@ var TicketsTable = function TicketsTable(_ref) {
4408
4737
 
4409
4738
  return React.createElement(Fragment, {
4410
4739
  key: index
4411
- }, React.createElement(TableRow, null, React.createElement(TableCell, null, ticket.hash), React.createElement(TableCell, null, ticket.ticket_type), React.createElement(TableCell, null, ticket.holder_name), React.createElement(TableCell, null, ticket.status), React.createElement(TableCell, null, React.createElement("a", {
4412
- className: 'download-button',
4413
- href: ticket.pdf_link,
4414
- download: true
4740
+ }, React.createElement(TableRow, null, React.createElement(TableCell, null, ticket.hash), React.createElement(TableCell, null, ticket.ticket_type), React.createElement(TableCell, null, ticket.holder_name), React.createElement(TableCell, null, ticket.status), React.createElement(TableCell, null, React.createElement("span", {
4741
+ "aria-hidden": true,
4742
+ className: "download-button",
4743
+ onClick: function onClick() {
4744
+ return downloadPDF(ticket.pdf_link);
4745
+ }
4415
4746
  }, "Download"))), !!((_ticket$add_ons = ticket.add_ons) != null && _ticket$add_ons.length) && React.createElement(TableRow, null, React.createElement(TableCell, {
4416
4747
  colSpan: 5
4417
4748
  }, React.createElement(Table, {
4418
- className: 'ticket-add-on-table'
4749
+ className: "ticket-add-on-table"
4419
4750
  }, React.createElement(TableHead, null, React.createElement(TableRow, null, React.createElement(TableCell, null, "Add-On"), React.createElement(TableCell, null, "Status"))), React.createElement(TableBody, null, ticket.add_ons.map(function (add_on, index) {
4420
4751
  return React.createElement(TableRow, {
4421
4752
  key: index