text: (this["webpackJsonpstock-portfolio"]=this["webpackJsonpstock-portfolio"]||[]).push([[0],{42:function(e,t,n){e.exports=n(78)},47:function(e,t,n){},78:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),o=n(37),s=n.n(o);n(47),Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));var i=n(81),c=n(80),l=n(79),u=r.a.createContext(null),m=n(3),p=n(4),d=n(6),f=n(5),h=n(7),b=r.a.createContext(null),g=function(e){return function(t){return r.a.createElement(b.Consumer,null,(function(n){return r.a.createElement(e,Object.assign({},t,{firebase:n}))}))}},v=b,E=n(8),O=n(16),y=n.n(O);n(52),n(54);function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}var S={apiKey:"AIzaSyDHzV8npw_ICa0T81EFgc9KLyqMy6_UAYw",authDomain:"todo-7961b.firebaseio.com",databaseURL:"https://todo-7961b.firebaseio.com",projectId:"todo-7961b",storageBucket:"react-firebase-s2233d64f8.appspot.com",messagingSenderId:"701928454501"},w=function e(){var t=this;Object(m.a)(this,e),this.doCreateUserWithEmailAndPassword=function(e,n){return t.auth.createUserWithEmailAndPassword(e,n)},this.doSignInWithEmailAndPassword=function(e,n){return t.auth.signInWithEmailAndPassword(e,n)},this.doSignInWithGoogle=function(){return t.auth.signInWithPopup(t.googleProvider)},this.doSignInWithFacebook=function(){return t.auth.signInWithPopup(t.facebookProvider)},this.doSignInWithTwitter=function(){return t.auth.signInWithPopup(t.twitterProvider)},this.doSignOut=function(){return t.auth.signOut()},this.doPasswordReset=function(e){return t.auth.sendPasswordResetEmail(e)},this.doSendEmailVerification=function(){return t.auth.currentUser.sendEmailVerification({url:"http://localhost:3000"})},this.doPasswordUpdate=function(e){return t.auth.currentUser.updatePassword(e)},this.onAuthUserListener=function(e,n){return t.auth.onAuthStateChanged((function(a){a?t.user(a.uid).once("value").then((function(t){var n=t.val();n.roles||(n.roles={}),a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({uid:a.uid,email:a.email,emailVerified:a.emailVerified,providerData:a.providerData},n),e(a)})):n()}))},this.user=function(e){return t.db.ref("users/".concat(e))},this.users=function(){return t.db.ref("users")},this.message=function(e){return t.db.ref("messages/".concat(e))},this.messages=function(){return t.db.ref("messages")},y.a.initializeApp(S),this.serverValue=y.a.database.ServerValue,this.emailAuthProvider=y.a.auth.EmailAuthProvider,this.auth=y.a.auth(),this.db=y.a.database(),this.googleProvider=new y.a.auth.GoogleAuthProvider,this.facebookProvider=new y.a.auth.FacebookAuthProvider,this.twitterProvider=new y.a.auth.TwitterAuthProvider},k=function(e){var t=function(t){function n(e){var t;return Object(m.a)(this,n),(t=Object(d.a)(this,Object(f.a)(n).call(this,e))).state={authUser:JSON.parse(localStorage.getItem("authUser"))},t}return Object(h.a)(n,t),Object(p.a)(n,[{key:"componentDidMount",value:function(){var e=this;this.listener=this.props.firebase.onAuthUserListener((function(t){localStorage.setItem("authUser",JSON.stringify(t)),e.setState({authUser:t})}),(function(){localStorage.removeItem("authUser"),e.setState({authUser:null})}))}},{key:"componentWillUnmount",value:function(){this.listener()}},{key:"render",value:function(){return r.a.createElement(u.Provider,{value:this.state.authUser},r.a.createElement(e,this.props))}}]),n}(r.a.Component);return g(t)},P=n(82),C=n(10),I="/home",N="/account",D=function(e){return function(t){var n=function(n){function a(){return Object(m.a)(this,a),Object(d.a)(this,Object(f.a)(a).apply(this,arguments))}return Object(h.a)(a,n),Object(p.a)(a,[{key:"componentDidMount",value:function(){var t=this;this.listener=this.props.firebase.onAuthUserListener((function(n){e(n)||t.props.history.push("/signin")}),(function(){return t.props.history.push("/signin")}))}},{key:"componentWillUnmount",value:function(){this.listener()}},{key:"render",value:function(){var n=this;return r.a.createElement(u.Consumer,null,(function(a){return e(a)?r.a.createElement(t,n.props):null}))}}]),a}(r.a.Component);return Object(C.a)(P.a,g)(n)}},M=function(e){var t=function(t){function n(e){var t;return Object(m.a)(this,n),(t=Object(d.a)(this,Object(f.a)(n).call(this,e))).onSendEmailVerification=function(){console.log("send email"),t.props.firebase.doSendEmailVerification().then((function(){return t.setState({isSent:!0})}))},t.state={isSent:!1},t}return Object(h.a)(n,t),Object(p.a)(n,[{key:"render",value:function(){var t=this;return r.a.createElement(u.Consumer,null,(function(n){return function(e){return e&&!e.emailVerified&&e.providerData.map((function(e){return e.providerId})).includes("password")}(n)?r.a.createElement("div",null,r.a.createElement(e,t.props),t.state.isSent?r.a.createElement("p",null,"E-Mail confirmation sent: Check your E-Mails (Spam folder included) for a confirmation E-Mail. Refresh this page once you confirmed your E-Mail."):r.a.createElement("p",{style:{color:"red"}},"Verify your E-Mail: Check your E-Mails (Spam folder included) for a confirmation E-Mail or send another confirmation E-Mail."),r.a.createElement("button",{className:"btn centr btn-default m-left-5 todo-btn",type:"button",onClick:t.onSendEmailVerification,disabled:t.state.isSent},"Send confirmation E-Mail")):r.a.createElement(e,t.props)}))}}]),n}(r.a.Component);return g(t)},U=g((function(e){var t=e.firebase;return r.a.createElement("button",{type:"button",className:"btn btn-primary todo-sign-in-btn",onClick:t.doSignOut},"SIGN OUT")})),T="ADMIN",A={link:{textDecoration:"none",color:"white",textAlign:"center"}},x=function(e){var t=e.authUser;return r.a.createElement("div",{className:" blue-bar navbar navbar-default navbar-light justify-content-end"},r.a.createElement("div",{id:"nav-bar-item"},r.a.createElement(l.a,{style:A.link,to:I},"HOME")),r.a.createElement("div",{id:"nav-bar-item"},r.a.createElement(l.a,{style:A.link,to:"/"},"BROWSE")),r.a.createElement("div",{id:"nav-bar-item"},r.a.createElement(l.a,{style:A.link,to:N},"PORTFOLIO")),!!t.roles[T]&&r.a.createElement("div",{id:"nav-bar-item"},r.a.createElement(l.a,{style:A.link,to:"/admin"},"ADMIN")),r.a.createElement("div",{id:"nav-bar-item",onClick:function(){localStorage.setItem("bank","")}},r.a.createElement(U,null)))},L=function(){return r.a.createElement("nav",{className:"blue-bar navbar navbar-default navbar-light justify-content-end"},r.a.createElement("div",{id:"nav-bar-item",className:"nav-item"},r.a.createElement(l.a,{style:A.link,to:"/"},"LANDING")),r.a.createElement("div",{id:"nav-bar-item",className:"nav-item"},r.a.createElement(l.a,{style:A.link,to:"/signin"},"SIGN IN")))},W=function(){return r.a.createElement(u.Consumer,null,(function(e){return e?r.a.createElement(x,{authUser:e}):r.a.createElement(L,null)}))},R=n(14),F=n.n(R),V={link:{textDecoration:"none",color:"black",textAlign:"center"}},G=function(e){var t=e.data;return r.a.createElement("div",{className:"card"},r.a.createElement(l.a,{style:V.link,onClick:function(){localStorage.setItem(t["1. symbol"],t["2. name"])},to:"/stock/".concat(t["1. symbol"])},r.a.createElement("div",{className:"content"},r.a.createElement("h6",null," ",t["1. symbol"]),r.a.createElement("p",null,t["2. name"]),r.a.createElement("p",null,"Market Open | ",t["5. marketOpen"]," "),r.a.createElement("p",null,"Market Close | ",t["6. marketClose"]),r.a.createElement("p",null,"Currency | ",t["8. currency"]," "))))},_=function(e){function t(){var e,n;Object(m.a)(this,t);for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];return(n=Object(d.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(r)))).state={keyword:"",loaded:!1,isloading:!1,data:[]},n.fetchInfo=function(){F.a.get("/api/live/".concat(n.state.keyword)).then((function(e){var t=e.data;n.setState({loaded:!0,isloading:!1,data:t})}))},n.handleInputChange=function(){n.setState({keyword:n.search.value})},n.handleOnSubmit=function(e){n.setState({isloading:!0}),console.log(n.state.keyword),n.fetchInfo(),e.preventDefault()},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this;console.log(this.state);var t=this.state,n=t.isloading,a=t.loaded,o=t.data;return r.a.createElement("div",{className:"searchPage m-top-5"},r.a.createElement("h4",{className:"centr m-top-50"},"Browse Stocks"),r.a.createElement("form",{className:"search",onSubmit:this.handleOnSubmit},r.a.createElement("input",{className:"searchTerm",placeholder:"search...",ref:function(t){return e.search=t},onChange:this.handleInputChange})),r.a.createElement("div",{className:"card-result-area"},n?r.a.createElement("div",{className:"lds-circle centr"},r.a.createElement("div",null)):a&&o.map((function(e,t){return r.a.createElement(G,{key:t,data:e})}))))}}]),t}(a.Component),B=function(){return r.a.createElement(_,null)};function H(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?H(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var J={username:"",email:"",passwordOne:"",passwordTwo:"",isAdmin:!1,error:null,uid:""},z="auth/email-already-in-use",Y="\n    An account with this E-Mail address already exists.\n    Try to login with this account instead. If you think the\n    account is already used from one of the social logins, try\n    to sign in with one of them. Afterward, associate your accounts\n    on your personal account page.\n  ",K=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){var t=n.state,a=t.username,r=t.email,o=t.passwordOne,s=t.isAdmin,i={};s&&(i[T]=T),n.props.firebase.doCreateUserWithEmailAndPassword(r,o).then((function(e){return console.log("AUTHUSER: ",e),n.createStockUser(e.user.uid,r),n.props.firebase.user(e.user.uid).set({username:a,email:r,roles:i})})).then((function(){return n.props.firebase.doSendEmailVerification()})).then((function(){n.setState($({},J)),n.props.history.push(I)})).catch((function(e){e.code===z&&(e.message=Y),n.setState({error:e})})),e.preventDefault()},n.createStockUser=function(e,t){F.a.post("/api/users/create/",{userID:e,userName:t,bank:5e4}).then((function(e){console.log(e)}),(function(e){console.log(e)}))},n.onChange=function(e){n.setState(Object(E.a)({},e.target.name,e.target.value))},n.onChangeCheckbox=function(e){n.setState(Object(E.a)({},e.target.name,e.target.checked))},n.state=$({},J),n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state,t=e.username,n=e.email,a=e.passwordOne,o=e.passwordTwo,s=e.error,i=a!==o||""===a||""===n||""===t;return r.a.createElement("form",{className:"register-form",onSubmit:this.onSubmit},r.a.createElement("input",{name:"username",value:t,onChange:this.onChange,type:"text",placeholder:"Full Name"}),r.a.createElement("input",{name:"email",value:n,onChange:this.onChange,type:"text",placeholder:"Email Address"}),r.a.createElement("input",{name:"passwordOne",value:a,onChange:this.onChange,type:"password",placeholder:"Password"}),r.a.createElement("input",{name:"passwordTwo",value:o,onChange:this.onChange,type:"password",placeholder:"Confirm Password"}),r.a.createElement("button",{disabled:i,type:"submit"},"Sign Up"),s&&r.a.createElement("p",null,s.message))}}]),t}(a.Component),q=function(){return r.a.createElement("p",null,"Don't have an account? ",r.a.createElement(l.a,{to:"/signup"},"Sign Up"))},Q=Object(C.a)(P.a,g)(K),X=function(){return r.a.createElement("div",{className:"login-page"},r.a.createElement("div",{className:"form"},r.a.createElement("h1",null,"SignUp"),r.a.createElement(Q,null)))};function Z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function ee(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var te={email:"",error:null},ne=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){var t=n.state.email;n.props.firebase.doPasswordReset(t).then((function(){n.setState(ee({},te))})).catch((function(e){n.setState({error:e})})),e.preventDefault()},n.onChange=function(e){n.setState(Object(E.a)({},e.target.name,e.target.value))},n.state=ee({},te),n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state,t=e.email,n=e.error,a=""===t;return r.a.createElement("form",{onSubmit:this.onSubmit,className:"m-top-5"},r.a.createElement("input",{name:"email",value:this.state.email,onChange:this.onChange,className:"myFormControl",type:"text",placeholder:"Email Address"}),r.a.createElement("button",{disabled:a,className:"btn btn-default m-left-5 todo-btn",type:"submit"},"Reset My Password"),n&&r.a.createElement("p",null,n.message))}}]),t}(a.Component),ae=function(){return r.a.createElement("p",null,r.a.createElement(l.a,{to:"/pw-forget"},"Forgot Password?"))},re=function(){return r.a.createElement("div",null,r.a.createElement("h1",null,"PasswordForget"),r.a.createElement(oe,null))},oe=g(ne);function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function ie(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ce={email:"",password:"",error:null},le="auth/account-exists-with-different-credential",ue="\n  An account with an E-Mail address to\n  this social account already exists. Try to login from\n  this account instead and associate your social accounts on\n  your personal account page.\n",me=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){var t=n.state,a=t.email,r=t.password;n.props.firebase.doSignInWithEmailAndPassword(a,r).then((function(){n.setState(ie({},ce)),n.props.history.push(I)})).catch((function(e){n.setState({error:e})})),console.log(localStorage.getItem("authUser"),a),e.preventDefault()},n.onChange=function(e){n.setState(Object(E.a)({},e.target.name,e.target.value))},n.state=ie({},ce),n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state,t=e.email,n=e.password,a=e.error,o=""===n||""===t;return r.a.createElement("form",{className:"login-form",onSubmit:this.onSubmit},r.a.createElement("input",{name:"email",value:t,onChange:this.onChange,type:"text",placeholder:"Email Address"}),r.a.createElement("input",{name:"password",value:n,onChange:this.onChange,type:"password",placeholder:"Password"}),r.a.createElement("button",{className:"btn btn-primary todo-sign-in-btn",disabled:o,type:"submit"},"SIGN IN"),a&&r.a.createElement("p",null,a.message))}}]),t}(a.Component),pe=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){n.props.firebase.doSignInWithGoogle().then((function(e){return n.props.firebase.user(e.user.uid).set({username:e.user.displayName,email:e.user.email,roles:{}})})).then((function(){n.setState({error:null}),n.props.history.push(I)})).catch((function(e){e.code===le&&(e.message=ue),n.setState({error:e})})),e.preventDefault()},n.state={error:null},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state.error;return r.a.createElement("form",{onSubmit:this.onSubmit},r.a.createElement("button",{type:"submit"},"Sign In with Google"),e&&r.a.createElement("p",null,e.message))}}]),t}(a.Component),de=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){n.props.firebase.doSignInWithFacebook().then((function(e){return n.props.firebase.user(e.user.uid).set({username:e.additionalUserInfo.profile.name,email:e.additionalUserInfo.profile.email,roles:{}})})).then((function(){n.setState({error:null}),n.props.history.push(I)})).catch((function(e){e.code===le&&(e.message=ue),n.setState({error:e})})),e.preventDefault()},n.state={error:null},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state.error;return r.a.createElement("form",{onSubmit:this.onSubmit},r.a.createElement("button",{type:"submit"},"Sign In with Facebook"),e&&r.a.createElement("p",null,e.message))}}]),t}(a.Component),fe=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){n.props.firebase.doSignInWithTwitter().then((function(e){return n.props.firebase.user(e.user.uid).set({username:e.additionalUserInfo.profile.name,email:e.additionalUserInfo.profile.email,roles:{}})})).then((function(){n.setState({error:null}),n.props.history.push(I)})).catch((function(e){e.code===le&&(e.message=ue),n.setState({error:e})})),e.preventDefault()},n.state={error:null},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state.error;return r.a.createElement("form",{onSubmit:this.onSubmit},r.a.createElement("button",{type:"submit"},"Sign In with Twitter"),e&&r.a.createElement("p",null,e.message))}}]),t}(a.Component),he=Object(C.a)(P.a,g)(me),be=(Object(C.a)(P.a,g)(pe),Object(C.a)(P.a,g)(de),Object(C.a)(P.a,g)(fe),function(){return r.a.createElement("div",{className:"login-page"},r.a.createElement("div",{className:"form"},r.a.createElement("h1",null,"SignIn"),r.a.createElement(he,null),r.a.createElement(ae,null),r.a.createElement(q,null)))}),ge=n(41),ve=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onToggleEditMode=function(){n.setState((function(e){return{editMode:!e.editMode,editText:n.props.message.text}}))},n.onChangeEditText=function(e){n.setState({editText:e.target.value})},n.onSaveEditText=function(){n.props.onEditMessage(n.props.message,n.state.editText),n.setState({editMode:!1})},n.state={editMode:!1,editText:n.props.message.text},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.props,t=e.authUser,n=e.message,a=e.onRemoveMessage,o=this.state,s=o.editMode,i=o.editText;return r.a.createElement("li",null,s?r.a.createElement("input",{type:"text",value:i,onChange:this.onChangeEditText}):r.a.createElement("span",null,r.a.createElement("strong",null,n.userId)," ",n.text,n.editedAt&&r.a.createElement("span",null,"(Edited)")),t.uid===n.userId&&r.a.createElement("span",null,s?r.a.createElement("span",null,r.a.createElement("button",{onClick:this.onSaveEditText},"Save"),r.a.createElement("button",{onClick:this.onToggleEditMode},"Reset")):r.a.createElement("button",{onClick:this.onToggleEditMode},"Edit"),!s&&r.a.createElement("button",{type:"button",onClick:function(){return a(n.uid)}},"Delete")))}}]),t}(a.Component),Ee=function(e){var t=e.authUser,n=e.messages,a=e.onEditMessage,o=e.onRemoveMessage;return r.a.createElement("ul",null,n.map((function(e){return r.a.createElement(ve,{authUser:t,key:e.uid,message:e,onEditMessage:a,onRemoveMessage:o})})))};function Oe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oe(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oe(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var je=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onListenForMessages=function(){n.setState({loading:!0}),n.props.firebase.messages().orderByChild("createdAt").limitToLast(n.state.limit).on("value",(function(e){var t=e.val();if(t){var a=Object.keys(t).map((function(e){return ye({},t[e],{uid:e})}));n.setState({messages:a,loading:!1})}else n.setState({messages:null,loading:!1})}))},n.onChangeText=function(e){n.setState({text:e.target.value})},n.onCreateMessage=function(e,t){n.props.firebase.messages().push({text:n.state.text,userId:t.uid,createdAt:n.props.firebase.serverValue.TIMESTAMP}),n.setState({text:""}),e.preventDefault()},n.onEditMessage=function(e,t){e.uid;var a=Object(ge.a)(e,["uid"]);n.props.firebase.message(e.uid).set(ye({},a,{text:t,editedAt:n.props.firebase.serverValue.TIMESTAMP}))},n.onRemoveMessage=function(e){n.props.firebase.message(e).remove()},n.onNextPage=function(){n.setState((function(e){return{limit:e.limit+5}}),n.onListenForMessages)},n.state={text:"",loading:!1,messages:[],limit:5},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){this.onListenForMessages()}},{key:"componentWillUnmount",value:function(){this.props.firebase.messages().off()}},{key:"render",value:function(){var e=this,t=this.state,n=t.text,a=t.messages,o=t.loading;return r.a.createElement(u.Consumer,null,(function(t){return r.a.createElement("div",null,!o&&a&&r.a.createElement("button",{type:"button",onClick:e.onNextPage},"More"),o&&r.a.createElement("div",null,"Loading ..."),a&&r.a.createElement(Ee,{authUser:t,messages:a,onEditMessage:e.onEditMessage,onRemoveMessage:e.onRemoveMessage}),!a&&r.a.createElement("div",null,"There are no messages ..."),r.a.createElement("form",{onSubmit:function(n){return e.onCreateMessage(n,t)}},r.a.createElement("input",{type:"text",value:n,onChange:e.onChangeText}),r.a.createElement("button",{type:"submit"},"Send")))}))}}]),t}(a.Component),Se=g(je),we=n(40),ke=n.n(we),Pe=function(e){function t(){return Object(m.a)(this,t),Object(d.a)(this,Object(f.a)(t).apply(this,arguments))}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){return console.log(ke()().format("LLL")),r.a.createElement("div",null,"date")}}]),t}(a.Component),Ce=Object(C.a)(M,D((function(e){return!!e})))((function(){return r.a.createElement("div",null,r.a.createElement("h1",null,"Home Page"),r.a.createElement("p",null,"The Home Page is accessible by every signed in user."),r.a.createElement(Pe,null),r.a.createElement(Se,null))})),Ie=function(e){function t(){var e,n;Object(m.a)(this,t);for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];return(n=Object(d.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(r)))).state={transInfoLoaded:!1,transInfoLoading:!1,transData:[]},n.getTransInfo=function(e){F.a.get("/api/transactions/".concat(e)).then((function(e){var t=e.data;n.setState({transInfoLoaded:!0,transInfoLoading:!1,transData:t})}))},n.getUserInfo=function(e){F.a.get("/api/users/".concat(e)).then((function(e){var t=e.data;localStorage.setItem("bank",t.bank)}))},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"componentWillMount",value:function(){var e=JSON.parse(localStorage.getItem("authUser")).uid;console.log(e),this.getUserInfo(e),this.getTransInfo(e)}},{key:"render",value:function(){console.log(this.state.transData);var e=this.state,t=e.transInfoLoaded,n=e.transData;return r.a.createElement("div",{className:"porfolio-detials"},r.a.createElement("div",{className:"porfolio-rows"},r.a.createElement("h5",{className:"centr m-top-5"},"Transaction History"),t?n.map((function(e){return r.a.createElement("div",{className:"trans-card"},r.a.createElement("h5",null,e.stock),r.a.createElement("p",null,"shares owned: ",e.shares),r.a.createElement("p",null,"Total Price: $",e.amount_payed))})):r.a.createElement("div",{className:"lds-circle centr"},r.a.createElement("div",null))),r.a.createElement("div",null,r.a.createElement("h5",{className:"centr m-top-5"},"Porfolio")))}}]),t}(a.Component);function Ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function De(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ne(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ne(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Me={passwordOne:"",passwordTwo:"",error:null},Ue=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){var t=n.state.passwordOne;n.props.firebase.doPasswordUpdate(t).then((function(){n.setState(De({},Me))})).catch((function(e){n.setState({error:e})})),e.preventDefault()},n.onChange=function(e){n.setState(Object(E.a)({},e.target.name,e.target.value))},n.state=De({},Me),n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.state,t=e.passwordOne,n=e.passwordTwo,a=e.error,o=t!==n||""===t;return r.a.createElement("form",{onSubmit:this.onSubmit,className:"m-top-5"},r.a.createElement("div",{className:""},r.a.createElement("input",{name:"passwordOne",value:t,onChange:this.onChange,className:"myFormControl",type:"password",placeholder:"New Password"}),r.a.createElement("input",{name:"passwordTwo",value:n,onChange:this.onChange,className:"myFormControl",type:"password",placeholder:"Confirm New Password"}),r.a.createElement("button",{disabled:o,className:"btn btn-default m-left-5 todo-btn",type:"submit"},"Reset Password"),a&&r.a.createElement("p",null,a.message)))}}]),t}(a.Component),Te=g(Ue),Ae=[{id:"password",provider:null},{id:"google.com",provider:"googleProvider",css:"fa fa-google"},{id:"facebook.com",provider:"facebookProvider",css:"fa fa-facebook"},{id:"twitter.com",provider:"twitterProvider",css:"fa fa-twitter"}],xe=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).fetchSignInMethods=function(){n.props.firebase.auth.fetchSignInMethodsForEmail(n.props.authUser.email).then((function(e){return n.setState({activeSignInMethods:e,error:null})})).catch((function(e){return n.setState({error:e})}))},n.onSocialLoginLink=function(e){n.props.firebase.auth.currentUser.linkWithPopup(n.props.firebase[e]).then(n.fetchSignInMethods).catch((function(e){return n.setState({error:e})}))},n.onDefaultLoginLink=function(e){var t=n.props.firebase.emailAuthProvider.credential(n.props.authUser.email,e);n.props.firebase.auth.currentUser.linkAndRetrieveDataWithCredential(t).then(n.fetchSignInMethods).catch((function(e){return n.setState({error:e})}))},n.onUnlink=function(e){n.props.firebase.auth.currentUser.unlink(e).then(n.fetchSignInMethods).catch((function(e){return n.setState({error:e})}))},n.state={activeSignInMethods:[],error:null},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){this.fetchSignInMethods()}},{key:"render",value:function(){var e=this,t=this.state,n=t.activeSignInMethods,a=t.error;return r.a.createElement("div",null,r.a.createElement("div",null,Ae.map((function(t){var a=1===n.length,o=n.includes(t.id);return r.a.createElement("div",{className:"m-top-5 centr",key:t.id},"password"===t.id?r.a.createElement(We,{onlyOneLeft:a,isEnabled:o,signInMethod:t,onLink:e.onDefaultLoginLink,onUnlink:e.onUnlink}):r.a.createElement(Le,{onlyOneLeft:a,isEnabled:o,signInMethod:t,onLink:e.onSocialLoginLink,onUnlink:e.onUnlink}))}))),a&&a.message)}}]),t}(a.Component),Le=function(e){var t=e.onlyOneLeft,n=e.isEnabled,a=e.signInMethod,o=e.onLink,s=e.onUnlink;return n?r.a.createElement("button",{type:"button",className:"btn btn-default col-md-3 todo-btn",onClick:function(){return s(a.id)},disabled:t},"Deactivate ",a.id):r.a.createElement("button",{type:"button",className:"btn btn-default col-md-3 todo-btn",onClick:function(){return o(a.provider)}},"Link ",a.id)},We=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSubmit=function(e){e.preventDefault(),n.props.onLink(n.state.passwordOne),n.setState({passwordOne:"",passwordTwo:""})},n.onChange=function(e){n.setState(Object(E.a)({},e.target.name,e.target.value))},n.state={passwordOne:"",passwordTwo:""},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"render",value:function(){var e=this.props,t=e.onlyOneLeft,n=e.isEnabled,a=e.signInMethod,o=e.onUnlink,s=this.state,i=s.passwordOne,c=s.passwordTwo,l=i!==c||""===i;return n?r.a.createElement("button",{type:"button",onClick:function(){return o(a.id)},className:"btn btn-default col-md-3 todo-btn",disabled:t},"Deactivate ",a.id):r.a.createElement("form",{onSubmit:this.onSubmit},r.a.createElement("input",{name:"passwordOne",value:i,onChange:this.onChange,type:"password",placeholder:"New Password"}),r.a.createElement("input",{name:"passwordTwo",value:c,onChange:this.onChange,type:"password",placeholder:"Confirm New Password"}),r.a.createElement("button",{disabled:l,className:"btn btn-default col-md-3 todo-btn",type:"submit"},"Link ",a.id))}}]),t}(a.Component),Re=(g(xe),Object(C.a)(M,D((function(e){return!!e})))((function(){return r.a.createElement(u.Consumer,null,(function(e){return r.a.createElement("div",{className:"porfolio-area"},r.a.createElement(Ie,null),r.a.createElement(oe,null),r.a.createElement(Te,null))}))}))),Fe=n(83);function Ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}var Ge=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).state={loading:!1,users:[]},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){var e=this;this.setState({loading:!0}),this.props.firebase.users().on("value",(function(t){var n=t.val(),a=Object.keys(n).map((function(e){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ve(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ve(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},n[e],{uid:e})}));e.setState({users:a,loading:!1})}))}},{key:"componentWillUnmount",value:function(){this.props.firebase.users().off()}},{key:"render",value:function(){var e=this.state,t=e.users,n=e.loading;return r.a.createElement("div",null,r.a.createElement("h2",null,"Users"),n&&r.a.createElement("div",null,"Loading ..."),r.a.createElement("ul",null,t.map((function(e){return r.a.createElement("li",{key:e.uid},r.a.createElement("span",null,r.a.createElement("strong",null,"ID:")," ",e.uid),r.a.createElement("span",null,r.a.createElement("strong",null,"E-Mail:")," ",e.email),r.a.createElement("span",null,r.a.createElement("strong",null,"Username:")," ",e.username),r.a.createElement("span",null,r.a.createElement(l.a,{to:{pathname:"".concat("/admin","/").concat(e.uid),state:{user:e}}},"Details")))}))))}}]),t}(a.Component),_e=g(Ge);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}var He=function(e){function t(e){var n;return Object(m.a)(this,t),(n=Object(d.a)(this,Object(f.a)(t).call(this,e))).onSendPasswordResetEmail=function(){n.props.firebase.doPasswordReset(n.state.user.email)},n.state=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(n,!0).forEach((function(t){Object(E.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(n).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({loading:!1,user:null},e.location.state),n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){var e=this;this.state.user||(this.setState({loading:!0}),this.props.firebase.user(this.props.match.params.id).on("value",(function(t){e.setState({user:t.val(),loading:!1})})))}},{key:"componentWillUnmount",value:function(){this.props.firebase.user(this.props.match.params.id).off()}},{key:"render",value:function(){var e=this.state,t=e.user,n=e.loading;return r.a.createElement("div",null,r.a.createElement("h2",null,"User (",this.props.match.params.id,")"),n&&r.a.createElement("div",null,"Loading ..."),t&&r.a.createElement("div",null,r.a.createElement("span",null,r.a.createElement("strong",null,"ID:")," ",t.uid),r.a.createElement("span",null,r.a.createElement("strong",null,"E-Mail:")," ",t.email),r.a.createElement("span",null,r.a.createElement("strong",null,"Username:")," ",t.username),r.a.createElement("span",null,r.a.createElement("button",{type:"button",onClick:this.onSendPasswordResetEmail},"Send Password Reset"))))}}]),t}(a.Component),$e=g(He),Je=Object(C.a)(M,D((function(e){return e&&!!e.roles[T]})))((function(){return r.a.createElement("div",null,r.a.createElement("h1",null,"Admin"),r.a.createElement("p",null,"The Admin Page is accessible by every signed in admin user."),r.a.createElement(Fe.a,null,r.a.createElement(c.a,{exact:!0,path:"/admin/:id",component:$e}),r.a.createElement(c.a,{exact:!0,path:"/admin",component:_e})))})),ze=function(e){function t(){var e,n;Object(m.a)(this,t);for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];return(n=Object(d.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(r)))).state={symbol:"",loaded:"",shares:0,costPershar:0,data:{}},n.onSubmit=function(e){var t=n.state,a=t.symbol,r=t.data,o=t.shares,s=t.costPershar;n.logStock(a,r.meta_data["3. Last Refreshed"],r.data["5. volume"],r.data["1. open"],r.data["2. high"],r.data["3. low"],r.data["4. close"]);var i=o*s,c=JSON.parse(localStorage.getItem("authUser")).uid;n.makeTransaction(c,o,a,i,null),n.props.history.push(N),e.preventDefault()},n.logStock=function(e,t,n,a,r,o,s){F.a.post("/api/stock/",{symbol:e,lastUpdated:t,volume:n,_open:a,_high:r,_low:o,_close:s}).then((function(e){console.log(e)}),(function(e){console.log(e)}))},n.makeTransaction=function(e,t,n,a,r){F.a.post("/api/transactions/",{user:e,stock:n,shares:t,amount_payed:a,time:r}).then((function(e){console.log(e.data),localStorage.setItem("bank",e.data.moneyLeft)}),(function(e){console.log(e)}))},n.onChange=function(e){n.setState(Object(E.a)({},e.target.name,e.target.value))},n.fetchStockInfo=function(e){F.a.get("/api/live/".concat(e,"/daily")).then((function(e){var t=e.data;n.setState({data:t,shares:1,costPershar:t.data["1. open"]})}))},n}return Object(h.a)(t,e),Object(p.a)(t,[{key:"componentWillMount",value:function(){var e=this.props.match.params.symbol;this.setState({symbol:e}),e&&this.fetchStockInfo(e),console.log(this.props)}},{key:"render",value:function(){var e=this,t=this.state,n=t.symbol,a=t.data,o=t.shares,s=t.costPershar;return console.log(o),r.a.createElement("div",{className:"m-50 trans-card"},r.a.createElement("h5",{className:"stock-title"},localStorage.getItem(n)),r.a.createElement("div",{className:"stock-details-section m-left-5"},r.a.createElement("div",{className:"stock-info-section "},r.a.createElement("h6",{className:"centr"}," Symbol : ",n),r.a.createElement("br",null),a.data&&r.a.createElement("div",{className:"centr"},r.a.createElement("p",null,"Open   : $",a.data["1. open"]),r.a.createElement("p",null,"Close  : $",a.data["4. close"]),r.a.createElement("p",null,"High   : $",a.data["2. high"]),r.a.createElement("p",null,"Low    : $",a.data["3. low"]),r.a.createElement("p",null,"Volume : ",a.data["5. volume"]))),r.a.createElement("div",{className:"stock-purchase-or-login"},r.a.createElement(u.Consumer,null,(function(t){return t?r.a.createElement("div",{className:"form"},r.a.createElement("form",{className:"login-form",onSubmit:e.onSubmit},r.a.createElement("h5",null,"$",s*o),r.a.createElement("input",{name:"shares",value:o,onChange:e.onChange,type:"text",placeholder:"shares"}),r.a.createElement("button",{className:"btn btn-primary todo-sign-in-btn",type:"submit"},"BUY"))):r.a.createElement(l.a,{to:"/signin"},"SIGN IN TO BUY SHARES")})))))}}]),t}(a.Component),Ye=k((function(){return r.a.createElement(i.a,null,r.a.createElement("div",null,r.a.createElement(W,null),r.a.createElement(c.a,{exact:!0,path:"/",component:B}),r.a.createElement(c.a,{path:"/signup",component:X}),r.a.createElement(c.a,{path:"/signin",component:be}),r.a.createElement(c.a,{path:"/pw-forget",component:re}),r.a.createElement(c.a,{path:"/stock/:symbol",component:ze}),r.a.createElement(c.a,{path:I,component:Ce}),r.a.createElement(c.a,{path:N,component:Re}),r.a.createElement(c.a,{path:"/admin",component:Je})))}));s.a.render(r.a.createElement(v.Provider,{value:new w},r.a.createElement(Ye,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()}))}},[[42,1,2]]]);
  //# sourceMappingURL=main.7a074711.chunk.js.map