(self["webpackJsonp@lyrio/ui"]=self["webpackJsonp@lyrio/ui"]||[]).push([[168],{1671:function(e,r,a){"use strict";a.r(r),a.d(r,"fetchData",(function(){return k})),a.d(r,"View",(function(){return y}));var t,n=a(10),s=a.n(n),c=a(179),i=a(19),o=a(15),u=a(1),l=a(0),p=a(1803),b=a(1807),d=a(618),g=a(55),j=a(738),f=a.n(j),m=a(181),v=a(9),O=a(182),h=a(22),w=a(183),x=a(37);function k(e){return M.apply(this,arguments)}function M(){return(M=Object(o.a)(s.a.mark((function e(r){var a,t,n;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m.c.user.getUserMeta({username:r,getPrivileges:!0});case 2:if(a=e.sent,t=a.requestError,n=a.response,!t){e.next=9;break}throw new w.a(t,{showRefresh:!0,showBack:!0});case 9:if(!n.error){e.next=11;break}throw new w.a(Object(x.c)("user_edit.errors.".concat(n.error)));case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(e){e.EditHomepage="EditHomepage",e.ManageUser="ManageUser",e.ManageUserGroup="ManageUserGroup",e.ManageProblem="ManageProblem",e.ManageContest="ManageContest",e.ManageDiscussion="ManageDiscussion",e.SkipRecaptcha="SkipRecaptcha"}(t||(t={}));var y=Object(g.a)((function(e){var r=Object(h.i)("user_edit.privilege");Object(l.useEffect)((function(){v.a.enterNewPage("".concat(r(".title")," - ").concat(e.meta.username),null,!1)}),[v.a.locale,e.meta]);var a=Object(h.d)(),n=Object(i.a)(a,2)[1],g=Object(h.b)(Object(o.a)(s.a.mark((function a(){var t,i,o;return s.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,m.c.user.setUserPrivileges({userId:e.meta.id,privileges:Object(c.a)(y)});case 2:t=a.sent,i=t.requestError,o=t.response,i?O.a.error(i(r)):o.error?O.a.error(r("user_edit.errors.".concat(o.error))):(n(!1),O.a.success(r(".success")));case 6:case"end":return a.stop()}}),a)})))),j=Object(i.a)(g,2),w=j[0],x=j[1],k=Object(l.useState)(new Set(e.privileges)),M=Object(i.a)(k,2),y=M[0],U=M[1];var N=v.a.currentUser.isAdmin;return Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)(p.a,{className:f.a.sectionHeader,size:"large",content:r(".header")}),Object.values(t).map((function(e){return Object(u.jsxs)("div",{className:f.a.privilegeRow,children:[Object(u.jsx)(b.a,{toggle:!0,readOnly:!N,label:r(".privileges.".concat(e,".name")),checked:y.has(e),onChange:function(r,a){var t=a.checked;return function(e,r){var a=new Set(y);r?a.add(e):a.delete(e),U(a),n(!0)}(e,t)}}),Object(u.jsx)("div",{className:f.a.notes,children:r(".privileges.".concat(e,".notes"))})]},e)})),Object(u.jsx)("div",{className:f.a.notes+" "+f.a.notesAdminOnly,children:r(".admin_only")}),Object(u.jsx)(d.a,{className:f.a.submit,loading:w,disabled:!N,primary:!0,content:r(".submit"),onClick:x})]})}))}}]);
//# sourceMappingURL=168.cb4a431e.chunk.js.map