text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{205:function(e,t,n){e.exports=n(357)},357:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),o=n(34),i=n.n(o),c=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}$/));function l(e,t){navigator.serviceWorker.register(e).then(function(e){e.onupdatefound=function(){var n=e.installing;null!=n&&(n.onstatechange=function(){"installed"===n.state&&(navigator.serviceWorker.controller?(console.log("New content is available and will be used when all tabs for this page are closed. See https://bit.ly/CRA-PWA."),t&&t.onUpdate&&t.onUpdate(e)):(console.log("Content is cached for offline use."),t&&t.onSuccess&&t.onSuccess(e)))})}}).catch(function(e){console.error("Error during service worker registration:",e)})}var s=n(55),u=n(56),d=n(59),p=n(57),m=n(60),f=n(46),h=n(36),g=n(368),v=n(25),E=n.n(v),w=n(44),b=n(124),y={},O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"LOGIN_SUCCESS":return t.response;case"LOGIN_FAILURE":return{};case"LOGIN_BYTOKEN":return t.user;case"LOGOUT_SUCCESS":return{};case"USER_UPDATE_SUCCESS":return Object(b.a)({},e,{user:Object(b.a)({},e.user,{email:t.response.email})});default:return e}},j=n(71),k=n.n(j);var S=function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"get";return function(r){var o={route:e,method:a,data:n,prefix:t};r({type:"".concat(t,"ATTEMPT"),payload:o})}},x=function(e){return S("api/login","LOGIN_",e,"post")},A=n(366),N=n(370),R=n(369),U=n(367),C=n(358),P=n(116),L=n(117);function W(){var e=Object(P.a)(["\n  margin: 0.25em;\n"]);return W=function(){return e},e}function G(){var e=Object(P.a)(["\n  background: Bisque;\n  font-size: 1em;\n  margin: 1em;\n  padding: 0.25em 1em;\n  border: 2px solid Chocolate;\n  border-radius: 3px;\n"]);return G=function(){return e},e}L.a.button(G()),L.a.input(W());var T=function(e){function t(){var e,n;Object(s.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(p.a)(t)).call.apply(e,[this].concat(r)))).handleSubmit=function(){var e=Object(w.a)(E.a.mark(function e(t){var a;return E.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),a={username:t.target.username.value,password:t.target.password.value},e.next=4,n.props.login(a);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),n}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){return r.a.createElement("div",{className:"LoginPage"},r.a.createElement(A.a,{active:this.props.loading.loading,inline:"centered"}),r.a.createElement(N.a,null,r.a.createElement(N.a.Row,{centered:!0},r.a.createElement("h3",null,"Enter your info"))),r.a.createElement(N.a,null,r.a.createElement(N.a.Row,{centered:!0},r.a.createElement(R.a,{onSubmit:this.handleSubmit},r.a.createElement(R.a.Group,{inline:!0},r.a.createElement("label",{style:{width:"75px"}},"Username"),r.a.createElement(U.a,{type:"text",name:"username",icon:"user",required:"true",iconPosition:"left",style:{minWidth:"25em"},placeholder:"Your AD-username",className:"form-control1"})),r.a.createElement(R.a.Group,{inline:!0},r.a.createElement("label",{style:{width:"75px"}},"Password"),r.a.createElement(U.a,{type:"password",name:"password",required:"true",icon:"lock",iconPosition:"left",style:{minWidth:"25em"},placeholder:"Your password",className:"form-control2"})),r.a.createElement(R.a.Group,null,r.a.createElement(C.a,{type:"submit",color:"blue"},"Login"))))))}}]),t}(r.a.Component),I={login:x},_=Object(h.b)(function(e){return{user:e.user,loading:e.loading}},I)(T),D=function(e){return S("api/users","CREATE_USER_",e,"post")},Y=function(e){function t(){var e,n;Object(s.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(p.a)(t)).call.apply(e,[this].concat(r)))).handleSubmit=function(){var e=Object(w.a)(E.a.mark(function e(t){var a;return E.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),t.target.password.value===t.target.passwordA.value){e.next=5;break}console.log("you goold"),e.next=8;break;case 5:return a={username:t.target.username.value,password:t.target.password.value},e.next=8,n.props.createUser(a);case 8:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),n}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){return r.a.createElement("div",{className:"RegisterPage"},r.a.createElement(A.a,{active:this.props.loading.loading,inline:"centered"}),r.a.createElement(N.a,null,r.a.createElement(N.a.Row,{centered:!0},r.a.createElement("h3",null,"Register to service here "))),r.a.createElement(N.a,null,r.a.createElement(N.a.Row,{centered:!0},r.a.createElement(R.a,{onSubmit:this.handleSubmit},r.a.createElement(R.a.Group,{inline:!0},r.a.createElement("label",{style:{width:"75px"}},"Username"),r.a.createElement(U.a,{type:"text",name:"username",icon:"user",required:"true",iconPosition:"left",style:{minWidth:"25em"},placeholder:"Your AD-username",className:"form-control1"})),r.a.createElement(R.a.Group,{inline:!0},r.a.createElement("label",{style:{width:"75px"}},"Real name"),r.a.createElement(U.a,{type:"text",name:"name",icon:"user",required:"true",iconPosition:"left",style:{minWidth:"25em"},placeholder:"Your AD-username",className:"form-control1"})),r.a.createElement(R.a.Group,{inline:!0},r.a.createElement("label",{style:{width:"75px"}},"Password"),r.a.createElement(U.a,{type:"password",name:"password",required:"true",icon:"lock",iconPosition:"left",style:{minWidth:"25em"},placeholder:"Your password",className:"form-control2"})),r.a.createElement(R.a.Group,{inline:!0},r.a.createElement("label",{style:{width:"75px"}},"Password Again"),r.a.createElement(U.a,{type:"password",name:"passwordA",required:"true",icon:"lock",iconPosition:"left",style:{minWidth:"25em"},placeholder:"Your password",className:"form-control2"})),r.a.createElement(R.a.Group,null,r.a.createElement(C.a,{type:"submit",color:"blue"},"Register"))))))}}]),t}(r.a.Component),q={createUser:D},B=Object(h.b)(function(e){return{user:e.user,loading:e.loading}},q)(Y),J=function(e){function t(){return Object(s.a)(this,t),Object(d.a)(this,Object(p.a)(t).apply(this,arguments))}return Object(m.a)(t,e),Object(u.a)(t,[{key:"componentDidMount",value:function(){try{var e=window.localStorage.getItem("bikesLogger");if(e&&"{}"!==e){var t=JSON.parse(e);this.props.tokenLogin(t)}}catch(n){console.log(n)}}},{key:"componentWillReceiveProps",value:function(e){var t={user:e.user,token:e.token,created:e.created};window.localStorage.setItem("bikesLogger",JSON.stringify(t))}},{key:"render",value:function(){var e=this,t=function(){return r.a.createElement("main",null,r.a.createElement(f.c,null,r.a.createElement(f.a,{path:"/register",render:function(){return r.a.createElement(B,null)}}),r.a.createElement(f.a,{path:"/",render:function(){return r.a.createElement(_,null)}})))};return r.a.createElement(g.a,null,r.a.createElement("div",null,!0===e.props.loading?r.a.createElement("p",null,"loading lol"):r.a.createElement(t,null)))}}]),t}(a.Component),M=Object(f.e)(Object(h.b)(function(e){return{user:e.user.user,token:e.user.token,loading:e.loading.loading}},{tokenLogin:function(e){return function(){var t=Object(w.a)(E.a.mark(function t(n){return E.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n({type:"LOGIN_BYTOKEN",user:e});case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()}})(J)),F=n(114),z=n(43),K=n(192),$=n(193),H={loading:!1},Q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:H,t=arguments.length>1?arguments[1]:void 0;return t.type.includes("ATTEMPT")?{loading:!0}:t.type.includes("SUCCESS")?{loading:!1}:t.type.includes("FAILURE")?{loading:!1}:(t.type,e)},V=Object(z.combineReducers)({user:O,loading:Q}),X=Object(z.createStore)(V,Object($.composeWithDevTools)(Object(z.applyMiddleware)(K.a,function(e){return function(t){return function(n){t(n);var a=n.payload;a&&function(e,t,n,a,r){var o={headers:{Authorization:"bearer ".concat(r)}};switch(t){case"get":return k.a.get(e,o);case"post":return k.a.post(e,n,o);case"put":return k.a.put(e,n,o);case"delete":return k.a.delete(e,o);default:return Promise.reject(new Error("Invalid http method"))}}(a.route,a.method,a.data,a.prefix,e.getState().user.token).then(function(t){e.dispatch({type:"".concat(a.prefix,"SUCCESS"),response:t.data})}).catch(function(t){return e.dispatch({type:"".concat(a.prefix,"FAILURE"),response:t})})}}})));i.a.render(r.a.createElement(h.a,{store:X},r.a.createElement(F.a,null,r.a.createElement(M,null))),document.getElementById("root")),function(e){if("serviceWorker"in navigator){if(new URL("",window.location.href).origin!==window.location.origin)return;window.addEventListener("load",function(){var t="".concat("","/service-worker.js");c?(function(e,t){fetch(e).then(function(n){var a=n.headers.get("content-type");404===n.status||null!=a&&-1===a.indexOf("javascript")?navigator.serviceWorker.ready.then(function(e){e.unregister().then(function(){window.location.reload()})}):l(e,t)}).catch(function(){console.log("No internet connection found. App is running in offline mode.")})}(t,e),navigator.serviceWorker.ready.then(function(){console.log("This web app is being served cache-first by a service worker. To learn more, visit https://bit.ly/CRA-PWA")})):l(t,e)})}}()}},[[205,1,2]]]);
  //# sourceMappingURL=main.c20d830d.chunk.js.map