text: (this["webpackJsonpburger-builder"]=this["webpackJsonpburger-builder"]||[]).push([[4],{102:function(e,t,n){e.exports={Auth:"Auth_Auth__1_UVG"}},103:function(e,t,n){"use strict";n.r(t);var a=n(24),i=n(6),r=n(7),u=n(9),l=n(8),s=n(1),c=n(17),o=n(97),d=n(33),h=n(41),p=n(102),b=n.n(p),j=n(18),v=n(5),g=n(4),f=n(0),m=function(e){Object(u.a)(n,e);var t=Object(l.a)(n);function n(){var e;Object(i.a)(this,n);for(var r=arguments.length,u=new Array(r),l=0;l<r;l++)u[l]=arguments[l];return(e=t.call.apply(t,[this].concat(u))).state={controls:{email:{elementType:"input",elementConfig:{type:"email",placeholder:"Your E-Mail"},value:"",validation:{required:!0,isEmail:!0},valid:!1,touched:!1},password:{elementType:"input",elementConfig:{type:"password",placeholder:"Your Password"},value:"",validation:{required:!0,minLength:7},valid:!1,touched:!1}},isSignUp:!0},e.inputChangedHandler=function(t,n){var i=Object(g.b)(e.state.controls,Object(a.a)({},n,Object(g.b)(e.state.controls[n],{value:t.target.value,valid:Object(g.a)(t.target.value,e.state.controls[n].validation),touched:!0})));e.setState({controls:i})},e.submitHandler=function(t){t.preventDefault(),e.props.onAuth(e.state.controls.email.value,e.state.controls.password.value,e.state.isSignUp)},e.switchAuthModeHandler=function(){e.setState((function(e){return{isSignUp:!e.isSignUp}}))},e}return Object(r.a)(n,[{key:"componentDidMount",value:function(){this.props.buildingBurger||"/"===this.props.authRedirectPath||this.prop.onSetAuthRedirectPath()}},{key:"render",value:function(){var e=this,t=[];for(var n in this.state.controls)t.push({id:n,config:this.state.controls[n]});var a=t.map((function(t){return Object(f.jsx)(o.a,{elementType:t.config.elementType,elementConfig:t.config.elementConfig,Value:t.config.value,invalid:!t.config.valid,shouldValidate:t.config.validation,touched:t.config.touched,changed:function(n){return e.inputChangedHandler(n,t.id)}},t.id)}));this.props.loading&&(a=Object(f.jsx)(h.a,{}));var i=null;this.props.error&&(i=Object(f.jsx)("p",{children:this.props.error.message}));var r=null;return this.props.isAuthenticated&&(r=Object(f.jsx)(v.a,{to:this.props.authRedirectPath})),Object(f.jsxs)("div",{className:b.a.Auth,children:[r,i,Object(f.jsxs)("form",{onSubmit:this.submitHandler,children:[a,Object(f.jsx)(d.a,{btnType:"Success",children:"SUBMIT"})]}),Object(f.jsxs)(d.a,{btnType:"Danger",clicked:this.switchAuthModeHandler,children:["SWITCH TO ",this.state.isSignUp?"SIGNIN":"SIGNUP"]})]})}}]),n}(s.Component);t.default=Object(c.b)((function(e){return{loading:e.auth.loading,error:e.auth.error,isAuthenticated:null!==e.auth.token,buildingBurger:e.burgerBuilder.building,authRedirectPath:e.auth.authRedirectPath}}),(function(e){return{onAuth:function(t,n,a){return e(j.b(t,n,a))},onSetAuthRedirectPath:function(){return e(j.j("/"))}}}))(m)},97:function(e,t,n){"use strict";var a=n(10),i=(n(1),n(98)),r=n.n(i),u=n(0);t.a=function(e){var t=null,n=[r.a.InputElement];switch(e.invalid&&e.shouldValidate&&e.touched&&n.push(r.a.Invalid),e.elementType){case"input":t=Object(u.jsx)("input",Object(a.a)(Object(a.a)({className:n.join(" ")},e.elementConfig),{},{value:e.value,onChange:e.changed}));break;case"textarea":t=Object(u.jsx)("textarea",Object(a.a)(Object(a.a)({className:n.join(" ")},e.elementConfig),{},{value:e.value,onChange:e.changed}));break;case"select":t=Object(u.jsx)("select",{className:n.join(" "),value:e.value,onChange:e.changed,children:e.elementConfig.options.map((function(e){return Object(u.jsx)("option",{value:e.value,children:e.displayValue},e.value)}))});break;default:t=Object(u.jsx)("input",Object(a.a)(Object(a.a)({className:n.join(" ")},e.elementConfig),{},{value:e.value,onChange:e.changed}))}return Object(u.jsxs)("div",{className:r.a.Input,children:[Object(u.jsx)("label",{className:r.a.Label,children:e.label}),t]})}},98:function(e,t,n){e.exports={Input:"Input_Input__1j4PD",Label:"Input_Label__2i2Tf",InputElement:"Input_InputElement__3haSw",Invalid:"Input_Invalid__3FWzZ"}}}]);
  //# sourceMappingURL=4.f241f2ac.chunk.js.map