dappros/ethora

View on GitHub
client-web/build-prod/static/js/228.9205070d.chunk.js

Summary

Maintainability
A
0 mins
Test Coverage
"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[228],{59715:function(e,n,t){t.d(n,{A:function(){return d}});t(72791);var o=t(17205),r=t(60788),i=t(77248),a=t(8440),l=t(39571),s=t(40464),c=t(80184);function d(e){var n=e.open,t=e.onClose,d=e.onDeletePress,u=e.loading,f=e.title,p=e.description,h=e.deleteButtonTitle,x=e.cancelButtonTitle;return(0,c.jsxs)(r.Z,{open:n,onClose:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,c.jsx)(s.Z,{id:"alert-dialog-title",children:f}),(0,c.jsx)(a.Z,{children:(0,c.jsx)(l.Z,{id:"alert-dialog-description",children:p})}),(0,c.jsxs)(i.Z,{children:[(0,c.jsx)(o.Z,{disabled:u,onClick:t,children:x||"Cancel"}),(0,c.jsx)(o.Z,{disabled:u,onClick:d,autoFocus:!0,color:"error",children:h||"Delete"})]})]})}},61228:function(e,n,t){t.r(n),t.d(n,{default:function(){return O}});var o=t(72791),r=t(20803),i=t(74165),a=t(15861),l=t(70885),s=t(50228),c=t(4565),d=t(13811),u=t(64880),f=t(11210),p=t(8343),h=t(41286),x=t(59715),m=t(91803),Z=t(59911),v=t(17205),j=t(80184),g={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",boxShadow:24,p:4,justifyContent:"center",display:"flex",flexDirection:"column",borderRadius:"10px"};function b(e){var n=e.title,t=e.open,o=e.onClose,r=e.onChange,i=e.onSubmit;return(0,j.jsx)(m.Z,{open:t,onClose:o,"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:(0,j.jsxs)(s.Z,{sx:g,children:[(0,j.jsx)(c.Z,{id:"modal-modal-title",variant:"h6",component:"h2",children:n}),(0,j.jsx)(Z.Z,{onChange:function(e){return r(e.target.value)},margin:"normal",id:"outlined-basic",label:"Enter new info here",variant:"outlined"}),(0,j.jsx)(v.Z,{onClick:i,style:{justifyContent:"center",alignItems:"center",display:"flex"},variant:"contained",children:(0,j.jsx)(c.Z,{id:"modal-modal-description",children:"Submit"})})]})})}var w=t(96580),C=t(73978),y=t(75426),S=t(60340),D=t(68438),k=t(27247),R=t(50705),I=t(52775),M=t(47409);function z(e){var n,t=e.roomJID,r=e.onDeleteRoomClick,h=(0,f.K)((function(e){return e.userChatRooms})).find((function(e){return(null===e||void 0===e?void 0:e.jid)===t})),x=(0,f.K)((function(e){return e.updateUserChatRoom})),m=(0,f.K)((function(e){return e.roomRoles})),Z=(0,I.D)().showSnackbar,v=null===(n=m.find((function(e){return e.roomJID===(null===h||void 0===h?void 0:h.jid)})))||void 0===n?void 0:n.role,g=(0,o.useRef)(null),b=(0,o.useState)(!1),z=(0,l.Z)(b,2),L=z[0],N=z[1],P=(0,u.k6)(),T=h&&(h.group===D.hx.official||h.group===D.hx.favourite),A="moderator"===v||"owner"===v||"admin"===v,_=function(e){var n=Object.assign({},h);n.group=e,x(n)},K=function(){var e=(0,a.Z)((0,i.Z)().mark((function e(n){var o,r,a,l;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(o=new FormData).append("files",n),N("chatIcon"),e.prev=3,e.next=6,(0,M.cT)(o);case 6:r=e.sent,a=t.split("@")[0],p.Z.setRoomImage(a,r.data.results[0].location,h.room_background,"icon"),(l=Object.assign({},h)).room_thumbnail=r.data.results[0].location,x(l),Z("success","Success! The chat icon was set"),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(3),console.log(e.t0),Z("error","An error occurred while loading the image.  ( "+e.t0.message+" "+e.t0.response.data+" )");case 19:N(!1);case 20:case"end":return e.stop()}}),e,null,[[3,15]])})));return function(n){return e.apply(this,arguments)}}();return(0,j.jsx)("div",{style:{cursor:"pointer"},children:(0,j.jsxs)(s.Z,{sx:{width:200,height:200,margin:5,backgroundColor:"primary.dark",justifyContent:"center",alignItems:"center",display:"flex",borderRadius:"10px",position:"relative"},children:[(0,j.jsxs)(s.Z,{sx:{position:"absolute",top:0,right:0,display:"flex",flexDirection:"column",zIndex:99999},children:[(0,j.jsx)(d.Z,{sx:{color:"white"},onClick:function(){return _(T?"":D.hx.favourite)},children:T?(0,j.jsx)(S.Z,{}):(0,j.jsx)(y.Z,{})}),A&&(0,j.jsxs)(d.Z,{sx:{color:"white"},onClick:function(){var e;return null===(e=g.current)||void 0===e?void 0:e.click()},children:[(0,j.jsx)("input",{type:"file",name:"file",id:"file",onChange:function(e){return K(e.target.files[0])},ref:g,style:{display:"none"},accept:"image/*"}),"chatIcon"===L?(0,j.jsx)(w.Z,{style:{color:"white"},size:24}):(0,j.jsx)(R.Z,{})]}),A&&(0,j.jsx)(d.Z,{sx:{color:"red"},onClick:r,children:(0,j.jsx)(k.Z,{})})]}),(0,j.jsx)(d.Z,{disableRipple:!0,onClick:function(e){A&&P.push("/changebg/"+t)},children:null!==h&&void 0!==h&&h.room_thumbnail&&"none"!==(null===h||void 0===h?void 0:h.room_thumbnail)?(0,j.jsx)(C.Z,{sx:{width:200,height:200,borderRadius:"10px"},variant:"square",src:h.room_thumbnail}):(0,j.jsx)(c.Z,{color:"white",fontSize:"120px",children:null===h||void 0===h?void 0:h.name[0]})})]})})}function L(){var e,n=(0,u.UO)().roomJID,t=(0,o.useState)(""),m=(0,l.Z)(t,2),Z=m[0],v=m[1],g=(0,o.useState)(""),w=(0,l.Z)(g,2),C=w[0],y=w[1],S=(0,o.useState)(!1),D=(0,l.Z)(S,2),k=D[0],R=D[1],I=(0,o.useState)(!1),M=(0,l.Z)(I,2),L=M[0],N=M[1],P=(0,o.useState)(!1),T=(0,l.Z)(P,2),A=T[0],_=T[1],K=(0,f.K)((function(e){return e.userChatRooms})).find((function(e){return(null===e||void 0===e?void 0:e.jid)===n})),J=(0,f.K)((function(e){return e.roomRoles})),O=(0,u.k6)(),U=null===(e=J.find((function(e){return e.roomJID===(null===K||void 0===K?void 0:K.jid)})))||void 0===e?void 0:e.role,H="moderator"===U||"owner"===U||"admin"===U,E=function(){N(!1)},V=function(){var e=(0,a.Z)((0,i.Z)().mark((function e(){return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:p.Z.leaveTheRoom(n),p.Z.unsubscribe(n),E(),O.push("/chat/none");case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,j.jsxs)(r.Z,{style:{justifyContent:"center",alignItems:"center",display:"flex",flexDirection:"column"},children:[(0,j.jsx)(z,{roomJID:n,onDeleteRoomClick:function(){return N(!0)}}),(0,j.jsxs)(s.Z,{flexDirection:"row",display:"flex",children:[(0,j.jsx)(c.Z,{fontSize:"20px",fontWeight:"bold",children:null===K||void 0===K?void 0:K.name}),H&&(0,j.jsx)(d.Z,{onClick:function(){return _(!0)},style:{marginLeft:10},children:(0,j.jsx)(h.Z,{fontSize:"small"})})]}),(0,j.jsxs)(r.Z,{style:{flexDirection:"row",justifyContent:"center",alignItems:"center",display:"flex"},children:[(0,j.jsx)(c.Z,{fontSize:"20px",children:null!==K&&void 0!==K&&K.description?K.description:"No description"}),H&&(0,j.jsx)(d.Z,{onClick:function(){return R(!0)},style:{marginLeft:10},children:(0,j.jsx)(h.Z,{fontSize:"small"})})]}),(0,j.jsx)(b,{title:"Set New Chat Name",open:A,onClose:function(){return _(!1)},onChange:y,onSubmit:function(){_(!1),function(e){p.Z.changeRoomName(n,e)}(C)}}),(0,j.jsx)(b,{title:"Set New Chat Description",open:k,onClose:function(){return R(!1)},onChange:v,onSubmit:function(){R(!1),function(e){p.Z.changeRoomDescription(n,e)}(Z)}}),(0,j.jsx)(x.A,{open:L,title:"Delete",description:"Do you want to delete this room?",onDeletePress:V,onClose:E})]})}var N=t(45629),P=t(76132),T=t(16992),A=t(70324),_=t(52898),K=t(28741);function J(){var e,n=(0,u.UO)().roomJID,t=(0,f.K)((function(e){return e.userChatRooms})),r=(0,f.K)((function(e){return e.roomMemberInfo.filter((function(e){return"none"!==e.name}))})),i=(0,f.K)((function(e){return e.user})),a=t.find((function(e){return(null===e||void 0===e?void 0:e.jid)===n})),h=(0,o.useState)(!1),x=(0,l.Z)(h,2),m=x[0],Z=x[1],v=(0,o.useState)(),g=(0,l.Z)(v,2),b=(g[0],g[1]),w=(0,o.useState)(null),y=(0,l.Z)(w,2),S=y[0],D=y[1],k=(0,f.K)((function(e){return e.roomRoles})),R=(0,u.k6)(),I=null===(e=k.find((function(e){return e.roomJID===(null===a||void 0===a?void 0:a.jid)})))||void 0===e?void 0:e.role,M=function(e){e.stopPropagation(),D(null),Z(!1)};return(0,j.jsxs)(s.Z,{children:[(0,j.jsxs)(c.Z,{variant:"h5",children:["Members (",r.length,")"]}),(0,j.jsx)(N.Z,{sx:{width:"100%",bgcolor:"background.paper"},children:r.map((function(e){return(0,j.jsxs)(P.ZP,{dense:!0,onClick:function(){return function(e){e.jid.includes((0,K.I)(i.walletAddress))?R.push("/profile/"+i.walletAddress):R.push("/profile/"+(0,K.$)(e.jid.split("@")[0]))}(e)},style:{flexDirection:"row",alignItems:"center"},children:[(0,j.jsx)(s.Z,{alignItems:"center",justifyContent:"center",style:{background:"#003E9C",width:"40px",height:"40px",margin:5,display:"flex"},children:"none"!==e.profile?(0,j.jsx)(C.Z,{style:{width:"40px",height:"40px"},variant:"square",src:e.profile}):(0,j.jsx)(c.Z,{style:{color:"white"},children:e.name?e.name[0]:null})}),(0,j.jsx)(c.Z,{children:e.jid.includes((0,K.I)(i.walletAddress))?"You":e.name}),!e.jid.includes((0,K.I)(i.walletAddress))&&("moderator"===I||"owner"===I)&&(0,j.jsx)(d.Z,{"aria-label":"more",id:"long-button","aria-haspopup":"true",onClick:function(n){return function(e,n){e.stopPropagation(),b(n),D(e.currentTarget),Z(!0)}(n,e)},children:(0,j.jsx)(_.Z,{})}),"owner"===e.role&&(0,j.jsx)(s.Z,{style:{border:"1px solid",borderWidth:1,borderRadius:5,width:"70px",alignItems:"center",display:"flex",justifyContent:"center",marginLeft:10},children:(0,j.jsx)(c.Z,{children:e.role})}),"clear"!==e.ban_status?(0,j.jsx)(s.Z,{style:{border:"1px solid",borderWidth:1,borderRadius:5,width:"70px",alignItems:"center",display:"flex",justifyContent:"center",marginLeft:10},children:(0,j.jsx)(c.Z,{children:"banned"})}):null,(0,j.jsx)(T.Z,{id:"long-menu",MenuListProps:{"aria-labelledby":"long-button"},anchorEl:S,open:m,onClose:M,PaperProps:{style:{maxHeight:216,width:"20ch"}},children:(0,j.jsx)(A.Z,{onClick:function(n){return function(e,n){"clear"===e.ban_status?p.Z.banUserStanza(e.jid,a.jid):p.Z.unbanUserStanza(e.jid,a.jid),p.Z.getRoomMemberInfo(a.jid),M(n)}(e,n)},children:"clear"===(null===e||void 0===e?void 0:e.ban_status)?"Ban":"Unban"})})]},e.jid)}))})]})}function O(){var e=(0,u.UO)().roomJID;return(0,o.useEffect)((function(){p.Z.getRoomMemberInfo(e),p.Z.getRoomInfo(e)}),[]),(0,j.jsxs)(r.Z,{maxWidth:"xl",children:[(0,j.jsx)(L,{}),(0,j.jsx)(J,{})]})}},27247:function(e,n,t){var o=t(64836);n.Z=void 0;var r=o(t(45649)),i=t(80184),a=(0,r.default)((0,i.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");n.Z=a},41286:function(e,n,t){var o=t(64836);n.Z=void 0;var r=o(t(45649)),i=t(80184),a=(0,r.default)((0,i.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Edit");n.Z=a},50705:function(e,n,t){var o=t(64836);n.Z=void 0;var r=o(t(45649)),i=t(80184),a=(0,r.default)((0,i.jsx)("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"}),"InsertPhoto");n.Z=a},52898:function(e,n,t){var o=t(64836);n.Z=void 0;var r=o(t(45649)),i=t(80184),a=(0,r.default)((0,i.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}),"MoreVert");n.Z=a},75426:function(e,n,t){var o=t(64836);n.Z=void 0;var r=o(t(45649)),i=t(80184),a=(0,r.default)((0,i.jsx)("path",{d:"m12 8.89.94 3.11h2.82l-2.27 1.62.93 3.01L12 14.79l-2.42 1.84.93-3.01L8.24 12h2.82L12 8.89M12 2l-2.42 8H2l6.17 4.41L5.83 22 12 17.31 18.18 22l-2.35-7.59L22 10h-7.58L12 2z"}),"StarPurple500");n.Z=a},77248:function(e,n,t){t.d(n,{Z:function(){return m}});var o=t(63366),r=t(87462),i=t(72791),a=t(28182),l=t(94419),s=t(60277),c=t(85513),d=t(75878),u=t(21217);function f(e){return(0,u.Z)("MuiDialogActions",e)}(0,d.Z)("MuiDialogActions",["root","spacing"]);var p=t(80184),h=["className","disableSpacing"],x=(0,s.ZP)("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:function(e,n){var t=e.ownerState;return[n.root,!t.disableSpacing&&n.spacing]}})((function(e){var n=e.ownerState;return(0,r.Z)({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto"},!n.disableSpacing&&{"& > :not(:first-of-type)":{marginLeft:8}})})),m=i.forwardRef((function(e,n){var t=(0,c.Z)({props:e,name:"MuiDialogActions"}),i=t.className,s=t.disableSpacing,d=void 0!==s&&s,u=(0,o.Z)(t,h),m=(0,r.Z)({},t,{disableSpacing:d}),Z=function(e){var n=e.classes,t={root:["root",!e.disableSpacing&&"spacing"]};return(0,l.Z)(t,f,n)}(m);return(0,p.jsx)(x,(0,r.Z)({className:(0,a.Z)(Z.root,i),ownerState:m,ref:n},u))}))},8440:function(e,n,t){t.d(n,{Z:function(){return v}});var o=t(4942),r=t(63366),i=t(87462),a=t(72791),l=t(28182),s=t(94419),c=t(60277),d=t(85513),u=t(75878),f=t(21217);function p(e){return(0,f.Z)("MuiDialogContent",e)}(0,u.Z)("MuiDialogContent",["root","dividers"]);var h=t(5186),x=t(80184),m=["className","dividers"],Z=(0,c.ZP)("div",{name:"MuiDialogContent",slot:"Root",overridesResolver:function(e,n){var t=e.ownerState;return[n.root,t.dividers&&n.dividers]}})((function(e){var n=e.theme,t=e.ownerState;return(0,i.Z)({flex:"1 1 auto",WebkitOverflowScrolling:"touch",overflowY:"auto",padding:"20px 24px"},t.dividers?{padding:"16px 24px",borderTop:"1px solid ".concat((n.vars||n).palette.divider),borderBottom:"1px solid ".concat((n.vars||n).palette.divider)}:(0,o.Z)({},".".concat(h.Z.root," + &"),{paddingTop:0}))})),v=a.forwardRef((function(e,n){var t=(0,d.Z)({props:e,name:"MuiDialogContent"}),o=t.className,a=t.dividers,c=void 0!==a&&a,u=(0,r.Z)(t,m),f=(0,i.Z)({},t,{dividers:c}),h=function(e){var n=e.classes,t={root:["root",e.dividers&&"dividers"]};return(0,s.Z)(t,p,n)}(f);return(0,x.jsx)(Z,(0,i.Z)({className:(0,l.Z)(h.root,o),ownerState:f,ref:n},u))}))},39571:function(e,n,t){t.d(n,{Z:function(){return Z}});var o=t(63366),r=t(87462),i=t(72791),a=t(28182),l=t(94419),s=t(60277),c=t(85513),d=t(4565),u=t(75878),f=t(21217);function p(e){return(0,f.Z)("MuiDialogContentText",e)}(0,u.Z)("MuiDialogContentText",["root"]);var h=t(80184),x=["children","className"],m=(0,s.ZP)(d.Z,{shouldForwardProp:function(e){return(0,s.FO)(e)||"classes"===e},name:"MuiDialogContentText",slot:"Root",overridesResolver:function(e,n){return n.root}})({}),Z=i.forwardRef((function(e,n){var t=(0,c.Z)({props:e,name:"MuiDialogContentText"}),i=t.className,s=(0,o.Z)(t,x),d=function(e){var n=e.classes,t=(0,l.Z)({root:["root"]},p,n);return(0,r.Z)({},n,t)}(s);return(0,h.jsx)(m,(0,r.Z)({component:"p",variant:"body1",color:"text.secondary",ref:n,ownerState:s,className:(0,a.Z)(d.root,i)},t,{classes:d}))}))}}]);
//# sourceMappingURL=228.9205070d.chunk.js.map