{"ast":null,"code":"import _regeneratorRuntime from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/regenerator\";\nimport _classCallCheck from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/inherits\";\nimport _possibleConstructorReturn from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn\";\nimport _getPrototypeOf from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/getPrototypeOf\";\nimport _asyncToGenerator from \"/home/jjglover/goallinestats/node_modules/@babel/runtime/helpers/esm/asyncToGenerator\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nimport React from 'react';\nimport axios from 'axios';\nimport MakeTable from '../components/table.js';\nimport BuildSortFilter from '../components/playerSortFilter.js';\n\nfunction fetchStats(_x) {\n  return _fetchStats.apply(this, arguments);\n}\n\nfunction _fetchStats() {\n  _fetchStats = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(parameters) {\n    var arrayData;\n    return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n      while (1) {\n        switch (_context2.prev = _context2.next) {\n          case 0:\n            _context2.next = 2;\n            return axios.get(parameters);\n\n          case 2:\n            arrayData = _context2.sent;\n            DataTableContent = arrayData.data;\n            return _context2.abrupt(\"return\", DataTableContent);\n\n          case 5:\n          case \"end\":\n            return _context2.stop();\n        }\n      }\n    }, _callee2);\n  }));\n  return _fetchStats.apply(this, arguments);\n}\n\nvar TableBuilder = /*#__PURE__*/function (_React$Component) {\n  _inherits(TableBuilder, _React$Component);\n\n  var _super = _createSuper(TableBuilder);\n\n  function TableBuilder(props) {\n    var _this;\n\n    _classCallCheck(this, TableBuilder);\n\n    _this = _super.call(this, props);\n    _this.state = {\n      options: {\n        sort: null,\n        group: null,\n        goalie: null,\n        page: null,\n        subseasonid: null,\n        subgoalie: null\n      },\n      baseURL: _this.props.baseURL,\n      displayTable: _this.props.props.dataarray //displayOptions: this.props.displayOptions\n\n    };\n    _this.updateTable = _this.updateTable.bind(_assertThisInitialized(_this));\n    return _this;\n  }\n\n  _createClass(TableBuilder, [{\n    key: \"updateTable\",\n    value: function () {\n      var _updateTable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(sortset, text) {\n        var updateText, currentState, getParameters, startParameters, currentOptions, index, requestURL, refreshTable, newTable;\n        return _regeneratorRuntime.wrap(function _callee$(_context) {\n          while (1) {\n            switch (_context.prev = _context.next) {\n              case 0:\n                updateText = sortset + '=' + text;\n                currentState = this.state.options;\n\n                if (sortset == 'sort') {\n                  currentState.sort = updateText;\n                  this.setState(function (state) {\n                    return {\n                      options: currentState\n                    };\n                  });\n                } else if (sortset == 'group') {\n                  currentState.group = updateText;\n                } else if (sortset == 'page') {\n                  currentState.page = updateText;\n                } else if (sortset == 'subseasonid') {\n                  currentState.subseasonid = updateText;\n                } else if (sortset == 'subgoalie') {\n                  currentState.subgoalie = updateText;\n                } else if (sortset == 'goalie') {\n                  currentState.goalie = updateText;\n                  currentState.sort = '';\n                  currentState.group = '';\n                  currentState.page = '';\n                  currentState.subseasonid = '';\n                  currentState.subgoalie = '';\n                }\n\n                this.setState(function (state) {\n                  return {\n                    options: currentState\n                  };\n                });\n                getParameters = decodeURIComponent(window.location.search.substring(1));\n                startParameters = this.state.baseURL + getParameters;\n                currentOptions = '';\n\n                for (index in this.state.options) {\n                  if (this.state.options[index] != null) {\n                    currentOptions += this.state.options[index] + '&';\n                  }\n                }\n\n                currentOptions = currentOptions.slice(0, -1);\n                console.log(startParameters != '&');\n\n                if (startParameters != '&') {\n                  startParameters += '&';\n                }\n\n                requestURL = startParameters + currentOptions;\n                _context.next = 14;\n                return fetchStats(requestURL);\n\n              case 14:\n                refreshTable = _context.sent;\n                newTable = MakeTable(refreshTable);\n                this.setState(function (state) {\n                  return {\n                    //displayOptions: BuildSortFilter(refreshTable),\n                    displayTable: newTable\n                  };\n                });\n\n              case 17:\n              case \"end\":\n                return _context.stop();\n            }\n          }\n        }, _callee, this);\n      }));\n\n      function updateTable(_x2, _x3) {\n        return _updateTable.apply(this, arguments);\n      }\n\n      return updateTable;\n    }()\n  }, {\n    key: \"render\",\n    value: function render() {\n      //console.log(this.props.props.dataarray)\n      return /*#__PURE__*/_jsxs(\"div\", {\n        children: [/*#__PURE__*/_jsx(BuildSortFilter, {\n          props: this.props.props,\n          updateTable: this.updateTable\n        }), /*#__PURE__*/_jsx(MakeTable, {\n          currentset: this.props.props\n        })]\n      });\n    }\n  }]);\n\n  return TableBuilder;\n}(React.Component);\n\nexport { TableBuilder as default };","map":null,"metadata":{},"sourceType":"module"}