dappros/ethora

View on GitHub
client-web/build/static/js/91.78370d64.chunk.js

Summary

Maintainability
A
0 mins
Test Coverage
"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[91],{5091:function(e,t,n){n.r(t),n.d(t,{default:function(){return R}});var s=n(1413),r=n(74165),a=n(15861),o=n(70885),i=n(92148),c=n(42093),l=n(38365),u=n(50228),d=n(17205),f=n(20803),p=n(70043),m=n(72791),x=n(87210),h=n.n(x),g=n(64880),k=new(n(58992)._k)({supportedChainIds:[1,3,4,5,42]}),v=n(47409),w=n(11210),Z=n(24177),N=n(42016),y=n(60788),j=n(40464),b=n(13811),C=n(29823),I=n(55705),S=n(59911),A=n(80184),T=function(e){var t={};return e.firstName||(t.firstName="Required"),e.lastName||(t.lastName="Required"),t};function O(e){var t=e.open,n=e.setOpen,s=(0,p.Ge)(),o=s.account,i=s.library,c=s.deactivate,l=(0,w.K)((function(e){return e.setUser})),f=(0,g.k6)(),m=(0,I.TA)({initialValues:{firstName:"",lastName:""},validate:T,onSubmit:function(){var e=(0,a.Z)((0,r.Z)().mark((function e(t){var n,s,a,u,d;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.getSigner(),e.prev=1,s="Register",e.next=5,n.signMessage(s);case 5:return a=e.sent,e.next=8,(0,v.pR)(o,a,s,t.firstName,t.lastName);case 8:u=e.sent,d=u.data.user,l({_id:d._id,description:d.description,firstName:d.firstName,lastName:d.lastName,xmppPassword:d.xmppPassword,walletAddress:d.defaultWallet.walletAddress,token:u.data.token,refreshToken:u.data.refreshToken,profileImage:d.profileImage,isProfileOpen:d.isProfileOpen,isAssetsOpen:d.isAssetsOpen,ACL:d.ACL}),c(),f.push("/profile/".concat(d.defaultWallet.walletAddress)),e.next=18;break;case 15:e.prev=15,e.t0=e.catch(1),console.log("signature error ",e.t0);case 18:case"end":return e.stop()}}),e,null,[[1,15]])})));return function(t){return e.apply(this,arguments)}}()});return(0,A.jsx)(y.Z,{onClose:function(){},maxWidth:!1,open:t,children:(0,A.jsxs)(u.Z,{style:{width:"350px"},children:[(0,A.jsxs)(j.Z,{style:{display:"flex",justifyContent:"space-between"},children:["Continue with Metamask",(0,A.jsx)(b.Z,{onClick:function(){return n(!1)},children:(0,A.jsx)(C.Z,{})})]}),(0,A.jsx)(u.Z,{sx:{width:"100%",typography:"body1",padding:1},children:(0,A.jsxs)("form",{onSubmit:m.handleSubmit,children:[(0,A.jsx)(S.Z,{margin:"dense",inputProps:{autoComplete:"off"},label:"First Name",name:"firstName",type:"text",fullWidth:!0,variant:"standard",onChange:m.handleChange,onBlur:m.handleBlur,error:m.touched.firstName&&Boolean(m.errors.firstName),helperText:m.touched.firstName&&m.errors.firstName?m.errors.firstName:""}),(0,A.jsx)(S.Z,{margin:"dense",label:"Last Name",name:"lastName",type:"text",fullWidth:!0,inputProps:{autoComplete:"off"},variant:"standard",onChange:m.handleChange,onBlur:m.handleBlur,error:m.touched.lastName&&Boolean(m.errors.lastName),helperText:m.touched.lastName&&m.errors.lastName?m.errors.lastName:""}),(0,A.jsx)(u.Z,{sx:{margin:2,display:"flex",justifyContent:"center"},children:(0,A.jsx)(d.Z,{type:"submit",variant:"contained",children:"Register"})})]})})]})})}var W=n(6933),P=n(20929),L=n(92827),_=n(45100),B=n(68438);function R(){var e=(0,w.K)((function(e){return e.setUser})),t=(0,w.K)((function(e){return e.user})),n=(0,Z.aM)(),x=(0,g.k6)(),y=(0,p.Ge)(),j=y.active,b=y.account,C=y.library,I=y.activate,S=(0,m.useState)(!1),T=(0,o.Z)(S,2),R=T[0],M=T[1],G=(0,m.useState)(!1),q=(0,o.Z)(G,2),z=q[0],E=q[1],F=(0,m.useState)(!1),K=(0,o.Z)(F,2),D=K[0],U=K[1],Y=(0,m.useState)(!1),H=(0,o.Z)(Y,2),J=H[0],V=H[1];(0,m.useEffect)((function(){L.MN.load("client:auth2",(function(){L.MN.client.init({clientId:"972933470054-9v5gnseqef8po7cvvrsovj51cte249ov.apps.googleusercontent.com",scope:""})}))})),(0,m.useEffect)((function(){t.firstName&&t.xmppPassword?x.push("/profile/".concat(t.walletAddress)):!t.firstName||t.xmppPassword||x.push("/owner")}),[t]);(0,m.useEffect)((function(){var e=n.get("type");if(e)switch(e){case"username":E(!0);break;case"email":M(!0)}}),[n]),(0,m.useEffect)((function(){console.log("active ",j),j&&(console.log(j,b),b&&!t.firstName&&v.v9(b).then(function(){var e=(0,a.Z)((0,r.Z)().mark((function e(t){var n,s,a,o,i;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("login user"),n=C.getSigner(),s="Login",e.next=5,n.signMessage(s);case 5:return a=e.sent,e.next=8,v.ph(b,a,s);case 8:o=e.sent,i=o.data.user,X(i,o.data),x.push("/profile/".concat(i.defaultWallet.walletAddress));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){console.log(e),e.response&&404===e.response.status?(console.log("registering user"),U(!0)):console.log("other errors")})))}),[j,b]);var Q=function(){var e=(0,a.Z)((0,r.Z)().mark((function e(t){var n,s,a,o,i,c;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="google",e.next=3,v.O6(t.profileObj.email);case 3:if(s=e.sent,V(!0),console.log(s.data.success),s.data.success){e.next=14;break}return e.next=9,v.g7(t.tokenId,t.accessToken,n);case 9:a=e.sent,o=a.data.user,X(o,a.data),e.next=21;break;case 14:return e.next=16,v.iY(t.tokenId,t.accessToken,"",n);case 16:return e.next=18,v.g7(t.tokenId,t.accessToken,n);case 18:i=e.sent,c=i.data.user,X(c,i.data);case 21:V(!1);case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),X=function(t,n){e({_id:t._id,firstName:t.firstName,lastName:t.lastName,description:t.description,xmppPassword:t.xmppPassword,walletAddress:t.defaultWallet.walletAddress,token:n.token,refreshToken:n.refreshToken,profileImage:t.profileImage,isProfileOpen:t.isProfileOpen,isAssetsOpen:t.isAssetsOpen,ACL:t.ACL,referrerId:t.referrerId||""})},$=function(){var e=(0,a.Z)((0,r.Z)().mark((function e(t){var n,s,a,o,i;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="facebook",V(!0),e.next=4,v.O6(t.email);case 4:if(e.sent.data.success){e.next=13;break}return e.next=8,v.g7("","",n,t.accessToken);case 8:s=e.sent,a=s.data.user,X(a,s.data),e.next=20;break;case 13:return e.next=15,v.iY("","",t.accessToken,n);case 15:return e.next=17,v.g7("","",n,t.accessToken);case 17:o=e.sent,i=o.data.user,X(i,o.data);case 20:V(!1);case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return J?(0,A.jsx)(_.A,{}):(0,A.jsxs)(f.Z,{maxWidth:"xl",style:{display:"flex",flexDirection:"column",height:"calc(100vh - 68px)",justifyContent:"center",alignItems:"center"},children:[(0,A.jsxs)(u.Z,{sx:{marginTop:5},style:{display:"flex",maxWidth:"300px",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[B.Az&&(0,A.jsx)(h(),{appId:"1172938123281314",autoLoad:!1,fields:"name,email,picture",onClick:function(){},callback:$,icon:(0,A.jsx)(c.Z,{style:{marginRight:10}}),buttonStyle:{display:"flex",justifyContent:"flex-start",alignItems:"center",fontSize:16,padding:5,borderRadius:4,width:"100%",margin:"3px 0",fontFamily:"Roboto,Helvetica,Arial,sans-serif",fontWeight:500,textTransform:"none",paddingLeft:20},textButton:"Sign In with facebook",containerStyle:{padding:0,width:"100%"}}),B.nS&&(0,A.jsx)(P.GoogleLogin,{clientId:"972933470054-9v5gnseqef8po7cvvrsovj51cte249ov.apps.googleusercontent.com",buttonText:"Sign In with Google",onSuccess:Q,onFailure:function(e){console.log("failed:",e)},cookiePolicy:"single_host_origin",render:function(e){return(0,A.jsx)(d.Z,(0,s.Z)((0,s.Z)({},e),{},{sx:{margin:1},fullWidth:!0,variant:"contained",startIcon:(0,A.jsx)(l.Z,{}),style:{backgroundColor:"white",color:"rgba(0,0,0,0.6)",textTransform:"none",fontSize:"16px"},children:"Sign In with Google"}))}}),B.Jx&&(0,A.jsx)(d.Z,{sx:{margin:1},fullWidth:!0,variant:"contained",onClick:function(){I(k)},startIcon:(0,A.jsx)(i.Z,{}),style:{backgroundColor:"#d9711a",textTransform:"none",fontSize:"16px"},children:"Sign In with Metamask"}),B.lB&&(0,A.jsx)(d.Z,{sx:{margin:1},fullWidth:!0,variant:"text",onClick:function(){return x.push("/regularSignIn")},children:"Login with credentials"})]}),(0,A.jsx)(O,{open:D,setOpen:U}),(0,A.jsx)(N.W,{open:R,setOpen:M}),(0,A.jsx)(W.t,{open:z,setOpen:E})]})}}}]);
//# sourceMappingURL=91.78370d64.chunk.js.map