diff --git a/.gitignore b/.gitignore index 2e72d77..2b5e3df 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,3 @@ typings/ # configuration config.js -client/dist/bundle.js \ No newline at end of file diff --git a/client/dist/bundle.js b/client/dist/bundle.js index d36269f..57d7a33 100644 --- a/client/dist/bundle.js +++ b/client/dist/bundle.js @@ -130,7 +130,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var reac /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @material-ui/core/styles */ \"./node_modules/@material-ui/core/styles/index.js\");\n/* harmony import */ var _material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _material_ui_core_Paper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @material-ui/core/Paper */ \"./node_modules/@material-ui/core/Paper/index.js\");\n/* harmony import */ var _material_ui_core_Paper__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_Paper__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @material-ui/core/Grid */ \"./node_modules/@material-ui/core/Grid/index.js\");\n/* harmony import */ var _material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _LeadInfo_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./LeadInfo.jsx */ \"./client/src/components/LeadInfo.jsx\");\n/* harmony import */ var _ButtonList_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ButtonList.jsx */ \"./client/src/components/ButtonList.jsx\");\n/* harmony import */ var _ContactList_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ContactList.jsx */ \"./client/src/components/ContactList.jsx\");\n/* harmony import */ var _SearchView_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./SearchView.jsx */ \"./client/src/components/SearchView.jsx\");\n/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-router */ \"./node_modules/react-router/esm/react-router.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var _AuthService_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./AuthService.js */ \"./client/src/components/AuthService.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar DashBody =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(DashBody, _React$Component);\n\n function DashBody(props) {\n var _this;\n\n _classCallCheck(this, DashBody);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(DashBody).call(this, props));\n _this.state = {\n // userId = null,\n leads: [{\n name: 'patrick ryan',\n company: 'zlien',\n id: 1\n }, {\n name: 'winntana B.',\n company: 'Operation Spark',\n id: 2\n }, {\n name: 'arnulfo Man',\n company: 'guitar'\n }],\n selectedView: null,\n uploaded: [],\n purchased: [],\n currentLead: {},\n contact: null,\n searchedContacts: [],\n contactView: null,\n renderContactList: false,\n commentBodyText: '',\n comments: [{\n date: 'Add comments to keep track of your leads!',\n comment: 'The easiest place to keep track of lead data!'\n }],\n username: ''\n };\n var classes = props.classes;\n DashBody.propTypes = {\n classes: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.object.isRequired\n };\n _this.selectView = _this.selectView.bind(_assertThisInitialized(_this));\n _this.selectContact = _this.selectContact.bind(_assertThisInitialized(_this));\n _this.searchContact = _this.searchContact.bind(_assertThisInitialized(_this));\n _this.uploadedView = _this.uploadedView.bind(_assertThisInitialized(_this));\n _this.purchasedView = _this.purchasedView.bind(_assertThisInitialized(_this));\n _this.uploadContact = _this.uploadContact.bind(_assertThisInitialized(_this));\n _this.contactPurchase = _this.contactPurchase.bind(_assertThisInitialized(_this));\n _this.renderContactList = _this.renderContactList.bind(_assertThisInitialized(_this));\n _this.handleComment = _this.handleComment.bind(_assertThisInitialized(_this));\n _this.commentBody = _this.commentBody.bind(_assertThisInitialized(_this));\n _this.showModal = _this.showModal.bind(_assertThisInitialized(_this));\n return _this;\n }\n\n _createClass(DashBody, [{\n key: \"componentWillMount\",\n value: function componentWillMount() {\n this.props.history.push('/dashboard');\n document.body.style.backgroundImage = 'none';\n this.props.getUserPoints();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n document.body.style.backgroundImage = \"url('./leaddeal.png')\";\n }\n }, {\n key: \"showModal\",\n value: function showModal() {\n console.log('modal');\n }\n }, {\n key: \"selectView\",\n value: function selectView(button) {\n this.setState({\n selectedView: button\n });\n }\n }, {\n key: \"uploadedView\",\n value: function uploadedView() {\n var _this2 = this;\n\n this.props.auth.fetch(\"/api/users/\".concat(this.props.userId, \"/uploaded_contacts\")).then(function (uploadedContacts) {\n console.log(uploadedContacts);\n\n _this2.setState({\n uploaded: uploadedContacts,\n selectedView: 'uploaded'\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n }\n }, {\n key: \"purchasedView\",\n value: function purchasedView() {\n var _this3 = this;\n\n this.props.auth.fetch(\"/api/users/\".concat(this.props.userId, \"/purchased_contacts\")).then(function (purchasedContacts) {\n console.log(purchasedContacts);\n\n _this3.setState({\n purchased: purchasedContacts,\n selectedView: 'purchased'\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n }\n }, {\n key: \"selectContact\",\n value: function selectContact(contactId, list, view) {\n var _this4 = this;\n\n if (view === 'access') {\n var contact = this.state[list].filter(function (contact) {\n return contact.id === contactId;\n })[0];\n this.props.auth.fetch(\"/api/users/comments/\".concat(this.props.userId, \"/\").concat(contactId)).then(function (comments) {\n var revComments = comments.reverse();\n\n _this4.setState({\n comments: revComments\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n this.setState({\n currentLead: contact,\n contactView: 'access'\n });\n } else {\n var _contact = this.state.searchedContacts.filter(function (contact) {\n return contact.id === contactId;\n })[0];\n this.setState({\n currentLead: _contact,\n contactView: 'limited'\n });\n }\n }\n }, {\n key: \"searchContact\",\n value: function searchContact(query) {\n var _this5 = this;\n\n //console.log(query)\n var options = {\n method: 'POST',\n body: JSON.stringify(query)\n };\n this.props.auth.fetch(\"/api/users/search/\".concat(this.props.userId), options).then(function (contacts) {\n console.log('im inside this contact', contacts);\n\n _this5.setState({\n searchedContacts: contacts,\n selectedView: 'searched'\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n }\n }, {\n key: \"uploadContact\",\n value: function uploadContact(contact) {\n var _this6 = this;\n\n console.log(this.props.userId);\n var options = {\n method: 'POST',\n body: JSON.stringify(contact)\n };\n this.props.auth.fetch2(\"/api/users/\".concat(this.props.userId, \"/upload\"), options).then(function (response) {\n _this6.props.getUserPoints();\n })[\"catch\"](function (err) {\n console.error(err);\n });\n }\n }, {\n key: \"contactPurchase\",\n value: function contactPurchase(event, contactId) {\n var _this7 = this;\n\n console.log(event.target.innerHTML);\n\n if (this.props.points > 0) {\n var options = {\n method: 'POST'\n };\n this.props.auth.fetch(\"/api/users/purchase_contact/\".concat(this.props.userId, \"/\").concat(contactId), options).then(function (result) {\n console.log('i have just purchased this contact', result);\n\n _this7.props.getUserPoints(); // document.getElementById('purchase-button').innerHTML = 'Contact Purchased';\n // document.getElementById('purchase-button').style.color = 'grey';\n\n\n event.target.innerHTML = 'Contact Purchased';\n event.target.style.color = 'grey';\n })[\"catch\"](function (err) {\n console.log(err);\n });\n } else {\n alert('You do not have enough points to complete this purchase. Please upload more contacts to obtain more points');\n }\n }\n }, {\n key: \"handleComment\",\n value: function handleComment(event) {\n var _this8 = this;\n\n event.preventDefault();\n var comment = {};\n comment.body = this.state.commentBodyText;\n var options = {\n method: 'POST',\n body: JSON.stringify(comment)\n };\n this.props.auth.fetch(\"/api/users/comments/\".concat(this.props.userId, \"/\").concat(this.state.currentLead.id), options).then(function (comments) {\n var revComments = comments.reverse();\n\n _this8.setState({\n commentBodyText: '',\n comments: revComments\n });\n })[\"catch\"](function (err) {\n console.log(err);\n\n _this8.setState({\n commentBodyText: ''\n });\n });\n }\n }, {\n key: \"commentBody\",\n value: function commentBody(comment) {\n this.setState({\n commentBodyText: comment\n });\n }\n }, {\n key: \"renderContactList\",\n value: function renderContactList() {\n this.setState({\n renderContactList: true\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n if (this.state.renderContactList) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n container: true,\n spacing: 24\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: true\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"left-top-display\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_ButtonList_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n selectView: this.selectView,\n uploadedView: this.uploadedView,\n purchasedView: this.purchasedView,\n renderContactList: this.renderContactList,\n showModal: this.showModal\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"left-bottom-display\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_ContactList_jsx__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n uploaded: this.state.uploaded,\n purchased: this.state.purchased,\n selectedView: this.state.selectedView,\n selectContact: this.selectContact,\n searchContact: this.searchContact,\n uploadContact: this.uploadContact\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_SearchView_jsx__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n searchedContacts: this.state.searchedContacts,\n selectedView: this.state.selectedView,\n selectContact: this.selectContact\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: 9\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_LeadInfo_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n currentLead: this.state.currentLead,\n contactView: this.state.contactView,\n contactPurchase: this.contactPurchase,\n commentBody: this.commentBody,\n handleComment: this.handleComment,\n comments: this.state.comments,\n commentBodyText: this.state.commentBodyText\n }))));\n } else {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n container: true,\n spacing: 24\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: true\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"left-top-display\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_ButtonList_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n selectView: this.selectView,\n uploadedView: this.uploadedView,\n purchasedView: this.purchasedView,\n renderContactList: this.renderContactList\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: 9\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_LeadInfo_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n currentLead: this.state.currentLead,\n contactView: this.state.contactView,\n contactPurchase: this.contactPurchase\n }))));\n }\n }\n }]);\n\n return DashBody;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\nvar styles = function styles(theme) {\n return {\n root: {\n flexGrow: 1\n },\n paper: {\n padding: theme.spacing.unit * 2,\n textAlign: 'center',\n color: theme.palette.text.secondary\n }\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Object(react_router__WEBPACK_IMPORTED_MODULE_9__[\"withRouter\"])(Object(_material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2__[\"withStyles\"])(styles)(DashBody)));\n\n//# sourceURL=webpack:///./client/src/components/DashBody.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @material-ui/core/styles */ \"./node_modules/@material-ui/core/styles/index.js\");\n/* harmony import */ var _material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _material_ui_core_Paper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @material-ui/core/Paper */ \"./node_modules/@material-ui/core/Paper/index.js\");\n/* harmony import */ var _material_ui_core_Paper__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_Paper__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @material-ui/core/Grid */ \"./node_modules/@material-ui/core/Grid/index.js\");\n/* harmony import */ var _material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _LeadInfo_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./LeadInfo.jsx */ \"./client/src/components/LeadInfo.jsx\");\n/* harmony import */ var _ButtonList_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ButtonList.jsx */ \"./client/src/components/ButtonList.jsx\");\n/* harmony import */ var _ContactList_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ContactList.jsx */ \"./client/src/components/ContactList.jsx\");\n/* harmony import */ var _SearchView_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./SearchView.jsx */ \"./client/src/components/SearchView.jsx\");\n/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-router */ \"./node_modules/react-router/esm/react-router.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var _AuthService_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./AuthService.js */ \"./client/src/components/AuthService.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar DashBody =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(DashBody, _React$Component);\n\n function DashBody(props) {\n var _this;\n\n _classCallCheck(this, DashBody);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(DashBody).call(this, props));\n _this.state = {\n // userId = null,\n leads: [{\n name: 'patrick ryan',\n company: 'zlien',\n id: 1\n }, {\n name: 'winntana B.',\n company: 'Operation Spark',\n id: 2\n }, {\n name: 'arnulfo Man',\n company: 'guitar'\n }],\n selectedView: null,\n uploaded: [],\n purchased: [],\n currentLead: {},\n contact: null,\n searchedContacts: [],\n contactView: null,\n renderContactList: false,\n commentBodyText: '',\n comments: [{\n date: 'Add comments to keep track of your leads!',\n comment: 'The easiest place to keep track of lead data!'\n }],\n username: ''\n };\n var classes = props.classes;\n DashBody.propTypes = {\n classes: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.object.isRequired\n };\n _this.selectView = _this.selectView.bind(_assertThisInitialized(_this));\n _this.selectContact = _this.selectContact.bind(_assertThisInitialized(_this));\n _this.searchContact = _this.searchContact.bind(_assertThisInitialized(_this));\n _this.uploadedView = _this.uploadedView.bind(_assertThisInitialized(_this));\n _this.purchasedView = _this.purchasedView.bind(_assertThisInitialized(_this));\n _this.uploadContact = _this.uploadContact.bind(_assertThisInitialized(_this));\n _this.contactPurchase = _this.contactPurchase.bind(_assertThisInitialized(_this));\n _this.renderContactList = _this.renderContactList.bind(_assertThisInitialized(_this));\n _this.handleComment = _this.handleComment.bind(_assertThisInitialized(_this));\n _this.commentBody = _this.commentBody.bind(_assertThisInitialized(_this));\n _this.showModal = _this.showModal.bind(_assertThisInitialized(_this));\n return _this;\n }\n\n _createClass(DashBody, [{\n key: \"componentWillMount\",\n value: function componentWillMount() {\n this.props.history.push('/dashboard');\n document.body.style.backgroundImage = 'none';\n this.props.getUserPoints();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n document.body.style.backgroundImage = \"url('./leaddeal.png')\";\n }\n }, {\n key: \"showModal\",\n value: function showModal() {\n console.log('modal');\n }\n }, {\n key: \"selectView\",\n value: function selectView(button) {\n this.setState({\n selectedView: button\n });\n }\n }, {\n key: \"uploadedView\",\n value: function uploadedView() {\n var _this2 = this;\n\n this.props.auth.fetch(\"/api/users/\".concat(this.props.userId, \"/uploaded_contacts\")).then(function (uploadedContacts) {\n console.log(uploadedContacts);\n\n _this2.setState({\n uploaded: uploadedContacts,\n selectedView: 'uploaded'\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n }\n }, {\n key: \"purchasedView\",\n value: function purchasedView() {\n var _this3 = this;\n\n this.props.auth.fetch(\"/api/users/\".concat(this.props.userId, \"/purchased_contacts\")).then(function (purchasedContacts) {\n console.log(purchasedContacts);\n\n _this3.setState({\n purchased: purchasedContacts,\n selectedView: 'purchased'\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n }\n }, {\n key: \"selectContact\",\n value: function selectContact(contactId, list, view) {\n var _this4 = this;\n\n if (view === 'access') {\n var contact = this.state[list].filter(function (contact) {\n return contact.id === contactId;\n })[0];\n this.props.auth.fetch(\"/api/users/comments/\".concat(this.props.userId, \"/\").concat(contactId)).then(function (comments) {\n var revComments = comments.reverse();\n\n _this4.setState({\n comments: revComments\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n this.setState({\n currentLead: contact,\n contactView: 'access'\n });\n } else {\n var _contact = this.state.searchedContacts.filter(function (contact) {\n return contact.id === contactId;\n })[0];\n this.setState({\n currentLead: _contact,\n contactView: 'limited'\n });\n }\n }\n }, {\n key: \"searchContact\",\n value: function searchContact(query) {\n var _this5 = this;\n\n //console.log(query)\n var options = {\n method: 'POST',\n body: JSON.stringify(query)\n };\n this.props.auth.fetch(\"/api/users/search/\".concat(this.props.userId), options).then(function (contacts) {\n console.log('im inside this contact', contacts);\n\n _this5.setState({\n searchedContacts: contacts,\n selectedView: 'searched'\n });\n })[\"catch\"](function (err) {\n console.log(err);\n });\n }\n }, {\n key: \"uploadContact\",\n value: function uploadContact(contact) {\n var _this6 = this;\n\n console.log(this.props.userId);\n var options = {\n method: 'POST',\n body: JSON.stringify(contact)\n };\n this.props.auth.fetch2(\"/api/users/\".concat(this.props.userId, \"/upload\"), options).then(function (response) {\n _this6.props.getUserPoints();\n\n _this6.setState({\n currentLead: contact,\n contactView: 'access'\n });\n })[\"catch\"](function (err) {\n console.error(err);\n });\n }\n }, {\n key: \"contactPurchase\",\n value: function contactPurchase(event, contactId) {\n var _this7 = this;\n\n console.log(event.target.innerHTML);\n\n if (this.props.points > 0) {\n var options = {\n method: 'POST'\n };\n this.props.auth.fetch(\"/api/users/purchase_contact/\".concat(this.props.userId, \"/\").concat(contactId), options).then(function (result) {\n console.log('i have just purchased this contact', result);\n\n _this7.props.getUserPoints(); // document.getElementById('purchase-button').innerHTML = 'Contact Purchased';\n // document.getElementById('purchase-button').style.color = 'grey';\n\n\n event.target.innerHTML = 'Contact Purchased';\n event.target.style.color = 'grey';\n })[\"catch\"](function (err) {\n console.log(err);\n });\n } else {\n alert('You do not have enough points to complete this purchase. Please upload more contacts to obtain more points');\n }\n }\n }, {\n key: \"handleComment\",\n value: function handleComment(event) {\n var _this8 = this;\n\n event.preventDefault();\n var comment = {};\n comment.body = this.state.commentBodyText;\n var options = {\n method: 'POST',\n body: JSON.stringify(comment)\n };\n this.props.auth.fetch(\"/api/users/comments/\".concat(this.props.userId, \"/\").concat(this.state.currentLead.id), options).then(function (comments) {\n var revComments = comments.reverse();\n\n _this8.setState({\n commentBodyText: '',\n comments: revComments\n });\n })[\"catch\"](function (err) {\n console.log(err);\n\n _this8.setState({\n commentBodyText: ''\n });\n });\n }\n }, {\n key: \"commentBody\",\n value: function commentBody(comment) {\n this.setState({\n commentBodyText: comment\n });\n }\n }, {\n key: \"renderContactList\",\n value: function renderContactList() {\n this.setState({\n renderContactList: true\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n if (this.state.renderContactList) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n container: true,\n spacing: 24\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: true\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"left-top-display\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_ButtonList_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n selectView: this.selectView,\n uploadedView: this.uploadedView,\n purchasedView: this.purchasedView,\n renderContactList: this.renderContactList,\n showModal: this.showModal\n })), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"left-bottom-display\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_ContactList_jsx__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n uploaded: this.state.uploaded,\n purchased: this.state.purchased,\n selectedView: this.state.selectedView,\n selectContact: this.selectContact,\n searchContact: this.searchContact,\n uploadContact: this.uploadContact\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_SearchView_jsx__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n searchedContacts: this.state.searchedContacts,\n selectedView: this.state.selectedView,\n selectContact: this.selectContact\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: 9\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_LeadInfo_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n currentLead: this.state.currentLead,\n contactView: this.state.contactView,\n contactPurchase: this.contactPurchase,\n commentBody: this.commentBody,\n handleComment: this.handleComment,\n comments: this.state.comments,\n commentBodyText: this.state.commentBodyText\n }))));\n } else {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n container: true,\n spacing: 24\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: true\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"left-top-display\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_ButtonList_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n selectView: this.selectView,\n uploadedView: this.uploadedView,\n purchasedView: this.purchasedView,\n renderContactList: this.renderContactList\n }))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_4___default.a, {\n item: true,\n xs: 9\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_LeadInfo_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n currentLead: this.state.currentLead,\n contactView: this.state.contactView,\n contactPurchase: this.contactPurchase\n }))));\n }\n }\n }]);\n\n return DashBody;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\nvar styles = function styles(theme) {\n return {\n root: {\n flexGrow: 1\n },\n paper: {\n padding: theme.spacing.unit * 2,\n textAlign: 'center',\n color: theme.palette.text.secondary\n }\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Object(react_router__WEBPACK_IMPORTED_MODULE_9__[\"withRouter\"])(Object(_material_ui_core_styles__WEBPACK_IMPORTED_MODULE_2__[\"withStyles\"])(styles)(DashBody)));\n\n//# sourceURL=webpack:///./client/src/components/DashBody.jsx?"); /***/ }), @@ -226,7 +226,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var reac /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _material_ui_core_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @material-ui/core/Button */ \"./node_modules/@material-ui/core/Button/index.js\");\n/* harmony import */ var _material_ui_core_Button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_Button__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _components_DashboardHeader_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/DashboardHeader.jsx */ \"./client/src/components/DashboardHeader.jsx\");\n/* harmony import */ var _components_DashBody_jsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/DashBody.jsx */ \"./client/src/components/DashBody.jsx\");\n/* harmony import */ var _components_Login_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/Login.jsx */ \"./client/src/components/Login.jsx\");\n/* harmony import */ var _components_Register_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/Register.jsx */ \"./client/src/components/Register.jsx\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var _components_AuthService_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./components/AuthService.js */ \"./client/src/components/AuthService.js\");\n/* harmony import */ var _components_UserHeader_jsx__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./components/UserHeader.jsx */ \"./client/src/components/UserHeader.jsx\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n\n\n\n\n\n //Material UI stuff\n\nvar styles = {\n paperContainer: {\n backgroundImage: \"url(\".concat(Image, \")\")\n }\n};\n\nvar App =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(App, _React$Component);\n\n function App(props) {\n var _this;\n\n _classCallCheck(this, App);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(App).call(this, props));\n _this.state = {\n isLoggedin: false,\n userId: null,\n redirectTo: '',\n username: '',\n points: null\n };\n _this.registerUser = _this.registerUser.bind(_assertThisInitialized(_this));\n _this.loginUser = _this.loginUser.bind(_assertThisInitialized(_this));\n _this.logOutUser = _this.logOutUser.bind(_assertThisInitialized(_this));\n _this.getUserPoints = _this.getUserPoints.bind(_assertThisInitialized(_this));\n _this.Auth = new _components_AuthService_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"]();\n _this.showModal = _this.showModal.bind(_assertThisInitialized(_this));\n return _this;\n }\n\n _createClass(App, [{\n key: \"componentWillMount\",\n value: function componentWillMount() {// if (this.Auth.loggedIn()){\n // this.setState({\n // isLoggedin: true,\n // redirectTo: '/dashboard'\n // })\n // } else{\n // this.setState({\n // isLoggedin: false\n // })\n // }\n }\n }, {\n key: \"showModal\",\n value: function showModal() {\n console.log('modal');\n }\n }, {\n key: \"getUserPoints\",\n value: function getUserPoints() {\n var _this2 = this;\n\n this.Auth.fetch(\"/api/users/\".concat(this.state.userId)).then(function (user) {\n _this2.setState({\n points: user.points\n });\n })[\"catch\"](function (err) {\n console.error(err);\n });\n }\n }, {\n key: \"registerUser\",\n value: function registerUser(user) {\n var _this3 = this;\n\n axios__WEBPACK_IMPORTED_MODULE_8___default.a.post('/api/auth/signup', user).then(function (response) {\n console.log(response);\n\n if (response.data) {\n console.log('succesful signup');\n\n _this3.setState({\n redirectTo: '/login'\n });\n } else {\n console.log('signup error');\n }\n })[\"catch\"](function (err) {\n console.log('sign up server error', err);\n });\n }\n }, {\n key: \"loginUser\",\n value: function loginUser(username, password) {\n var _this4 = this;\n\n this.Auth.login(username, password).then(function (res) {\n console.log(res);\n\n _this4.setState({\n isLoggedin: true,\n userId: res.id,\n username: res.username\n });\n })[\"catch\"](function (err) {\n alert(err.message);\n });\n }\n }, {\n key: \"logOutUser\",\n value: function logOutUser() {\n this.Auth.logout();\n this.setState({\n isLoggedin: false,\n userId: null,\n redirectTo: '/login'\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this5 = this;\n\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"BrowserRouter\"], null, this.state.isLoggedin ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_UserHeader_jsx__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n logOutUser: this.logOutUser,\n userId: this.state.userId,\n points: this.state.points,\n username: this.state.username\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_DashBody_jsx__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n auth: this.Auth,\n userId: this.state.userId,\n username: this.state.username,\n updatePoints: this.updatePoints,\n getUserPoints: this.getUserPoints,\n points: this.state.points\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"Route\"], {\n exact: true,\n path: \"/dashboard\"\n })) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"intro-body\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_DashboardHeader_jsx__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n isLoggedin: this.state.isLoggedin,\n logOutUser: this.logOutUser\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"Route\"], {\n path: \"/register\",\n render: function render(routeProps) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Register_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], _extends({}, routeProps, {\n registerUser: _this5.registerUser\n }));\n }\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"Route\"], {\n path: \"/login\",\n render: function render(routeProps) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Login_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], _extends({}, routeProps, {\n Auth: _this5.Auth,\n isLoggedin: _this5.state.isLoggedin,\n loginUser: _this5.loginUser\n }));\n }\n })));\n }\n }]);\n\n return App;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\nreact_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render(react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(App, null), document.getElementById('root'));\n\n//# sourceURL=webpack:///./client/src/index.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _material_ui_core_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @material-ui/core/Button */ \"./node_modules/@material-ui/core/Button/index.js\");\n/* harmony import */ var _material_ui_core_Button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_material_ui_core_Button__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _components_DashboardHeader_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/DashboardHeader.jsx */ \"./client/src/components/DashboardHeader.jsx\");\n/* harmony import */ var _components_DashBody_jsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/DashBody.jsx */ \"./client/src/components/DashBody.jsx\");\n/* harmony import */ var _components_Login_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/Login.jsx */ \"./client/src/components/Login.jsx\");\n/* harmony import */ var _components_Register_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/Register.jsx */ \"./client/src/components/Register.jsx\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var _components_AuthService_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./components/AuthService.js */ \"./client/src/components/AuthService.js\");\n/* harmony import */ var _components_UserHeader_jsx__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./components/UserHeader.jsx */ \"./client/src/components/UserHeader.jsx\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n\n\n\n\n\n //Material UI stuff\n\nvar styles = {\n paperContainer: {\n backgroundImage: \"url(\".concat(Image, \")\")\n }\n};\n\nvar App =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(App, _React$Component);\n\n function App(props) {\n var _this;\n\n _classCallCheck(this, App);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(App).call(this, props));\n _this.state = {\n isLoggedin: false,\n userId: null,\n redirectTo: '',\n username: '',\n points: null\n };\n _this.registerUser = _this.registerUser.bind(_assertThisInitialized(_this));\n _this.loginUser = _this.loginUser.bind(_assertThisInitialized(_this));\n _this.logOutUser = _this.logOutUser.bind(_assertThisInitialized(_this));\n _this.getUserPoints = _this.getUserPoints.bind(_assertThisInitialized(_this));\n _this.Auth = new _components_AuthService_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"]();\n _this.showModal = _this.showModal.bind(_assertThisInitialized(_this));\n return _this;\n }\n\n _createClass(App, [{\n key: \"componentWillMount\",\n value: function componentWillMount() {// if (this.Auth.loggedIn()){\n // this.setState({\n // isLoggedin: true,\n // redirectTo: '/dashboard'\n // })\n // } else{\n // this.setState({\n // isLoggedin: false\n // })\n // }\n }\n }, {\n key: \"showModal\",\n value: function showModal() {\n console.log('modal');\n }\n }, {\n key: \"getUserPoints\",\n value: function getUserPoints() {\n var _this2 = this;\n\n this.Auth.fetch(\"/api/users/\".concat(this.state.userId)).then(function (user) {\n _this2.setState({\n points: user.points\n });\n })[\"catch\"](function (err) {\n console.error(err);\n });\n }\n }, {\n key: \"registerUser\",\n value: function registerUser(user) {\n var _this3 = this;\n\n axios__WEBPACK_IMPORTED_MODULE_8___default.a.post('/api/auth/signup', user).then(function (response) {\n console.log(response);\n\n if (response.data) {\n console.log('succesful signup');\n\n _this3.setState({\n redirectTo: '/login'\n });\n } else {\n console.log('signup error');\n }\n })[\"catch\"](function (err) {\n console.log('sign up server error', err);\n });\n }\n }, {\n key: \"loginUser\",\n value: function loginUser(username, password) {\n var _this4 = this;\n\n this.Auth.login(username, password).then(function (res) {\n console.log(res);\n\n _this4.setState({\n isLoggedin: true,\n userId: res.id,\n username: res.username\n });\n })[\"catch\"](function (err) {\n alert('The username and password you entered did not match our records. Please double-check and try again.');\n });\n }\n }, {\n key: \"logOutUser\",\n value: function logOutUser() {\n this.Auth.logout();\n this.setState({\n isLoggedin: false,\n userId: null,\n redirectTo: '/login'\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this5 = this;\n\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"BrowserRouter\"], null, this.state.isLoggedin ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_UserHeader_jsx__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n logOutUser: this.logOutUser,\n userId: this.state.userId,\n points: this.state.points,\n username: this.state.username\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_DashBody_jsx__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n auth: this.Auth,\n userId: this.state.userId,\n username: this.state.username,\n updatePoints: this.updatePoints,\n getUserPoints: this.getUserPoints,\n points: this.state.points\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"Route\"], {\n exact: true,\n path: \"/dashboard\"\n })) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"intro-body\"\n }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_DashboardHeader_jsx__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n isLoggedin: this.state.isLoggedin,\n logOutUser: this.logOutUser\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"Route\"], {\n path: \"/register\",\n render: function render(routeProps) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Register_jsx__WEBPACK_IMPORTED_MODULE_6__[\"default\"], _extends({}, routeProps, {\n registerUser: _this5.registerUser\n }));\n }\n }), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_7__[\"Route\"], {\n path: \"/login\",\n render: function render(routeProps) {\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Login_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], _extends({}, routeProps, {\n Auth: _this5.Auth,\n isLoggedin: _this5.state.isLoggedin,\n loginUser: _this5.loginUser\n }));\n }\n })));\n }\n }]);\n\n return App;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\nreact_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render(react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(App, null), document.getElementById('root'));\n\n//# sourceURL=webpack:///./client/src/index.jsx?"); /***/ }), diff --git a/client/src/components/DashBody.jsx b/client/src/components/DashBody.jsx index 1659164..2797aa3 100644 --- a/client/src/components/DashBody.jsx +++ b/client/src/components/DashBody.jsx @@ -153,6 +153,10 @@ uploadContact(contact){ this.props.auth.fetch2(`/api/users/${this.props.userId}/upload`, options) .then((response)=>{ this.props.getUserPoints(); + this.setState({ + currentLead: contact, + contactView: 'access' + }) }) .catch((err)=>{ console.error(err); diff --git a/client/src/index.jsx b/client/src/index.jsx index 1316913..67e0c93 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -106,7 +106,7 @@ loginUser(username, password){ }) }).catch((err) => { - alert(err.message); + alert('The username and password you entered did not match our records. Please double-check and try again.'); }); } diff --git a/handlers/auth.js b/handlers/auth.js index e894411..ed6d08e 100644 --- a/handlers/auth.js +++ b/handlers/auth.js @@ -30,12 +30,12 @@ exports.signin = async function(req, res, next) { }); } else{ return next({ - status: 400, + status: 401, message: 'Invalid username/password' }) } } catch(err){ - return next({status: 400, message: 'Invalid username/password'}); + return next({status: 401, message: 'Invalid username/password'}); } diff --git a/package-lock.json b/package-lock.json index 2a04481..9e1c10b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2962,8 +2962,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2984,14 +2983,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3006,20 +3003,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3136,8 +3130,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3149,7 +3142,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3164,7 +3156,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3172,14 +3163,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3198,7 +3187,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3279,8 +3267,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3292,7 +3279,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3378,8 +3364,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3415,7 +3400,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3435,7 +3419,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3479,14 +3462,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } },