tf-checkout-react 1.3.39-beta.2 → 1.3.40

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.
@@ -1205,7 +1205,7 @@ var createElementFromHTML = function createElementFromHTML(htmlString) {
1205
1205
  var div = document.createElement('div');
1206
1206
  div.innerHTML = htmlString.trim(); // Change this to div.childNodes to support multiple top-level nodes.
1207
1207
 
1208
- return div.firstChild || '';
1208
+ return div.childNodes || [];
1209
1209
  };
1210
1210
 
1211
1211
  var isWindowDefined = typeof window !== 'undefined';
@@ -1610,34 +1610,75 @@ var getCheckoutPageConfigs = /*#__PURE__*/function () {
1610
1610
  }();
1611
1611
 
1612
1612
  var usePixel = /*#__PURE__*/function () {
1613
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(key, eventId) {
1614
- var getEventData;
1613
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(key, eventId, alreadyLoadedEventData) {
1614
+ var addPixel, getEventData;
1615
1615
  return runtime_1.wrap(function _callee2$(_context2) {
1616
1616
  while (1) {
1617
1617
  switch (_context2.prev = _context2.next) {
1618
1618
  case 0:
1619
+ addPixel = function addPixel(pixel) {
1620
+ var _document;
1621
+
1622
+ if ((_document = document) != null && _document.head && pixel) {
1623
+ var nodes = createElementFromHTML(pixel);
1624
+
1625
+ for (var _i = 0, _Array$from = Array.from(nodes); _i < _Array$from.length; _i++) {
1626
+ var element = _Array$from[_i];
1627
+ document.head.append(element);
1628
+ }
1629
+ }
1630
+ };
1631
+
1619
1632
  getEventData = /*#__PURE__*/function () {
1620
1633
  var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1621
- var _document;
1622
-
1623
- var eventResponse, event, pixel;
1634
+ var isEventDataUndefined, eventResponse, event, pixel;
1624
1635
  return runtime_1.wrap(function _callee$(_context) {
1625
1636
  while (1) {
1626
1637
  switch (_context.prev = _context.next) {
1627
1638
  case 0:
1628
- _context.next = 2;
1629
- return getEvent(eventId);
1639
+ if (eventId) {
1640
+ _context.next = 2;
1641
+ break;
1642
+ }
1643
+
1644
+ return _context.abrupt("return");
1630
1645
 
1631
1646
  case 2:
1632
- eventResponse = _context.sent;
1633
- event = _get(eventResponse, 'data.data.attributes');
1634
- pixel = event[key];
1647
+ // Check if event data object passed or not. If not then the value will be undefined.
1648
+ // If event data passed, then it's initial value will be null.
1649
+ isEventDataUndefined = alreadyLoadedEventData === undefined;
1635
1650
 
1636
- if ((_document = document) != null && _document.head && pixel) {
1637
- document.head.append(createElementFromHTML(pixel));
1651
+ if (!isEventDataUndefined) {
1652
+ _context.next = 9;
1653
+ break;
1638
1654
  }
1639
1655
 
1656
+ _context.next = 6;
1657
+ return getEvent(eventId);
1658
+
1640
1659
  case 6:
1660
+ _context.t0 = _context.sent;
1661
+ _context.next = 10;
1662
+ break;
1663
+
1664
+ case 9:
1665
+ _context.t0 = null;
1666
+
1667
+ case 10:
1668
+ eventResponse = _context.t0;
1669
+ event = isEventDataUndefined ? _get(eventResponse, 'data.data.attributes', {}) : alreadyLoadedEventData || {};
1670
+
1671
+ if (typeof key === 'string') {
1672
+ pixel = event[key];
1673
+ addPixel(pixel);
1674
+ } else {
1675
+ _forEach(key, function (item) {
1676
+ var pixel = event[item];
1677
+ addPixel(pixel);
1678
+ });
1679
+ }
1680
+
1681
+ case 13:
1641
1682
  case "end":
1642
1683
  return _context.stop();
1643
1684
  }
@@ -1651,10 +1692,10 @@ var usePixel = /*#__PURE__*/function () {
1651
1692
  }();
1652
1693
 
1653
1694
  useEffect(function () {
1654
- getEventData();
1655
- }, []);
1695
+ getEventData(); // eslint-disable-next-line react-hooks/exhaustive-deps
1696
+ }, [eventId, alreadyLoadedEventData]);
1656
1697
 
1657
- case 2:
1698
+ case 3:
1658
1699
  case "end":
1659
1700
  return _context2.stop();
1660
1701
  }
@@ -1662,7 +1703,7 @@ var usePixel = /*#__PURE__*/function () {
1662
1703
  }, _callee2);
1663
1704
  }));
1664
1705
 
1665
- return function usePixel(_x, _x2) {
1706
+ return function usePixel(_x, _x2, _x3) {
1666
1707
  return _ref.apply(this, arguments);
1667
1708
  };
1668
1709
  }();
@@ -3637,7 +3678,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref4) {
3637
3678
  return item.code.toLowerCase() === defaultCountry;
3638
3679
  }) || {};
3639
3680
  var initialCountry = selectedCountry.id || _get(userData, 'country', '') || '1';
3640
- usePixel('checkoutPixels', eventId);
3681
+ usePixel(['checkoutPixels', 'brandCheckoutPixels'], eventId);
3641
3682
  return React.createElement(ThemeProvider, {
3642
3683
  theme: themeMui
3643
3684
  }, (loading || isCountriesLoading) && React.createElement(Backdrop, {
@@ -5055,7 +5096,7 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
5055
5096
  confirmationMain = _confirmationLabels$c2 === void 0 ? 'Your tickets are available in My Tickets section' : _confirmationLabels$c2,
5056
5097
  _confirmationLabels$c3 = confirmationLabels.confirmationHelper,
5057
5098
  confirmationHelper = _confirmationLabels$c3 === void 0 ? 'Please bring them with you to the event' : _confirmationLabels$c3;
5058
- usePixel('conversionPixels', data == null ? void 0 : data.product_id);
5099
+ usePixel(['conversionPixels', 'brandConversionPixels'], data == null ? void 0 : data.product_id);
5059
5100
  return React.createElement("div", {
5060
5101
  className: "confirmation-page"
5061
5102
  }, data && React.createElement(React.Fragment, null, React.createElement("div", {
@@ -5919,7 +5960,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5919
5960
  useCookieListener(X_TF_ECOMMERCE, function (value) {
5920
5961
  return setIsLogged(Boolean(value));
5921
5962
  });
5922
- usePixel('pagePixels', eventId);
5963
+ usePixel(['pagePixels', 'brandPagePixels'], eventId, event);
5923
5964
  useEffect(function () {
5924
5965
  if (typeof window !== 'undefined') {
5925
5966
  var access_token = window.localStorage.getItem('access_token');