"use strict";(self.webpackChunk_cromwell_admin_panel=self.webpackChunk_cromwell_admin_panel||[]).push([[33],{16366:(e,a,t)=>{t.d(a,{Z:()=>r});var l=t(6620),n=t(52322);const r=(0,l.Z)((0,n.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"}),"Visibility")},76901:(e,a,t)=>{t.d(a,{Z:()=>r});var l=t(6620),n=t(52322);const r=(0,l.Z)((0,n.jsx)("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"}),"VisibilityOff")},46552:(e,a,t)=>{t.d(a,{Z:()=>r});var l=t(82609),n=t.n(l)()((function(e){return e[1]}));n.push([e.id,'.text_e_8gN{font-family:"Roboto","sans-serif"}.center_PhhFM{display:flex;align-items:center;justify-content:center}.paper_QE060{box-shadow:0 2px 3px 0 rgba(0,0,0,.05),0 0 11px 5px rgba(0,0,0,.05);background-color:#fff;border-radius:5px}.page_KQ4Xl{display:flex;flex-direction:column;height:100%}.pageHeader_f5D5K{display:inline-block}.pageContent_PrqgN{display:inline-block;height:100%;overflow:auto}.pageTitle_S9azl{display:flex;align-items:center;font-weight:500}.pageTitle_S9azl::before{content:"";width:5px;height:5px;background-color:#333;margin-right:8px;display:block;border-radius:100%}.modeDark .pageTitle_S9azl::before{background-color:#eee}.UserPage_Fs5Wj{position:relative;max-width:900px;margin:0 auto;padding:20px;width:100%}.container_voDmd,.header_DZa3b{max-width:900px;margin:0 auto}.notFoundPage_ttdC4{display:flex;justify-content:center;align-items:center;height:100%}.notFoundText__LNhe{font-size:25px;font-weight:500}.header_DZa3b{box-shadow:0 2px 3px 0 rgba(0,0,0,.05),0 0 11px 5px rgba(0,0,0,.05);background-color:#fff;border-radius:5px;padding:5px 10px 5px 0;margin-bottom:15px;width:100%;display:flex;justify-content:space-between;align-items:center}.headerLeft_u8cIk{display:flex;align-items:center}.fields_mShJX{box-shadow:0 2px 3px 0 rgba(0,0,0,.05),0 0 11px 5px rgba(0,0,0,.05);background-color:#fff;border-radius:5px;padding:20px;display:flex;flex-direction:column}.imageField__KFZq{padding-bottom:4px}.image_zcFpz{border-radius:100%}.modeDark .header_DZa3b,.modeDark .fields_mShJX{background-color:#333}.modeDark .header_DZa3b *,.modeDark .fields_mShJX *{color:#eee}',""]),n.locals={text:"text_e_8gN",center:"center_PhhFM",paper:"paper_QE060",page:"page_KQ4Xl",pageHeader:"pageHeader_f5D5K",pageContent:"pageContent_PrqgN",pageTitle:"pageTitle_S9azl",UserPage:"UserPage_Fs5Wj",container:"container_voDmd",header:"header_DZa3b",notFoundPage:"notFoundPage_ttdC4",notFoundText:"notFoundText__LNhe",headerLeft:"headerLeft_u8cIk",fields:"fields_mShJX",imageField:"imageField__KFZq",image:"image_zcFpz"};const r=n},26245:(e,a,t)=>{t.d(a,{I:()=>l});const l=["administrator","author","customer","guest"]},50033:(e,a,t)=>{t.r(a),t.d(a,{default:()=>W});var l=t(65040),n=t(63756),r=t(49352),i=t(20355),s=t(16366),o=t(76901),d=t(87037),c=t(38677),m=t(63735),u=t(53242),p=t(30680),g=t(2784),f=t(63884),h=t(68109),v=t(37209),x=t(86661),b=t(7736),_=t(26245),E=t(45795),y=t(14812),Z=t(84073),w=t(46062),N=t.n(w),P=t(44036),k=t.n(P),F=t(96793),C=t.n(F),D=t(9978),z=t.n(D),S=t(11173),U=t.n(S),I=t(42464),T=t.n(I),A=t(46552),M={attributes:{"data-meta":"crw-admin-style"}};M.styleTagTransform=T(),M.setAttributes=z(),M.insert=C().bind(null,"head"),M.domAPI=k(),M.insertStyleElement=U(),N()(A.Z,M);const j=A.Z&&A.Z.locals?A.Z.locals:void 0;function W(){var e,a;const{id:t}=(0,f.UO)(),w=(0,r.getGraphQLClient)(),[N,P]=(0,g.useState)(!1),[k,F]=(0,g.useState)(""),C=(0,f.k6)(),[D,z]=(0,g.useState)(null),[S,U]=(0,g.useState)(!1),I="new"===t,[T,A]=(0,g.useState)(!1),M=async e=>{let a;try{a=await(null==w?void 0:w.getUserById(e,l.gql`
                fragment AdminPanelUserFragment on User {
                    id
                    slug
                    createDate
                    updateDate
                    isEnabled
                    pageTitle
                    pageDescription
                    meta {
                        keywords
                    }
                    fullName
                    email
                    avatar
                    bio
                    phone
                    address
                    role
                    customMeta (keys: ${JSON.stringify((0,E.He)(n.EDBEntity.User))})
                }`,"AdminPanelUserFragment"))}catch(e){console.error(e)}return a};(0,g.useEffect)((()=>{(async()=>{if(t&&!I){const e=await M(parseInt(t));(null==e?void 0:e.id)?z(e):P(!0)}else I&&z({})})()}),[]);const W=(e,a)=>{D&&z((t=>{const l=Object.assign({},t);return l[e]=a,l}))},L=e=>e&&""!==e;return N?g.createElement("div",{className:j.UserPage},g.createElement("div",{className:j.notFoundPage},g.createElement("p",{className:j.notFoundText},"User not found"))):g.createElement("div",{className:j.UserPage},g.createElement("div",{className:j.header},g.createElement("div",{className:j.headerLeft},g.createElement(d.Z,{onClick:()=>window.history.back()},g.createElement(i.Z,{style:{fontSize:"18px"}})),g.createElement("p",{className:Z.Z.pageTitle},"account")),g.createElement("div",{className:j.headerActions},g.createElement(c.Z,{variant:"contained",color:"primary",className:j.saveBtn,size:"small",onClick:async()=>{A(!0);const e=await(async()=>({slug:D.slug,pageTitle:D.pageTitle,pageDescription:D.pageDescription,fullName:D.fullName,email:D.email,avatar:D.avatar,bio:D.bio,phone:D.phone,address:D.address,role:D.role,customMeta:Object.assign({},D.customMeta,await(0,E.Q7)(n.EDBEntity.User))}))();if(L(e.email)&&L(e.fullName)&&L(e.role)){if(I){if(!L(k))return;try{const a={...e,password:k},t=await(null==w?void 0:w.createUser(a));x.A.success("Created user"),C.replace(`${b.Uu.baseRoute}/${t.id}`),z(t)}catch(e){x.A.error("Failed to create user"),(0,y.z)(e),console.error(e)}}else if(null==D?void 0:D.id)try{await(null==w?void 0:w.updateUser(D.id,e));const a=await M(parseInt(t));z(a),x.A.success("Saved!");const l=(0,n.getStoreItem)("userInfo");(null==l?void 0:l.id)&&l.id===a.id&&(0,n.setStoreItem)("userInfo",D)}catch(e){x.A.error("Failed to save"),(0,y.z)(e),console.error(e)}A(!1)}}},"Save"))),g.createElement("div",{className:j.fields},g.createElement(m.ZP,{container:!0,spacing:3},g.createElement(m.ZP,{item:!0,xs:12,sm:6,style:{display:"flex",alignItems:"flex-end"}},g.createElement(u.Z,{label:"Name",value:(null==D?void 0:D.fullName)||"",fullWidth:!0,variant:"standard",className:j.field,onChange:e=>{W("fullName",e.target.value)},error:T&&!L(null==D?void 0:D.fullName)})),g.createElement(m.ZP,{item:!0,xs:12,sm:6},g.createElement(h.u,{label:"Avatar",onChange:e=>{W("avatar",e)},value:null!==(e=null==D?void 0:D.avatar)&&void 0!==e?e:null,className:j.imageField,classes:{image:j.image},backgroundSize:"cover",width:"50px",height:"50px",showRemove:!0})),g.createElement(m.ZP,{item:!0,xs:12,sm:6},g.createElement(u.Z,{label:"E-mail",value:(null==D?void 0:D.email)||"",fullWidth:!0,variant:"standard",className:j.field,onChange:e=>{W("email",e.target.value)},error:T&&!L(null==D?void 0:D.email)})),I&&g.createElement(m.ZP,{item:!0,xs:12,sm:6},g.createElement(u.Z,{label:"Password",value:k||"",type:S?"text":"password",fullWidth:!0,variant:"standard",className:j.field,onChange:e=>{F(e.target.value)},error:T&&!L(k),InputProps:{endAdornment:g.createElement(p.Z,{position:"end"},g.createElement(d.Z,{"aria-label":"toggle password visibility",onClick:()=>{U(!S)},edge:"end"},S?g.createElement(s.Z,null):g.createElement(o.Z,null)))}})),g.createElement(m.ZP,{item:!0,xs:12,sm:6,display:"flex",alignItems:"flex-end"},g.createElement(v.P,{fullWidth:!0,variant:"standard",label:"Role",value:null!==(a=null==D?void 0:D.role)&&void 0!==a?a:"",onChange:e=>{W("role",e.target.value)},error:T&&!L(null==D?void 0:D.role),options:_.I.map((e=>({label:e,value:e})))})),g.createElement(m.ZP,{item:!0,xs:12,sm:6},g.createElement(u.Z,{label:"Bio",value:(null==D?void 0:D.bio)||"",fullWidth:!0,variant:"standard",multiline:!0,className:j.field,onChange:e=>{W("bio",e.target.value)}})),g.createElement(m.ZP,{item:!0,xs:12,sm:6},g.createElement(u.Z,{label:"Address",value:(null==D?void 0:D.address)||"",fullWidth:!0,variant:"standard",className:j.field,onChange:e=>{W("address",e.target.value)}})),g.createElement(m.ZP,{item:!0,xs:12,sm:6},g.createElement(u.Z,{label:"Phone",value:(null==D?void 0:D.phone)||"",fullWidth:!0,variant:"standard",className:j.field,onChange:e=>{W("phone",e.target.value)}})),g.createElement(m.ZP,{item:!0,xs:12,sm:12},D&&g.createElement(E._i,{entityType:n.EDBEntity.User,entityData:D,refetchMeta:async()=>{if(!t)return;const e=await M(parseInt(t));return null==e?void 0:e.customMeta}})))))}}}]);