text: (this.webpackJsonpfrontend=this.webpackJsonpfrontend||[]).push([[0],{17:function(e,t,n){e.exports=n(40)},40:function(e,t,n){"use strict";n.r(t);var r=n(0),a=n.n(r),c=n(15),u=n.n(c),o=n(1),l=n.n(o),i=n(2),s=n(3),p=n(5),d=n.n(p),f={login:function(){var e=Object(i.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d.a.post("/api/login",t);case 3:return n=e.sent,e.abrupt("return",n.data);case 7:e.prev=7,e.t0=e.catch(0),console.error("Exception occured in login service: ",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t){return e.apply(this,arguments)}}()},v=null,m=function(e){v="bearer ".concat(e)},b=function(){return v},h={register:function(){var e=Object(i.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d.a.post("/api/users",t);case 3:return n=e.sent,e.abrupt("return",n.data);case 7:e.prev=7,e.t0=e.catch(0),console.error("Exception occured in registration service: ",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t){return e.apply(this,arguments)}}()},g={getTableList:function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d.a.get("".concat("/api/users","/").concat(t));case 3:return n=e.sent,r=n.data,e.next=7,r.personalTables;case 7:return e.abrupt("return",e.sent);case 10:e.prev=10,e.t0=e.catch(0),console.error("Exception occured in getTableList service: ",e.t0);case 13:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t){return e.apply(this,arguments)}}(),createTable:function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={headers:{Authorization:b()}},e.next=4,d.a.post("/api/tables",t,n);case 4:return r=e.sent,e.abrupt("return",r.data);case 8:e.prev=8,e.t0=e.catch(0),console.error("Exception occureed in create Table service fe: ",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}()},E={getGoalsList:function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d.a.get("".concat("/api/tables","/").concat(t));case 3:return n=e.sent,r=n.data,e.abrupt("return",r.goals);case 8:e.prev=8,e.t0=e.catch(0),console.error("Exception occured in getGoalsList service: ",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}(),getGoalsByID:function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Promise.all(t.map((function(e){return d.a.get("".concat("/api/goals","/").concat(e))})));case 3:return n=e.sent,r=n.map((function(e){return e.data})),e.abrupt("return",r);case 8:e.prev=8,e.t0=e.catch(0),console.error("Exception occured in getGoalsByID service: ",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}(),addGoal:function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={headers:{Authorization:b()}},e.next=4,d.a.post("/api/goals",t,n);case 4:return r=e.sent,e.abrupt("return",r.data);case 8:e.prev=8,e.t0=e.catch(0),console.error("Exception occured in addGoal: ",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}(),deleteGoal:function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={headers:{Authorization:b()}},e.next=4,d.a.delete("".concat("/api/goals","/").concat(t),n);case 4:return r=e.sent,e.abrupt("return",r);case 8:e.prev=8,e.t0=e.catch(0),console.error("Excpetion occured in delete Goal service:",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}()},x=function(e){var t=e.handleSubmitGoal,n=e.title,r=e.handleTitle,c=e.goal,u=e.handleGoal;return a.a.createElement("form",{onSubmit:t},"Title:",a.a.createElement("input",{type:"text",value:n,name:"Title",onChange:function(e){var t=e.target;return r(t.value)},required:!0}),"New Goal:",a.a.createElement("input",{type:"text",value:c,name:"New Goal",onChange:function(e){var t=e.target;return u(t.value)},required:!0}),a.a.createElement("button",{type:"submit"},"add"))},w=n(16),O=function(e){(e.title.toLowerCase().includes("birthday")||e.description.toLowerCase().includes("birthday"))&&Object(w.a)({particleCount:100,spread:70,origin:{y:.6}})},y=function(e){var t=e.user,n=e.tableID,c=Object(r.useState)([]),u=Object(s.a)(c,2),o=u[0],p=u[1],d=Object(r.useState)(""),f=Object(s.a)(d,2),v=f[0],m=f[1],b=Object(r.useState)(""),h=Object(s.a)(b,2),g=h[0],w=h[1];Object(r.useEffect)((function(){function e(){return(e=Object(i.a)(l.a.mark((function e(){var t,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,E.getGoalsList(n);case 3:return t=e.sent,console.log("INTIAL GOALS IDS: ",t),e.next=7,E.getGoalsByID(t);case 7:r=e.sent,console.log("INITIAL GOALS:",r),p(r),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(0),console.log("Exception occured in Goals component useEffect: ",e.t0);case 15:case"end":return e.stop()}}),e,null,[[0,12]])})))).apply(this,arguments)}return function(){e.apply(this,arguments)}(),function(){p([])}}),[n]);var y=function(){var e=Object(i.a)(l.a.mark((function e(r){var a,c;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.preventDefault(),e.prev=1,a={author:t.id,title:g,description:v,parentTable:n},e.next=5,E.addGoal(a);case 5:c=e.sent,p(o.concat(c)),w(""),m(""),O(c),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(1),console.error("Exception occured in handling New Goal: ",e.t0);case 15:case"end":return e.stop()}}),e,null,[[1,12]])})));return function(t){return e.apply(this,arguments)}}(),j=function(){var e=Object(i.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,E.deleteGoal(t);case 3:n=o.filter((function(e){return e.id!==t})),p(n),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.error("Exception occured in deleting goal frontend: ",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t){return e.apply(this,arguments)}}();return n&&o?a.a.createElement(a.a.Fragment,null,a.a.createElement("tr",null,a.a.createElement("td",null,a.a.createElement(x,{handleSubmitGoal:y,title:g,handleTitle:w,goal:v,handleGoal:m}))),o.map((function(e){return a.a.createElement("tr",{key:e.id},a.a.createElement("td",{key:e.id,style:{border:"1px solid #34dbeb"}}," ",a.a.createElement("b",null,e.title),": ",e.description,e.author===t.id?a.a.createElement("button",{onClick:function(){return j(e.id)},style:{float:"right"}},"delete"):null))}))):a.a.createElement("tr",null)},j=function(e){var t=e.handleCreateTable,n=e.title,r=e.handleTitle;return a.a.createElement(a.a.Fragment,null,a.a.createElement("h3",null," Create new Table "),a.a.createElement("form",{onSubmit:t},"New Table Title:",a.a.createElement("input",{type:"text",value:n,name:"Title",onChange:function(e){var t=e.target;return r(t.value)},required:!0}),a.a.createElement("button",{type:"submit"},"create")))},k=function(e){var t=e.user,n=Object(r.useState)([]),c=Object(s.a)(n,2),u=c[0],o=c[1],p=Object(r.useState)(""),d=Object(s.a)(p,2),f=d[0],v=d[1];Object(r.useEffect)((function(){function e(){return(e=Object(i.a)(l.a.mark((function e(){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!t){e.next=6;break}return e.next=4,g.getTableList(t.id);case 4:n=e.sent,o(n);case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.log("Exception occured in useEffect: ",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))).apply(this,arguments)}return function(){e.apply(this,arguments)}(),function(){o([])}}),[t]);var m=function(){var e=Object(i.a)(l.a.mark((function e(t){var n,r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.prev=1,n={title:f},e.next=5,g.createTable(n);case 5:r=e.sent,o(u.concat(r.id)),v(""),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),console.error("Exception occureed in create table Tablelist component: ",e.t0);case 13:case"end":return e.stop()}}),e,null,[[1,10]])})));return function(t){return e.apply(this,arguments)}}();return t&&u?a.a.createElement(a.a.Fragment,null,a.a.createElement(j,{handleCreateTable:m,title:f,handleTitle:v}),a.a.createElement("div",null,a.a.createElement("h3",null," Your Tables"),u.map((function(e){return a.a.createElement("table",{key:e,style:{border:"1px solid #dddddd"}},a.a.createElement("tbody",null,a.a.createElement("tr",null,a.a.createElement("th",null,"TABLE: ",e)),a.a.createElement(y,{user:t,tableID:e})))})))):a.a.createElement("div",null)};var S=function(){var e=Object(r.useState)(""),t=Object(s.a)(e,2),n=t[0],c=t[1],u=Object(r.useState)(""),o=Object(s.a)(u,2),p=o[0],d=o[1],v=Object(r.useState)(null),b=Object(s.a)(v,2),g=b[0],E=b[1],x=Object(r.useState)(""),w=Object(s.a)(x,2),O=w[0],y=w[1],j=Object(r.useState)(""),S=Object(s.a)(j,2),T=S[0],G=S[1],C=Object(r.useState)(""),I=Object(s.a)(C,2),L=I[0],D=I[1];Object(r.useEffect)((function(){var e=window.localStorage.getItem("loggedUser");if(e){var t=JSON.parse(e);E(t),m(t.token)}}),[]);var N=function(){var e=Object(i.a)(l.a.mark((function e(t){var r;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.prev=1,e.next=4,f.login({username:n,password:p});case 4:r=e.sent,console.log(r.username," logged in"),window.localStorage.setItem("loggedUser",JSON.stringify(r)),m(r.token),E(r),c(""),d(""),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),console.error("Exception occured in handlelogin frontend: ",e.t0);case 16:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(t){return e.apply(this,arguments)}}(),A=function(){window.localStorage.removeItem("loggedUser"),E(null)},q=function(){var e=Object(i.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.prev=1,e.next=4,h.register({username:T,name:O,password:p});case 4:n=e.sent,console.log("User Registered: ",n.username),y(""),G(""),D(""),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),console.error("Exception in registration fe: ",e.t0);case 14:case"end":return e.stop()}}),e,null,[[1,11]])})));return function(t){return e.apply(this,arguments)}}();return a.a.createElement("div",{className:"App"},a.a.createElement("h1",null,"Geddit!"),a.a.createElement("div",null,null===g?a.a.createElement(a.a.Fragment,null,a.a.createElement("form",{onSubmit:N},a.a.createElement("h2",null,"Login"),a.a.createElement("div",null,"username",a.a.createElement("input",{type:"text",value:n,name:"Username",onChange:function(e){var t=e.target;return c(t.value)},required:!0})),a.a.createElement("div",null,"password",a.a.createElement("input",{type:"password",value:p,name:"Password",onChange:function(e){var t=e.target;return d(t.value)},required:!0})),a.a.createElement("button",{type:"submit"},"login")),a.a.createElement("form",{onSubmit:q},a.a.createElement("h2",null,"Register"),a.a.createElement("div",null,"Your Name",a.a.createElement("input",{type:"text",value:O,name:"Username",onChange:function(e){var t=e.target;return y(t.value)},required:!0})),a.a.createElement("div",null,"Username",a.a.createElement("input",{type:"text",value:T,name:"Username",onChange:function(e){var t=e.target;return G(t.value)},required:!0})),a.a.createElement("div",null,"password",a.a.createElement("input",{type:"password",value:L,name:"Password",onChange:function(e){var t=e.target;return D(t.value)},required:!0})),a.a.createElement("button",{type:"submit"},"register"))):a.a.createElement("div",null,g.username," logged in",a.a.createElement("button",{onClick:A},"Logout")),a.a.createElement(k,{user:g})))};u.a.render(a.a.createElement(S,null),document.getElementById("root"))}},[[17,1,2]]]);
  //# sourceMappingURL=main.db652bb0.chunk.js.map