text: (this.webpackJsonpsleepwell=this.webpackJsonpsleepwell||[]).push([[130],{1271:function(t,e,i){"use strict";i.r(e);var n=i(25),s=i(638),o=i(1),h=i(637),r=i(647),a=i(653),c=i(652),l=i(18),d=i(639),u=i.n(d),p=i(13),b=i(640).default,f=c.b().shape({thickness:c.a().required().positive()});e.default=function(){var t=Object(r.e)({mode:"all",resolver:Object(a.a)(f)}),e=t.register,i=t.handleSubmit,c=t.formState.errors,d=Object(l.g)(),m=Object(o.useState)(null),j=Object(s.a)(m,2),v=j[0],k=j[1],y=Object(o.useState)(!1),g=Object(s.a)(y,2),x=g[0],w=g[1],O=Object(o.useState)(!0),S=Object(s.a)(O,2),M=S[0],T=S[1],C=sessionStorage.getItem("token");return Object(p.jsx)(o.Fragment,{children:Object(p.jsx)(h.ub,{children:Object(p.jsx)(h.u,{xs:"12",sm:"12",children:Object(p.jsxs)(h.j,{children:[Object(p.jsx)(h.n,{children:"Add Thickness"}),Object(p.jsx)(h.k,{children:Object(p.jsxs)(h.J,{onSubmit:i((function(t){var e=new FormData,i=M?1:0;e.append("status",i),e.append("thickness",t.thickness),k(null),w(!0),b.post("http://markbran.in/apis/admin/thickness",e,{headers:{"auth-token":C}}).then((function(t){w(!1),d.push("/thickness")})).catch((function(t){w(!1),t.response&&t.response.data.message?k(t.response.data.message):k("Something went wrong!")}))})),children:[Object(p.jsx)("br",{}),v&&Object(p.jsx)("p",{className:"text-danger",children:v}),Object(p.jsx)(h.ub,{children:Object(p.jsx)(h.u,{xs:"6",children:Object(p.jsxs)(h.K,{children:[Object(p.jsx)(h.ab,{htmlFor:"size",children:"Thickness"}),Object(p.jsx)(h.T,{className:"mb-3",children:Object(p.jsx)(h.Q,Object(n.a)(Object(n.a)({},e("thickness")),{},{type:"text",placeholder:"Add thickness",autoComplete:"thickness"}))}),Object(p.jsx)(h.L,{className:"help-block text-danger",color:"red",children:c.thickness&&c.thickness.message})]})})}),Object(p.jsx)(h.ub,{children:Object(p.jsx)(h.u,{xl:"6",children:Object(p.jsxs)(h.K,{children:[Object(p.jsx)(h.ab,{htmlFor:"is_active",children:"Status"}),Object(p.jsx)(h.T,{children:Object(p.jsx)(u.a,{onChange:function(t){T(t)},checked:M})})]})})}),Object(p.jsx)(h.ub,{children:Object(p.jsx)(h.u,{xs:"8",children:Object(p.jsx)("button",{className:"btn btn-success",disabled:!!x,type:"submit",children:x?"Loading...":"Add Thickness"})})})]})})]})})})})}},639:function(t,e,i){t.exports=i(641)},641:function(t,e,i){Object.defineProperty(e,"__esModule",{value:!0});var n=i(1);function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}var o=n.createElement("svg",{viewBox:"-2 -5 14 20",height:"100%",width:"100%",style:{position:"absolute",top:0}},n.createElement("path",{d:"M9.9 2.12L7.78 0 4.95 2.828 2.12 0 0 2.12l2.83 2.83L0 7.776 2.123 9.9 4.95 7.07 7.78 9.9 9.9 7.776 7.072 4.95 9.9 2.12",fill:"#fff",fillRule:"evenodd"})),h=n.createElement("svg",{height:"100%",width:"100%",viewBox:"-2 -5 17 21",style:{position:"absolute",top:0}},n.createElement("path",{d:"M11.264 0L5.26 6.004 2.103 2.847 0 4.95l5.26 5.26 8.108-8.107L11.264 0",fill:"#fff",fillRule:"evenodd"}));function r(t){if(7===t.length)return t;for(var e="#",i=1;i<4;i+=1)e+=t[i]+t[i];return e}function a(t,e,i,n,s){return function(t,e,i,n,s){var o=(t-i)/(e-i);if(0===o)return n;if(1===o)return s;for(var h="#",r=1;r<6;r+=2){var a=parseInt(n.substr(r,2),16),c=parseInt(s.substr(r,2),16),l=Math.round((1-o)*a+o*c).toString(16);1===l.length&&(l="0"+l),h+=l}return h}(t,e,i,r(n),r(s))}var c=function(t){function e(e){t.call(this,e);var i=e.height,n=e.width,s=e.checked;this.t=e.handleDiameter||i-2,this.i=Math.max(n-i,n-(i+this.t)/2),this.o=Math.max(0,(i-this.t)/2),this.state={h:s?this.i:this.o},this.l=0,this.u=0,this.p=this.p.bind(this),this.v=this.v.bind(this),this.g=this.g.bind(this),this.k=this.k.bind(this),this.M=this.M.bind(this),this.m=this.m.bind(this),this.T=this.T.bind(this),this.$=this.$.bind(this),this.C=this.C.bind(this),this.D=this.D.bind(this),this.O=this.O.bind(this),this.S=this.S.bind(this)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.componentDidMount=function(){this.W=!0},e.prototype.componentDidUpdate=function(t){t.checked!==this.props.checked&&this.setState({h:this.props.checked?this.i:this.o})},e.prototype.componentWillUnmount=function(){this.W=!1},e.prototype.I=function(t){this.H.focus(),this.setState({R:t,j:!0,B:Date.now()})},e.prototype.L=function(t){var e=this.state,i=e.R,n=e.h,s=(this.props.checked?this.i:this.o)+t-i;e.N||t===i||this.setState({N:!0});var o=Math.min(this.i,Math.max(this.o,s));o!==n&&this.setState({h:o})},e.prototype.U=function(t){var e=this.state,i=e.h,n=e.N,s=e.B,o=this.props.checked,h=(this.i+this.o)/2;this.setState({h:this.props.checked?this.i:this.o});var r=Date.now()-s;(!n||r<250||o&&i<=h||!o&&i>=h)&&this.A(t),this.W&&this.setState({N:!1,j:!1}),this.l=Date.now()},e.prototype.p=function(t){t.preventDefault(),"number"==typeof t.button&&0!==t.button||(this.I(t.clientX),window.addEventListener("mousemove",this.v),window.addEventListener("mouseup",this.g))},e.prototype.v=function(t){t.preventDefault(),this.L(t.clientX)},e.prototype.g=function(t){this.U(t),window.removeEventListener("mousemove",this.v),window.removeEventListener("mouseup",this.g)},e.prototype.k=function(t){this.X=null,this.I(t.touches[0].clientX)},e.prototype.M=function(t){this.L(t.touches[0].clientX)},e.prototype.m=function(t){t.preventDefault(),this.U(t)},e.prototype.$=function(t){Date.now()-this.l>50&&(this.A(t),Date.now()-this.u>50&&this.W&&this.setState({j:!1}))},e.prototype.C=function(){this.u=Date.now()},e.prototype.D=function(){this.setState({j:!0})},e.prototype.O=function(){this.setState({j:!1})},e.prototype.S=function(t){this.H=t},e.prototype.T=function(t){t.preventDefault(),this.H.focus(),this.A(t),this.W&&this.setState({j:!1})},e.prototype.A=function(t){var e=this.props;(0,e.onChange)(!e.checked,t,e.id)},e.prototype.render=function(){var t=this.props,e=t.checked,i=t.disabled,o=t.className,h=t.offColor,r=t.onColor,c=t.offHandleColor,l=t.onHandleColor,d=t.checkedIcon,u=t.uncheckedIcon,p=t.checkedHandleIcon,b=t.uncheckedHandleIcon,f=t.boxShadow,m=t.activeBoxShadow,j=t.height,v=t.width,k=t.borderRadius,y=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(i[n]=t[n]);return i}(t,["checked","disabled","className","offColor","onColor","offHandleColor","onHandleColor","checkedIcon","uncheckedIcon","checkedHandleIcon","uncheckedHandleIcon","boxShadow","activeBoxShadow","height","width","borderRadius","handleDiameter"]),g=this.state,x=g.h,w=g.N,O=g.j,S={position:"relative",display:"inline-block",textAlign:"left",opacity:i?.5:1,direction:"ltr",borderRadius:j/2,WebkitTransition:"opacity 0.25s",MozTransition:"opacity 0.25s",transition:"opacity 0.25s",touchAction:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",userSelect:"none"},M={height:j,width:v,margin:Math.max(0,(this.t-j)/2),position:"relative",background:a(x,this.i,this.o,h,r),borderRadius:"number"==typeof k?k:j/2,cursor:i?"default":"pointer",WebkitTransition:w?null:"background 0.25s",MozTransition:w?null:"background 0.25s",transition:w?null:"background 0.25s"},T={height:j,width:Math.min(1.5*j,v-(this.t+j)/2+1),position:"relative",opacity:(x-this.o)/(this.i-this.o),pointerEvents:"none",WebkitTransition:w?null:"opacity 0.25s",MozTransition:w?null:"opacity 0.25s",transition:w?null:"opacity 0.25s"},C={height:j,width:Math.min(1.5*j,v-(this.t+j)/2+1),position:"absolute",opacity:1-(x-this.o)/(this.i-this.o),right:0,top:0,pointerEvents:"none",WebkitTransition:w?null:"opacity 0.25s",MozTransition:w?null:"opacity 0.25s",transition:w?null:"opacity 0.25s"},D={height:this.t,width:this.t,background:a(x,this.i,this.o,c,l),display:"inline-block",cursor:i?"default":"pointer",borderRadius:"number"==typeof k?k-1:"50%",position:"absolute",transform:"translateX("+x+"px)",top:Math.max(0,(j-this.t)/2),outline:0,boxShadow:O?m:f,border:0,WebkitTransition:w?null:"background-color 0.25s, transform 0.25s, box-shadow 0.15s",MozTransition:w?null:"background-color 0.25s, transform 0.25s, box-shadow 0.15s",transition:w?null:"background-color 0.25s, transform 0.25s, box-shadow 0.15s"},E={height:this.t,width:this.t,opacity:Math.max(2*(1-(x-this.o)/(this.i-this.o)-.5),0),position:"absolute",left:0,top:0,pointerEvents:"none",WebkitTransition:w?null:"opacity 0.25s",MozTransition:w?null:"opacity 0.25s",transition:w?null:"opacity 0.25s"},I={height:this.t,width:this.t,opacity:Math.max(2*((x-this.o)/(this.i-this.o)-.5),0),position:"absolute",left:0,top:0,pointerEvents:"none",WebkitTransition:w?null:"opacity 0.25s",MozTransition:w?null:"opacity 0.25s",transition:w?null:"opacity 0.25s"};return n.createElement("div",{className:o,style:S},n.createElement("div",{className:"react-switch-bg",style:M,onClick:i?null:this.T,onMouseDown:function(t){return t.preventDefault()}},d&&n.createElement("div",{style:T},d),u&&n.createElement("div",{style:C},u)),n.createElement("div",{className:"react-switch-handle",style:D,onClick:function(t){return t.preventDefault()},onMouseDown:i?null:this.p,onTouchStart:i?null:this.k,onTouchMove:i?null:this.M,onTouchEnd:i?null:this.m,onTouchCancel:i?null:this.O},b&&n.createElement("div",{style:E},b),p&&n.createElement("div",{style:I},p)),n.createElement("input",s({},{type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:i,style:{border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1}},y,{ref:this.S,onFocus:this.D,onBlur:this.O,onKeyUp:this.C,onChange:this.$})))},e}(n.Component);c.defaultProps={disabled:!1,offColor:"#888",onColor:"#080",offHandleColor:"#fff",onHandleColor:"#fff",uncheckedIcon:o,checkedIcon:h,boxShadow:null,activeBoxShadow:"0 0 2px 3px #3bf",height:28,width:56},e.default=c}}]);
  //# sourceMappingURL=130.798c6e68.chunk.js.map