text: (this["webpackJsonpsocial-incident"]=this["webpackJsonpsocial-incident"]||[]).push([[0],{20:function(e,t,n){e.exports=n(33)},25:function(e,t,n){},32:function(e,t,n){},33:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),o=n(17),c=n.n(o),s=(n(25),n(12)),i=n(7),l=n(6),u=n.n(l),m=n(9),p=n(5),d=function(){var e=Object(a.useState)(""),t=Object(p.a)(e,2),n=t[0],o=t[1],c=Object(a.useState)(""),s=Object(p.a)(c,2),i=s[0],l=s[1],d=Object(a.useState)(""),b=Object(p.a)(d,2),g=b[0],h=b[1],w=function(){var e=Object(m.a)(u.a.mark((function e(){var t,a;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""===n&&""===i){e.next=10;break}return e.next=3,fetch("https://9il287rnf8.execute-api.us-east-1.amazonaws.com/mvp/login",{method:"post",body:JSON.stringify({username:n,password:i})});case 3:return t=e.sent,e.next=6,t.json();case 6:200===(a=e.sent).status?(window.sessionStorage.setItem("username",n),window.sessionStorage.setItem("userToken",a.token),window.location.href="/welcome"):h(a.error),e.next=11;break;case 10:h("Either username or password not filled");case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return r.a.createElement("div",{id:"screen-body"},r.a.createElement("div",{class:"login"},r.a.createElement("h1",null,"Login"),r.a.createElement("br",null),r.a.createElement("small",null,g),r.a.createElement("input",{type:"text",value:n,onChange:function(e){return o(e.target.value)},placeholder:"username",required:"required"}),r.a.createElement("input",{type:"password",value:i,onChange:function(e){return l(e.target.value)},placeholder:"password",required:"required"}),r.a.createElement("button",{onClick:w,class:"btn btn-primary btn-block btn-large"},"Login"),r.a.createElement("button",{onClick:function(e){return window.location.href="/registration"},class:"btn btn-primary btn-block btn-large"},"Register")))},b=function(){var e=Object(a.useState)(""),t=Object(p.a)(e,2),n=t[0],o=t[1],c=Object(a.useState)(""),s=Object(p.a)(c,2),i=s[0],l=s[1],d=Object(a.useState)(""),b=Object(p.a)(d,2),g=b[0],h=b[1],w=Object(a.useState)(""),f=Object(p.a)(w,2),v=f[0],E=f[1],k=Object(a.useState)(""),y=Object(p.a)(k,2),O=y[0],j=y[1],x=function(){var e=Object(m.a)(u.a.mark((function e(){var t,a;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i!==g){e.next=10;break}return e.next=3,fetch("https://9il287rnf8.execute-api.us-east-1.amazonaws.com/mvp/register",{method:"post",body:JSON.stringify({username:n,password:i,email:v})});case 3:return t=e.sent,e.next=6,t.json();case 6:200===(a=e.sent).status?window.location.href="/login":j(a.error),e.next=11;break;case 10:j("Passwords don't match");case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return r.a.createElement("div",{class:"login"},r.a.createElement("h1",null,"Register Here!"),r.a.createElement("br",null),r.a.createElement("small",null,O),r.a.createElement("input",{type:"text",value:v,onChange:function(e){return E(e.target.value)},placeholder:"e-mail ID",required:"required"}),r.a.createElement("input",{type:"text",value:n,onChange:function(e){return o(e.target.value)},placeholder:"username",required:"required"}),r.a.createElement("input",{type:"password",value:i,onChange:function(e){return l(e.target.value)},placeholder:"password",required:"required"}),r.a.createElement("input",{type:"password",value:g,onChange:function(e){return h(e.target.value)},placeholder:"confirm password",required:"required"}),r.a.createElement("button",{onClick:x,class:"btn btn-primary btn-block btn-large"},"Register"),r.a.createElement("button",{onClick:function(e){return window.location.href="/"},class:"btn btn-primary btn-block btn-large"},"Login Instead"))},g=function(){var e=function(){var e=Object(m.a)(u.a.mark((function e(){var t;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=window.sessionStorage.getItem("userToken"),e.next=3,fetch("https://9il287rnf8.execute-api.us-east-1.amazonaws.com/mvp/logout",{method:"post",body:JSON.stringify({token:t})});case 3:e.sent,window.sessionStorage.removeItem("username"),window.sessionStorage.removeItem("userToken"),window.location.href="/login";case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),t=window.sessionStorage.getItem("username");return null===t?r.a.createElement(i.a,{to:"/login"}):r.a.createElement(r.a.Fragment,null,r.a.createElement("h1",null,"Hello ",t," , welcome to my social media site"),r.a.createElement("p",null,"Welcome to this page and happy sharing"),r.a.createElement("p",null,"I'm still welcoming you"),r.a.createElement("button",{onClick:e},"Logout"))};n(32);var h=function(){return r.a.createElement(s.a,null,r.a.createElement(i.d,null,r.a.createElement(i.b,{path:"/registration",component:b}),r.a.createElement(i.b,{path:"/login",component:d}),r.a.createElement(i.b,{path:"/welcome",component:g}),r.a.createElement(i.b,{path:"/",component:d})))};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}$/));c.a.render(r.a.createElement(h,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[20,1,2]]]);
  //# sourceMappingURL=main.eee0b4a6.chunk.js.map