text: (this.webpackJsonplesson=this.webpackJsonplesson||[]).push([[0],{12:function(t,e,n){t.exports={list:"ContactList_list__3HLiV",listItem:"ContactList_listItem__3jWlM",button:"ContactList_button__36skX",name:"ContactList_name__3dSRw",enter:"ContactList_enter__VCDc1",enterActive:"ContactList_enterActive__1peDQ",exit:"ContactList_exit__6STL3",exitActive:"ContactList_exitActive__3d_fM"}},22:function(t,e,n){t.exports={appear:"PhoneBook_appear__1iphc",appearActive:"PhoneBook_appearActive__HN9CD",title:"PhoneBook_title__3YER3",enter:"PhoneBook_enter__22CX5",enterActive:"PhoneBook_enterActive__iv_qA",exit:"PhoneBook_exit__3mIVP",exitActive:"PhoneBook_exitActive__16kw4"}},25:function(t,e,n){t.exports={NotificationWrapper:"Notification_NotificationWrapper__3ENjU",appear:"Notification_appear__3_84N",appearActive:"Notification_appearActive__3JFQH",exit:"Notification_exit__23375",exitActive:"Notification_exitActive__MTPXx"}},26:function(t,e,n){t.exports={NotificationWrapper:"Empty_NotificationWrapper__1dgPi",appear:"Empty_appear__3pOJ5",appearActive:"Empty_appearActive__1dMyK",exit:"Empty_exit__1s2xL",exitActive:"Empty_exitActive__3GkHD"}},27:function(t,e,n){t.exports={input:"ContactFilter_input__QJJUz"}},40:function(t,e,n){},41:function(t,e,n){},42:function(t,e,n){"use strict";n.r(e);var a,c=n(1),o=n(0),i=n(8),r=n.n(i),s=n(5),l=(n(40),n(14)),u=n(15),p=n(17),_=n(16),b=n(9),m=n(6),d=n(45),j={addContact:Object(m.b)("contacts/add",(function(t){var e=t.name,n=t.number;return{payload:{contact:{id:Object(d.a)(),name:e,number:n}}}})),deleteContact:Object(m.b)("contacts/remove"),onHandleFilter:Object(m.b)("contacts/handleFilter"),addToLocalStorage:Object(m.b)("contacts/addToLocalStorage")},h=n(25),f=n.n(h),x=function(t){var e=t.name;return Object(c.jsx)("div",{className:f.a.NotificationWrapper,children:"".concat(e," is already in Contacts")})},O=n(26),v=n.n(O),C=function(){return Object(c.jsx)("div",{className:v.a.NotificationWrapper,children:"ALL FIELDS MUST BE FILLED!"})},N=n(44),y=n(7),A=n.n(y),L=function(t){Object(p.a)(n,t);var e=Object(_.a)(n);function n(){var t;Object(l.a)(this,n);for(var a=arguments.length,c=new Array(a),o=0;o<a;o++)c[o]=arguments[o];return(t=e.call.apply(e,[this].concat(c))).state={name:"",number:"",newContact:null,showAlert:!1,showEmpty:!1},t.handleChange=function(e){var n=e.target.name;t.setState(Object(b.a)({},n,e.target.value))},t.handleSubmit=function(e){e.preventDefault(),t.props.contacts.some((function(e){return e.name===t.state.name}))?(t.setState({newContact:t.state.name,showAlert:!0}),setTimeout((function(){t.setState({showAlert:!1})}),2500)):""===t.state.name||""===t.state.contact?(t.setState({showEmpty:!0}),setTimeout((function(){t.setState({showEmpty:!1})}),2500)):t.props.addContact({name:t.state.name,number:t.state.number}),t.setState({name:"",number:""})},t}return Object(u.a)(n,[{key:"componentDidMount",value:function(){var t=localStorage.getItem("contacts");t&&this.props.addToLocalStorage(JSON.parse(t))}},{key:"componentDidUpdate",value:function(t){var e=this.props.contacts;t.contacts!==e&&localStorage.setItem("contacts",JSON.stringify(e))}},{key:"render",value:function(){var t=this.state,e=t.newContact,n=t.showAlert,a=t.showEmpty;return Object(c.jsxs)("div",{children:[Object(c.jsxs)("form",{onSubmit:this.handleSubmit,className:A.a.form,children:[Object(c.jsxs)("label",{className:A.a.label,children:["Name",Object(c.jsx)("input",{className:A.a.input,name:"name",type:"text",value:this.state.name,onChange:this.handleChange})]}),Object(c.jsxs)("label",{className:A.a.label,children:["Number",Object(c.jsx)("input",{className:A.a.input,name:"number",type:"tel",value:this.state.number,onChange:this.handleChange})]}),Object(c.jsx)("button",{className:A.a.button,type:"submit",children:"Add contact"})]}),Object(c.jsx)(N.a,{in:n,timeout:250,classNames:A.a,unmountOnExit:!0,children:Object(c.jsx)(x,{name:e})}),Object(c.jsx)(N.a,{in:a,timeout:250,classNames:A.a,unmountOnExit:!0,children:Object(c.jsx)(C,{})})]})}}]),n}(o.Component),g={addContact:j.addContact,addToLocalStorage:j.addToLocalStorage},S=Object(s.b)((function(t){return{contacts:t.contacts.contactList}}),g)(L),F=n(46),k=n(12),w=n.n(k),E=Object(s.b)((function(t){var e=t.contacts,n=e.contactList,a=e.filter.toLowerCase();return{contacts:n.filter((function(t){return t.name.toLowerCase().includes(a)}))}}),(function(t){return{deleteContact:function(e){t(j.deleteContact(e))}}}))((function(t){var e=t.contacts,n=t.deleteContact,a=function(t){var e=t.target.dataset.id;n(e)};return Object(c.jsxs)("div",{children:[Object(c.jsx)("h2",{children:"Contacts"}),Object(c.jsx)(F.a,{component:"ul",className:w.a.list,children:e.map((function(t){return Object(c.jsx)(N.a,{timeout:250,classNames:w.a,children:Object(c.jsxs)("li",{className:w.a.listItem,children:[Object(c.jsx)("span",{className:w.a.name,children:t.name}),": ",Object(c.jsx)("span",{children:t.number}),Object(c.jsx)("button",{className:w.a.button,type:"button","data-id":t.id,onClick:a,children:"Delete"})]})},t.id)}))})]})})),T=n(27),D=n.n(T),P={onHandleFilter:j.onHandleFilter},B=Object(s.b)((function(t){return{value:t.contacts.filter}}),P)((function(t){var e=t.value,n=t.onHandleFilter;return Object(c.jsxs)("div",{children:[Object(c.jsx)("h3",{children:"Find contacts by name"}),Object(c.jsx)("input",{className:D.a.input,type:"text",value:e,onChange:function(t){return n(t.target.value)}})]})})),H=n(22),I=n.n(H),J=function(t){Object(p.a)(n,t);var e=Object(_.a)(n);function n(){return Object(l.a)(this,n),e.apply(this,arguments)}return Object(u.a)(n,[{key:"render",value:function(){return Object(c.jsxs)("div",{children:[Object(c.jsx)(N.a,{in:!0,appear:!0,timeout:500,classNames:I.a,children:Object(c.jsx)("h1",{className:I.a.title,children:"Phonebook"})}),Object(c.jsx)(S,{}),this.props.contacts.length>1&&Object(c.jsx)(B,{}),Object(c.jsx)(E,{})]})}}]),n}(o.Component),W=Object(s.b)((function(t){return{contacts:t.contacts.contactList}}))(J),M=function(){return Object(c.jsx)(W,{})},U=n(28),V=n(4),Q=Object(m.c)([],(a={},Object(b.a)(a,j.addContact,(function(t,e){return[].concat(Object(U.a)(t),[e.payload.contact])})),Object(b.a)(a,j.deleteContact,(function(t,e){return t.filter((function(t){return t.id!==e.payload}))})),Object(b.a)(a,j.addToLocalStorage,(function(t,e){return e.payload})),a)),X=Object(m.c)("",Object(b.a)({},j.onHandleFilter,(function(t,e){return e.payload}))),R=Object(V.c)({contactList:Q,filter:X}),Z=Object(m.a)({reducer:{contacts:R}});n(41);r.a.render(Object(c.jsx)(s.a,{store:Z,children:Object(c.jsx)(M,{})}),document.getElementById("root"))},7:function(t,e,n){t.exports={form:"ContactForm_form__3ByxU",label:"ContactForm_label__167ST",input:"ContactForm_input__3i43o",button:"ContactForm_button__xpCZW",enter:"ContactForm_enter__2CcHt",enterActive:"ContactForm_enterActive__3DMAv",exit:"ContactForm_exit__2uVZp",exitActive:"ContactForm_exitActive__1hnah"}}},[[42,1,2]]]);
  //# sourceMappingURL=main.642797ca.chunk.js.map