????
Current Path : C:/inetpub/vhost/tracnghiem.gdtsolutions.vn/wwwroot/assets/ |
Current File : C:/inetpub/vhost/tracnghiem.gdtsolutions.vn/wwwroot/assets/index-1634a788.js |
import{p as ce,j as e,b as t,T as de,F as ue,I as q,bs as he,bt as me,bD as w,al as p,J as pe,ax as E,G as F,a4 as xe,bv as ge}from"./index-9bcd78a9.js";import{m as fe,b as Z,c as W,d as je,e as ye,D as be,f as Ce,a as Q,g as ve}from"./NumberFormat-694550a2.js";import{F as ee,a as K,L as _,I as Ne,b as Se,M as ke,d as Ae,e as Te,R as Ie,C as J,f as De}from"./reactstrap.modern-0a8c2eab.js";import{D as ne,b as te,a as Re,c as Ee}from"./DialogTitle-762ac824.js";import{S as se}from"./Slide-d13e3d86.js";import{A as Oe}from"./AppBar-a2b92a6e.js";import{T as we}from"./Toolbar-d5f2ec66.js";import{C as Fe}from"./CardContent-7571d5c8.js";import{S as Y}from"./Skeleton-16a64d4f.js";import{C as G}from"./Chip-76b2389c.js";import{D as Pe}from"./DataTable-63f87428.js";import{D as B}from"./DialogContentText-22d7ed41.js";import{S as Me}from"./Snackbar-43c044f4.js";import{A as qe}from"./Alert-60369fbc.js";import"./tiny-warning.esm-d265c1d1.js";import"./FormGroup-c4ebc22e.js";import"./popper-578b62a7.js";import"./warning-d8cd23a0.js";import"./unsupportedProp-e368368f.js";import"./Tooltip-4d2e5457.js";import"./Popper-151dcaf9.js";import"./TableRow-55190f90.js";import"./Checkbox-60209323.js";import"./SwitchBase-f2562236.js";import"./TablePagination-014b81e1.js";import"./KeyboardArrowRight-930a3b01.js";import"./MenuItem-3ea292e1.js";import"./listItemIconClasses-873dc6a3.js";import"./Close-1f3816f8.js";const z=({link:s,style:n,url:i,concat:d,alt:c,...o})=>{const[h,a]=t.useState(null);return t.useEffect(()=>{i&&a(i)},[i]),i?e.jsx("div",{style:{textAlign:"center"},children:e.jsx("img",{style:n,src:h||"/assets/img/avatar.png",alt:c,...o})}):s?e.jsx("div",{style:{textAlign:"center"},children:e.jsx("img",{style:n,src:s,alt:c,...o})}):e.jsx("div",{style:{textAlign:"center"},children:e.jsx("img",{style:n,src:`${d}`,alt:c,...o})})};z.propTypes={link:ce.string};z.defaultProps={style:{textAlign:"center"}};const ae=({url:s,...n})=>s?e.jsx(z,{url:s,...n}):e.jsx(z,{...n,concat:"/assets/img/avatar.png",alt:"avatar"});ae.defaultProps={style:{width:35,borderRadius:"50%",height:"auto"}};const ze=ae,$e=t.forwardRef((s,n)=>e.jsx(se,{direction:"up",ref:n,...s}));function Be(s){const{children:n,onClose:i,open:d,style:c,className:o}=s;return e.jsx(ne,{className:o,style:c,disableEnforceFocus:!0,fullScreen:!0,open:d,onClose:i,TransitionComponent:$e,children:n})}const He=fe(s=>({appBar:{position:"relative",backgroundColor:"#006fca"},toolbar:{minHeight:40},title:{marginLeft:s.spacing(2),flex:1}}));function Le(s){const n=He(),{renderCustom:i,renderButton:d,title:c,onClose:o}=s;return e.jsx(Oe,{style:{position:"relative"},children:e.jsxs(we,{className:n.toolbar,variant:"dense",children:[i,e.jsx(de,{variant:"h6",className:n.title,children:c}),d,e.jsx(ue,{color:"error",style:{width:"1.5rem",height:"1.5rem",backgroundColor:"azure"},className:"rounded-circle",onClick:o,children:e.jsx(q,{fontSize:"small",children:"close"})})]})})}function We(s){return e.jsx(te,{className:s.className,style:{backgroundColor:"#eee",paddingTop:20},children:s.children})}function Ke(s){const{renderCustom:n,renderButton:i,children:d,title:c,onClose:o,open:h,style:a,className:y}=s,j=he();return e.jsx(me,{theme:j,children:e.jsxs(Be,{open:h,onClose:o,style:a,className:y,children:[e.jsx(Le,{renderCustom:n,renderButton:i,title:c,onClose:o}),e.jsx(We,{className:"position-relative",children:d})]})})}const M=xe.memo(()=>e.jsxs("div",{style:{marginLeft:8,marginRight:8},children:[e.jsx(Y,{style:{width:"40%"}}),e.jsx(Y,{animation:"wave",style:{paddingTop:16,paddingBottom:16}})]}));function _e(s){const{account:n,onClose:i,open:d,onSuccess:c}=s,[o,h]=t.useState({accountDetailsDTO:{}}),[a,y]=t.useState(!1),[j,v]=t.useState(!1);t.useEffect(()=>{n&&(v(!0),w.getInfoByIdAccount(n.id).then(({...x})=>{h({...x})}).catch(()=>Z("Không thể lấy thông tin tài khoản !")).finally(()=>v(!1)))},[n]);const N=x=>{x.preventDefault();const{email:k,phoneNumber:T,userName:R,displayName:I}=o;if(["Admin","admin"].some(O=>O===R)){W("Tên đăng nhập không hợp lệ");return}n.id},A=t.useCallback(({target:{value:x,name:k}})=>{h(T=>({...T,[k]:x}))},[]);t.useEffect(()=>{d||a&&y(!1)},[d,a]);const{userName:m,displayName:r,email:u,phoneNumber:f,about:D}=o,C=t.forwardRef(function(k,T){return e.jsx(se,{direction:"up",ref:T,...k})});return e.jsx(Ke,{title:"Thông tin tài khoản",open:d,onClose:i,TransitionComponent:C,children:e.jsxs(p,{container:!0,spacing:1,children:[e.jsx(p,{xs:8,children:e.jsx(ee,{onChange:A,onSubmit:N,children:e.jsx(pe,{children:e.jsxs(Fe,{children:[e.jsx("legend",{style:{marginTop:8,marginLeft:8},children:"Thông tin tài khoản"}),j?e.jsxs(p,{container:!0,spacing:1,children:[e.jsx(p,{xs:6,children:e.jsx(M,{})}),e.jsx(p,{xs:6,children:e.jsx(M,{})})]}):e.jsxs(p,{container:!0,spacing:1,children:[e.jsx(p,{xs:6,children:e.jsx(E,{value:r||"",label:"Tên hiển thị",name:"displayName",disabled:!a})}),e.jsx(p,{xs:6,children:e.jsx(E,{disabled:!a,value:m||"",label:"Tên đăng nhập",name:"userName",...m&&a?{invalidFeedback:"Tên đăng nhập không hợp lệ",invalid:!1}:{}})})]}),e.jsx("legend",{style:{marginLeft:8,marginTop:16},children:"Thông tin người dùng"}),e.jsxs(p,{container:!0,children:[e.jsx(p,{xs:6,children:j?e.jsx(e.Fragment,{children:Array.from(new Array(5).keys()).map(x=>e.jsx(M,{},x))}):e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"Họ tên",name:"displayName",required:!0,value:r||"",disabled:!a}),e.jsx(E,{label:"email",name:"email",required:!0,value:u||"",disabled:!a}),e.jsx(E,{disabled:!a,label:"Số điện thoại",name:"phoneNumber",required:!0,value:f||""})]})}),e.jsxs(p,{xs:6,children:[j?e.jsx(e.Fragment,{children:Array.from(new Array(5).keys()).map(x=>e.jsx(M,{},x))}):e.jsx(e.Fragment,{children:e.jsx(E,{disabled:!a,label:"Thông tin bổ sung",type:"textarea",name:"About",value:D||""})}),e.jsx(F,{size:"small",color:"primary",...a?{type:"submit"}:{onClick:()=>y(!0)},children:a?"Xác nhận":"Chỉnh sửa"})]})]})]})})})}),e.jsx(p,{xs:4,children:e.jsxs("div",{className:"card card-profile card-secondary",children:[e.jsx("div",{className:"card-header",style:{backgroundImage:'url("/assets/img/blogpost.jpg")'},children:e.jsx("div",{className:"profile-picture",children:e.jsx("div",{className:"avatar avatar-xl",children:n.avatar&&e.jsx(ze,{id:n.avatar,style:{},className:"avatar-img rounded-circle"})})})}),e.jsx("div",{className:"card-body",children:e.jsxs("div",{className:"user-profile text-center",children:[e.jsx("div",{className:"name",children:n.DisplayName}),e.jsx("div",{className:"job",children:o.Email}),e.jsx("div",{className:"desc",children:n.authorities&&n.authorities.map(x=>x.name).join(", ")})]})})]})})]})})}const Ge="Phân quyền";function Ue({authorities:s,allAuthorities:n,accountUuid:i,...d}){const{onError:c,open:o,handleClose:h}=d;t.useEffect(()=>{if(s&&n){const m=n.filter(r=>s.findIndex(u=>r.id===u.id)===-1);v(m),y(s)}},[n,s]);const[a,y]=t.useState(null),[j,v]=t.useState(null),N=function(m){y(r=>{let u=[...r];const f=j.filter(D=>D.id!==m.id);return f.push(u[0]),v(f),u=[m],u})},A=t.useCallback(()=>{if(a){const m=a.map(u=>u.id),r={taiKhoan_ID:i,vaiTros_ID:m};w.addAuthorities(r).then(()=>{h()}).catch(()=>c(Ge))}else h()},[i,a,h,c]);return e.jsx(je,{title:"Cài đặt vai trò tài khoản",maxWidth:"xs",open:o,handleClose:h,renderFooter:e.jsx("div",{children:e.jsx(F,{startIcon:e.jsx(q,{children:"save"}),onClick:A,disabled:!1,children:"Lưu"})}),children:e.jsxs(p,{container:!0,children:[e.jsx(p,{xs:6,children:e.jsxs("div",{children:[e.jsx("h4",{children:"Các quyền đã được cấp"}),e.jsx("h5",{children:"Chọn một quyền bất kì để thu hồi"}),a&&a.map(({name:m,id:r})=>e.jsx(G,{label:m,clickable:!0,color:"primary",style:{margin:4}},r))]})}),e.jsx(p,{xs:6,children:e.jsxs("div",{children:[e.jsx("h4",{children:"Các quyền chưa được cấp"}),e.jsx("h5",{children:"Chọn một quyền bất kì để cấp phát"}),j&&j.map(({name:m,id:r})=>e.jsx(G,{onClick:()=>N({name:m,id:r}),label:m,clickable:!0,color:"default",style:{margin:4}},r))]})})]})})}const H=t.memo(function({label:n,name:i,invalid:d,invalidFeedback:c,...o}){return e.jsxs(K,{children:[e.jsx(_,{htmlFor:i,children:n}),e.jsx(Ne,{invalid:d,name:i,id:i,...n?{placeholder:`Nhập ${n.toLowerCase()}`}:{},...o}),d&&e.jsx(Se,{children:c})]})});function Ve({isOpen:s,toggle:n,onSuccess:i,onError:d,arrRoles:c,onWarning:o,arrOrganizations:h}){const[a,y]=t.useState({userName:""}),[j,v]=t.useState([]);t.useEffect(()=>{v(c)},[c]);const N=t.useCallback(({target:{value:r,name:u}})=>{y(f=>({...f,[u]:r}))},[]),A=function(r){r.preventDefault();const{userName:u,authorities:f,...D}=a;if(u.includes("Admin")||u.includes("admin")){W("Tên đăng nhập không hợp lệ");return}if(!f||f.length===0){W("Vui lòng chọn vai trò");return}w.addNewUsers({userName:u,accountDetails:D,authorities:f}).then(C=>{if(C.isSuccessed){const x={passWord:C.resultObj,userName:a.userName};i(x)}else o(C.Message)}).catch(()=>d("Tạo tài khoản"))},m=t.useCallback(r=>{const u=[];r&&r.forEach(f=>{u.push(f.value)}),y(f=>({...f,authorities:u}))},[]);return e.jsx(e.Fragment,{children:e.jsx(ke,{isOpen:s,toggle:n,size:"xl",children:e.jsxs(ee,{onChange:N,onSubmit:A,children:[e.jsx(Ae,{toggle:n,children:"Thêm tài khoản"}),e.jsxs(Te,{children:[e.jsx("legend",{style:{marginTop:8,marginLeft:8},children:"Thông tin tài khoản"}),e.jsxs(Ie,{children:[e.jsxs(J,{children:[e.jsx(H,{label:"Tên hiển thị",name:"displayName",required:!0}),e.jsxs(K,{children:[e.jsx(_,{htmlFor:"Roles",children:"Quyền"}),e.jsx(ye,{defaultValue:a&&a.authorities,options:j,column:{field:"value",label:"label",type:"string"},onChange:r=>m(r)})]})]}),e.jsxs(J,{children:[e.jsx(H,{label:"Tên đăng nhập",name:"userName",invalidFeedback:"Tên đăng nhập không hợp lệ",required:!0,invalid:a.userName.includes("Admin")||a.userName.includes("admin")}),e.jsx(H,{label:"email",name:"email",required:!0}),e.jsxs(K,{children:[e.jsx(_,{htmlFor:"Organizations",children:"Đơn vị"}),e.jsx(be,{url:"meet/allow/Organizations",column:{field:"id",label:"organName",type:"uuid"},value:a&&a.organizationId||null,onChange:r=>N({target:{value:r.value,name:"organizationId"}}),eleUrl:1})]})]})]})]}),e.jsxs(De,{children:[e.jsx(F,{startIcon:e.jsx(q,{children:"save"}),type:"submit",children:"Xác Nhận"}),e.jsx(F,{startIcon:e.jsx(q,{children:"close"}),onClick:n,children:"Đóng"})]})]})})})}function Xe(s){const{array:n,arrRoles:i}=s,[d,c]=t.useState([]);return t.useEffect(()=>{if(i&&i.length!==0){let o;o=i.filter(function(h){return n.filter(function(a){return a.roleId===h.id}).length}),c(o)}},[i,n]),e.jsx("div",{children:d.map((o,h)=>e.jsx(G,{label:o.name},h))})}const Qe=[{title:"ID",field:"id",type:"numeric",dataID:!0,editable:"never",hidden:!0},{title:"Tài khoản",field:"userName",type:"string",searchable:!0,cellStyle:{minWidth:50},defaultSort:"asc"},{title:"Tên hiển thị",field:"displayName",type:"string",searchable:!0,cellStyle:{minWidth:50},defaultSort:"asc"},{title:"Đã kích hoạt",field:"activated",type:"boolean",cellStyle:{minWidth:50}},{title:"Vai trò",field:"accountRoles.roleId",type:"string",dataRef:["id","userId"],render:({accountRoles:s},n,i)=>e.jsx(Xe,{array:s,arrRoles:i})}];function Je(s){return e.jsx(qe,{elevation:6,variant:"filled",...s})}const U=t.createRef(),L=()=>U.current&&U.current.onQueryChange();function In(){const[s,n]=t.useState(null),[i,d]=t.useState(null),[c,o]=t.useState(null),[h,a]=t.useState(!1),[y,j]=t.useState(!1),[v,N]=t.useState(!1),[A,m]=t.useState([]),[r,u]=t.useState(null),[f,D]=t.useState([]),[C,x]=t.useState(null),[k,T]=t.useState("");t.useEffect(()=>{ge.getAllRoles().then(l=>{const g=[];l.value.forEach(b=>{g.push({value:b.id,label:b.name,...b})}),u(g),m(l.value)})},[]);const[R,I]=t.useState({isOpen:!1,message:"",severity:"success"}),[O,$]=t.useState({isOpen:!1,renderContent:()=>null,title:""}),ie=function(l){I(g=>({...g,isOpen:!0,message:`${l} thành công`,severity:"success"})),L()},V=function(l){I(g=>({...g,isOpen:!0,message:`${l} thất bại, vui lòng thử lại`,severity:"error"}))},re=function(l){I(g=>({...g,isOpen:!0,message:`${l}`,severity:"warning"}))},X=t.useCallback(function(){$(l=>({...l,isOpen:!1}))},[$]),le=t.useCallback((l,g)=>{if(l){const b=[];l.forEach(S=>{const{name:P}=g.find(oe=>oe.id===S.roleId);b.push({id:S.roleId,name:P})}),o(b)}},[]);return t.useEffect(()=>{const l=[];C&&l.push(`accountRoles/any(a:a/roleId eq ${C})`),T(l.join(" and "))},[C]),t.useEffect(()=>{L()},[k]),r&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{dataIni:r,title:e.jsxs(p,{container:!0,children:[e.jsx(p,{xs:6,children:"Danh sách tài khoản"}),e.jsx(p,{xs:6,children:e.jsx(Ce,{placeholder:"Chọn vai trò...",value:C,onChange:l=>x(l?l.value:null),options:r,isClearable:!0})})]}),tableRef:U,url:"/admin/auth/Accounts",where:k,columns:Qe,selectType:"withColumns",onRowClick:(l,g)=>{n(g),a(!0)},onActions:[l=>({icon:"redo",color:"rgb(230, 109, 204)",typeFont:"fontawesome",tooltip:"Reset mật khẩu",onClick:(g,b)=>{w.resetPassword(b.userName).then(S=>{S.isSuccessed&&Q("Mật khẩu mới",S.resultObj)})}}),l=>({icon:"user-tag",color:"rgb(146, 148, 222)",typeFont:"fontawesome",tooltip:"Cài đặt vai trò",onClick:async(g,b)=>{le(b.accountRoles,r),j(!0),d(b.id)}}),l=>({icon:"key",color:"rgb(146, 148, 222)",typeFont:"fontawesome",tooltip:"Đổi mật khẩu",onClick:async(g,b)=>{ve({mes:"Đổi mật khẩu",titles:"",typeInput:"password",placeholder:"Nhập mật khẩu"}).then(S=>{S&&S.isConfirmed&&w.changePassword({userName:b.userName,password:S.value}).then(({resultObj:P})=>{Q("Đổi mật khẩu thành công")}).catch(P=>Z(P.message))})}})]}),s&&e.jsx(_e,{account:s,open:h,onClose:()=>a(!h)}),c&&e.jsx(Ue,{onSuccess:ie,onError:V,accountUuid:i,allAuthorities:A,authorities:c,open:y,handleClose:()=>{j(!y),o(null)}}),e.jsx(Ve,{onError:V,onWarning:re,arrRoles:r,arrOrganizations:f,onSuccess:({passWord:l,userName:g})=>{$({isOpen:!0,renderContent:()=>(L(),e.jsxs(e.Fragment,{children:[e.jsx(B,{id:"alert-dialog-slide-description",children:"Thông tin đăng nhập"}),e.jsxs(B,{id:"alert-dialog-slide-description",children:["Tài khoản : ",g]}),e.jsxs(B,{id:"alert-dialog-slide-description",children:["Mật khẩu: ",l]})]})),title:"Đăng kí tài khoản thành công"}),N(!1)},isOpen:v,toggle:()=>N(!1)}),e.jsx(Me,{open:R.isOpen,autoHideDuration:6e3,onClose:()=>I(l=>({...l,isOpen:!1})),children:e.jsx(Je,{onClose:()=>I(l=>({...l,isOpen:!1})),severity:R.severity,children:R.message})}),e.jsx("div",{children:e.jsxs(ne,{open:O.isOpen,keepMounted:!0,onClose:X,"aria-labelledby":"alert-dialog-slide-title","aria-describedby":"alert-dialog-slide-description",children:[e.jsx(Re,{id:"alert-dialog-slide-title",children:O.title}),e.jsx(te,{children:O.renderContent()}),e.jsx(Ee,{children:e.jsx(F,{onClick:X,color:"primary",children:"Xác nhận"})})]})})]})}export{In as default};