text: (this["webpackJsonpgoit-react-hw-08-phonebook"]=this["webpackJsonpgoit-react-hw-08-phonebook"]||[]).push([[3],{100:function(e,t,n){"use strict";n.r(t);n(52);var c=n(0),r=n.n(c),a=n(23),o=n.n(a),u=n(8),s=n(14),i=n(48),l=n(6),b=n(26),f=function(e){return e.auth.isUserInLogin},d=function(e){return e.auth.user.name},m=f;function O(e){var t=e.component,n=e.redirectTo,c=Object(b.a)(e,["component","redirectTo"]),a=Object(u.c)(m);return r.a.createElement(l.b,Object.assign({},c,{render:function(e){return a?r.a.createElement(t,e):r.a.createElement(l.a,{to:n})}}))}var j=f;function g(e){var t=e.component,n=e.redirectTo,c=Object(b.a)(e,["component","redirectTo"]),a=Object(u.c)(j);return r.a.createElement(l.b,Object.assign({},c,{render:function(e){return a&&c.restricted?r.a.createElement(l.a,{to:n}):r.a.createElement(t,e)}}))}var h=n(38),E=n.n(h),p=n(22),C=n(32),v=n.n(C),S=n(27),_=n.n(S),y=f;function N(){var e=Object(u.c)(y);return r.a.createElement("nav",{className:_.a.mainNavBox},r.a.createElement(s.b,{to:"/",exact:!0,activeStyle:{color:"#656566"},className:_.a.mainNav},"Home"),e&&r.a.createElement(s.b,{to:"/contacts",activeStyle:{color:"#656566"},className:_.a.mainNav},"Contacts"))}var x=n(33),R=n.n(x),q=function(){return r.a.createElement("div",null,r.a.createElement(s.b,{activeStyle:{color:"#656566"},className:R.a.secondNav,to:"/register",exact:!0},"Registration"),r.a.createElement(s.b,{activeStyle:{color:"#656566"},className:R.a.secondNav,to:"/login",exact:!0},"Authorization"))},U=n(21),w=n.n(U),k=d,B=p.a.logOut;function T(){var e=Object(u.b)(),t=Object(u.c)(k),n=Object(c.useCallback)((function(){e(B())}),[e]);return r.a.createElement(r.a.Fragment,null,r.a.createElement("div",{className:w.a.welcomeBox},r.a.createElement("div",{className:w.a.welcomeText},"Welcome,"),r.a.createElement("div",{className:w.a.welcomeName},t)),r.a.createElement("button",{className:w.a.btnLogout,type:"button",onClick:n},"Logout"))}var A=f;function M(e){e.isAuthenticated;var t=Object(u.c)(A);return r.a.createElement("div",{className:v.a.appBarBox},r.a.createElement("header",null,r.a.createElement(N,null),r.a.createElement("div",{className:v.a.secondMenuBox},t?r.a.createElement(T,null):r.a.createElement(q,null))))}var z=n(49),L=n.n(z),F=function(e){var t=e.children;return r.a.createElement("div",{className:L.a.containerGeneral},t)},G=Object(c.lazy)((function(){return n.e(1).then(n.bind(null,119))})),J=Object(c.lazy)((function(){return n.e(0).then(n.bind(null,122))})),I=Object(c.lazy)((function(){return n.e(4).then(n.bind(null,120))})),H=Object(c.lazy)((function(){return n.e(2).then(n.bind(null,121))})),P=p.a.getCurrentUser;function Q(){var e=Object(u.b)();return Object(c.useEffect)((function(){e(P())}),[e]),r.a.createElement(F,null,r.a.createElement(M,null),r.a.createElement(c.Suspense,{fallback:r.a.createElement(E.a,{type:"Puff",color:"#666464",height:60,width:60})},r.a.createElement(l.d,null,r.a.createElement(g,{exact:!0,path:"/",component:G}),r.a.createElement(g,{path:"/register",component:I,restricted:!0,redirectTo:"/contacts"}),r.a.createElement(g,{path:"/login",component:H,restricted:!0,redirectTo:"/contacts"}),r.a.createElement(O,{path:"/contacts",component:J,redirectTo:"/login"}))))}var Y,D,K,W,V=n(25),X=n(1),Z=n(17),$=n(50),ee=n.n($),te=n(35),ne=n(2),ce=n(7),re=n(5),ae=re.a.registerSuccess,oe=re.a.registerError,ue=re.a.loginSuccess,se=re.a.loginError,ie=re.a.logoutSuccess,le=re.a.logoutError,be=re.a.getCurrentUserSuccess,fe=re.a.getCurrentUserError,de={name:null,email:null},me=Object(X.c)(de,(Y={},Object(ne.a)(Y,ae,(function(e,t){return t.payload.user})),Object(ne.a)(Y,ue,(function(e,t){return t.payload.user})),Object(ne.a)(Y,ie,(function(e,t){return de})),Object(ne.a)(Y,be,(function(e,t){return t.payload})),Y)),Oe=Object(X.c)(null,(D={},Object(ne.a)(D,ae,(function(e,t){return t.payload.token})),Object(ne.a)(D,ue,(function(e,t){return t.payload.token})),Object(ne.a)(D,ie,(function(e,t){return null})),D)),je=function(e,t){return t.payload},ge=Object(X.c)(null,(K={},Object(ne.a)(K,oe,je),Object(ne.a)(K,se,je),Object(ne.a)(K,le,je),Object(ne.a)(K,fe,je),K)),he=Object(X.c)(!1,(W={},Object(ne.a)(W,ae,(function(){return!0})),Object(ne.a)(W,ue,(function(){return!0})),Object(ne.a)(W,be,(function(){return!0})),Object(ne.a)(W,oe,(function(){return!1})),Object(ne.a)(W,se,(function(){return!1})),Object(ne.a)(W,fe,(function(){return!1})),Object(ne.a)(W,ie,(function(){return!1})),W)),Ee=Object(ce.c)({user:me,isUserInLogin:he,token:Oe,error:ge}),pe=Object(V.a)(Object(X.d)({serializableCheck:{ignoredActions:[Z.a,Z.f,Z.b,Z.c,Z.d,Z.e]}})),Ce={key:"auth",storage:ee.a,whitelist:["token"]},ve=Object(X.a)({reducer:{auth:Object(Z.g)(Ce,Ee),contacts:te.a},middleware:pe}),Se={store:ve,persistor:Object(Z.h)(ve)};o.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(u.a,{store:Se.store},r.a.createElement(i.a,{loading:null,persistor:Se.persistor},r.a.createElement(s.a,null,r.a.createElement(Q,null))))),document.getElementById("root"))},15:function(e,t,n){"use strict";var c=n(1),r=Object(c.b)("contacts/fetchContactsRequest"),a=Object(c.b)("contacts/fetchContactsSuccess"),o=Object(c.b)("contacts/fetchContactsError"),u=Object(c.b)("contacts/addContactRequest"),s=Object(c.b)("contacts/addContactSuccess"),i=Object(c.b)("contacts/addContactError"),l=Object(c.b)("contacts/deleteContactRequest"),b=Object(c.b)("contacts/deleteContactSuccess"),f=Object(c.b)("contacts/deleteContactError"),d=Object(c.b)("contacts/Filter");t.a={fetchContactsRequest:r,fetchContactsSuccess:a,fetchContactsError:o,addContactRequest:u,addContactSuccess:s,addContactContactsError:i,deleteContactRequest:l,deleteContactSuccess:b,deleteContactError:f,changeFilter:d}},21:function(e,t,n){e.exports={welcomeBox:"UserMenu_welcomeBox__3MxKw",welcomeText:"UserMenu_welcomeText__Yww3U",welcomeName:"UserMenu_welcomeName__13pxt",btnLogout:"UserMenu_btnLogout__2cbiQ"}},22:function(e,t,n){"use strict";var c=n(18),r=n.n(c),a=n(5),o=a.a.registerRequest,u=a.a.registerSuccess,s=a.a.registerError,i=a.a.logoutRequest,l=a.a.logoutSuccess,b=a.a.logoutError,f=a.a.loginRequest,d=a.a.loginSuccess,m=a.a.loginError,O=a.a.getCurrentUserRequest,j=a.a.getCurrentUserSuccess,g=a.a.getCurrentUserError;r.a.defaults.baseURL="https://goit-phonebook-api.herokuapp.com/";var h=function(e){r.a.defaults.headers.common.Authorization="Bearer ".concat(e)},E=function(){r.a.defaults.headers.common.Authorization=""};t.a={register:function(e){return function(t){t(o()),r.a.post("/users/signup",e).then((function(e){return t(u(e.data),h(e.data.token))})).catch((function(e){return t(s(e.message))}))}},login:function(e){return function(t){t(f()),r.a.post("/users/login",e).then((function(e){return t(d(e.data),h(e.data.token))})).catch((function(e){return t(m(e.message))}))}},logOut:function(){return function(e){e(i()),r.a.post("/users/logout").then((function(){return e(l())}),E()).catch((function(t){return e(b(t.message))}))}},getCurrentUser:function(){return function(e,t){var n=t().auth.token;n&&(h(n),e(O()),r.a.get("/users/current").then((function(t){return e(j(t.data))})).catch((function(t){return e(g(t.message))})))}}}},27:function(e,t,n){e.exports={mainNav:"Navigation_mainNav__yQBbY"}},32:function(e,t,n){e.exports={appBarBox:"AppBar_appBarBox__2lS8R",secondMenuBox:"AppBar_secondMenuBox___DpRe"}},33:function(e,t,n){e.exports={secondNav:"AuthNav_secondNav__2J-Av"}},35:function(e,t,n){"use strict";var c,r,a,o=n(2),u=n(25),s=n(7),i=n(1),l=n(15),b=l.a.fetchContactsRequest,f=l.a.fetchContactsSuccess,d=l.a.fetchContactsError,m=l.a.addContactRequest,O=l.a.addContactSuccess,j=l.a.addContactContactsError,g=l.a.deleteContactRequest,h=l.a.deleteContactSuccess,E=l.a.deleteContactError,p=l.a.changeFilter,C=Object(i.c)([],(c={},Object(o.a)(c,f,(function(e,t){return t.payload})),Object(o.a)(c,O,(function(e,t){var n=t.payload;return[].concat(Object(u.a)(e),[n])})),Object(o.a)(c,h,(function(e,t){var n=t.payload;return e.filter((function(e){return e.id!==n}))})),c)),v=Object(i.c)("",Object(o.a)({},p,(function(e,t){return t.payload}))),S=Object(i.c)(!1,(r={},Object(o.a)(r,b,(function(){return!0})),Object(o.a)(r,f,(function(){return!1})),Object(o.a)(r,d,(function(){return!1})),Object(o.a)(r,m,(function(){return!0})),Object(o.a)(r,O,(function(){return!1})),Object(o.a)(r,j,(function(){return!1})),Object(o.a)(r,g,(function(){return!0})),Object(o.a)(r,h,(function(){return!1})),Object(o.a)(r,E,(function(){return!1})),r)),_=Object(i.c)(null,(a={},Object(o.a)(a,d,(function(e,t){return t.payload})),Object(o.a)(a,j,(function(e,t){return t.payload})),Object(o.a)(a,E,(function(e,t){return t.payload})),a));t.a=Object(s.c)({items:C,filter:v,loading:S,error:_})},49:function(e,t,n){e.exports={containerGeneral:"ContainerGeneralForPage_containerGeneral__3EJbH"}},5:function(e,t,n){"use strict";var c=n(1),r=Object(c.b)("auth/registerRequest"),a=Object(c.b)("auth/registerSuccess"),o=Object(c.b)("auth/registerError"),u=Object(c.b)("auth/loginRequest"),s=Object(c.b)("auth/loginSuccess"),i=Object(c.b)("auth/loginError"),l=Object(c.b)("auth/logoutRequest"),b=Object(c.b)("auth/logoutSuccess"),f=Object(c.b)("auth/logoutError"),d=Object(c.b)("auth/getCurrentUserRequest"),m=Object(c.b)("auth/getCurrentUserSuccess"),O=Object(c.b)("auth/getCurrentUserError");t.a={registerRequest:r,registerSuccess:a,registerError:o,logoutRequest:l,logoutSuccess:b,logoutError:f,loginRequest:u,loginSuccess:s,loginError:i,getCurrentUserRequest:d,getCurrentUserSuccess:m,getCurrentUserError:O}},51:function(e,t,n){e.exports=n(100)}},[[51,5,6]]]);
  //# sourceMappingURL=main.5f41c00c.chunk.js.map