????

Your IP : 216.73.216.130


Current Path : C:/inetpub/vhost/donthu.nextform.vn/wwwroot/assets/
Upload File :
Current File : C:/inetpub/vhost/donthu.nextform.vn/wwwroot/assets/index-BdKdMHAc.js

var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});import{b5 as PropTypes,Z as React,r as reactExports,k as jsxRuntimeExports,ar as Typography,x as IconButton,I as Icon,bl as createTheme,bm as ThemeProvider,bw as Accounts,bi as CHECK_ERROR,am as Grid,C as Card,aB as TextField,y as Button,bj as CHECK_WARNING,B as Box,P as Paper,aH as CircularProgress,bp as Roles,bh as CHECK_SUCCESS,bx as CHECK_CONFIRM_INPUT}from"./index-y1X-EiI1.js";import{t as tagPropType,m as mapToCssModules}from"./utils-B_XeHYak.js";import{D as Dialog,b as DialogContent,c as DialogActions,a as DialogTitle}from"./DialogTitle-B28XGy8_.js";import{S as Slide}from"./Slide--5eXGPG6.js";import{A as AppBar}from"./AppBar-BrohM22l.js";import{T as Toolbar}from"./Toolbar-BZCdaOvb.js";import{m as makeStyles,b as CardContent,d as CustomizedDialogs,u as useAsync,F as Form$1,C as CardHeader,a as FormControl,D as DataTable,g as SelectCustom}from"./DataTable-BEDH0i35.js";import{S as Skeleton}from"./Skeleton-BoenLgti.js";import{C as Chip}from"./Chip-4iuxTgqW.js";import{D as DialogContentText}from"./DialogContentText-vv6CMCLq.js";import{S as Snackbar}from"./Snackbar-Xm96By5D.js";import{A as Alert}from"./Alert-AfWalC00.js";import"./Tooltip-C0pwvyhl.js";import"./Popper-BN0GgV3z.js";import"./TableRow-BfZy-RM-.js";import"./FormGroup-CEJG6asl.js";import"./ListItemText-BvrfP19N.js";import"./Autocomplete-CpStdzj7.js";import"./Close-DnCuke95.js";import"./usePreviousProps-eNEUPQQG.js";import"./warning-BmqNoLzl.js";import"./TablePagination-Dnie0nHQ.js";import"./LoadingButton-DgqpHLzy.js";import"./Badge-BUU8rl3f.js";import"./Collapse-YEAu7S3-.js";import"./Switch-BlzK9Osj.js";import"./SwitchBase-HB81Uehs.js";import"./Checkbox-B8nePMFP.js";import"./colorManipulator-DvIuWqAp.js";function _typeof(obj){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(obj2){return typeof obj2}:function(obj2){return obj2&&typeof Symbol=="function"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype?"symbol":typeof obj2},_typeof(obj)}__name(_typeof,"_typeof");var _excluded=["className","cssModule","tag","innerRef"];function _extends(){return _extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_extends.apply(this,arguments)}__name(_extends,"_extends");function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded),key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],!(excluded.indexOf(key)>=0)&&Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}__name(_objectWithoutProperties,"_objectWithoutProperties");function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={},sourceKeys=Object.keys(source),key,i;for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],!(excluded.indexOf(key)>=0)&&(target[key]=source[key]);return target}__name(_objectWithoutPropertiesLoose,"_objectWithoutPropertiesLoose");function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}__name(_classCallCheck,"_classCallCheck");function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}__name(_defineProperties,"_defineProperties");function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}__name(_createClass,"_createClass");function _inherits(subClass,superClass){if(typeof superClass!="function"&&superClass!==null)throw new TypeError("Super expression must either be null or a function");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),Object.defineProperty(subClass,"prototype",{writable:!1}),superClass&&_setPrototypeOf(subClass,superClass)}__name(_inherits,"_inherits");function _setPrototypeOf(o,p){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():__name(function(o2,p2){return o2.__proto__=p2,o2},"_setPrototypeOf"),_setPrototypeOf(o,p)}__name(_setPrototypeOf,"_setPrototypeOf");function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return __name(function(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget)}else result=Super.apply(this,arguments);return _possibleConstructorReturn(this,result)},"_createSuperInternal")}__name(_createSuper,"_createSuper");function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call=="function"))return call;if(call!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(self)}__name(_possibleConstructorReturn,"_possibleConstructorReturn");function _assertThisInitialized(self){if(self===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return self}__name(_assertThisInitialized,"_assertThisInitialized");function _isNativeReflectConstruct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}__name(_isNativeReflectConstruct,"_isNativeReflectConstruct");function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():__name(function(o2){return o2.__proto__||Object.getPrototypeOf(o2)},"_getPrototypeOf"),_getPrototypeOf(o)}__name(_getPrototypeOf,"_getPrototypeOf");var propTypes={children:PropTypes.node,tag:tagPropType,innerRef:PropTypes.oneOfType([PropTypes.object,PropTypes.func,PropTypes.string]),className:PropTypes.string,cssModule:PropTypes.object},Form=function(_Component){_inherits(Form2,_Component);var _super=_createSuper(Form2);function Form2(props){var _this;return _classCallCheck(this,Form2),_this=_super.call(this,props),_this.getRef=_this.getRef.bind(_assertThisInitialized(_this)),_this.submit=_this.submit.bind(_assertThisInitialized(_this)),_this}return __name(Form2,"Form"),_createClass(Form2,[{key:"getRef",value:__name(function(ref){this.props.innerRef&&this.props.innerRef(ref),this.ref=ref},"getRef")},{key:"submit",value:__name(function(){this.ref&&this.ref.submit()},"submit")},{key:"render",value:__name(function(){var _this$props=this.props,className=_this$props.className,cssModule=_this$props.cssModule,_this$props$tag=_this$props.tag,Tag=_this$props$tag===void 0?"form":_this$props$tag,innerRef=_this$props.innerRef,attributes=_objectWithoutProperties(_this$props,_excluded),classes=mapToCssModules(className,cssModule);return React.createElement(Tag,_extends({},attributes,{ref:innerRef,className:classes}))},"render")}]),Form2}(reactExports.Component);Form.propTypes=propTypes;const ViewImage=__name(({link,style,url,concat,alt,...attribute})=>{const[avatar,setAvatar]=reactExports.useState(null);return reactExports.useEffect(()=>{url&&setAvatar(url)},[url]),url?jsxRuntimeExports.jsx("div",{style:{textAlign:"center"},children:jsxRuntimeExports.jsx("img",{style,src:avatar||"/assets/img/avatar.png",alt,...attribute})}):link?jsxRuntimeExports.jsx("div",{style:{textAlign:"center"},children:jsxRuntimeExports.jsx("img",{style,src:link,alt,...attribute})}):jsxRuntimeExports.jsx("div",{style:{textAlign:"center"},children:jsxRuntimeExports.jsx("img",{style,src:`${concat}`,alt,...attribute})})},"ViewImage");ViewImage.propTypes={link:PropTypes.string};ViewImage.defaultProps={style:{textAlign:"center"}};const Avatar=__name(({url,...attribute})=>url?jsxRuntimeExports.jsx(ViewImage,{url,...attribute}):jsxRuntimeExports.jsx(ViewImage,{...attribute,concat:"/assets/img/avatar.png",alt:"avatar"}),"Avatar");Avatar.defaultProps={style:{width:35,borderRadius:"50%",height:"auto"}};const Avatar$1=Avatar,Transition=reactExports.forwardRef((props,ref)=>jsxRuntimeExports.jsx(Slide,{direction:"up",ref,...props}));function FullScreenDialog$1(props){const{children,onClose,open,style,className}=props;return jsxRuntimeExports.jsx(Dialog,{className,style,disableEnforceFocus:!0,fullScreen:!0,open,onClose,TransitionComponent:Transition,children})}__name(FullScreenDialog$1,"FullScreenDialog$1");const useStyles=makeStyles(theme=>({appBar:{position:"relative",backgroundColor:"#006fca"},toolbar:{minHeight:40},title:{marginLeft:theme.spacing(2),flex:1}}));function HeaderDialog$1(props){const classes=useStyles(),{renderCustom,renderButton,title,onClose}=props;return jsxRuntimeExports.jsx(AppBar,{style:{position:"relative"},children:jsxRuntimeExports.jsxs(Toolbar,{className:classes.toolbar,variant:"dense",children:[renderCustom,jsxRuntimeExports.jsx(Typography,{variant:"h6",className:classes.title,children:title}),renderButton,jsxRuntimeExports.jsx(IconButton,{color:"error",style:{width:"1.5rem",height:"1.5rem",backgroundColor:"azure"},className:"rounded-circle",onClick:onClose,children:jsxRuntimeExports.jsx(Icon,{fontSize:"small",children:"close"})})]})})}__name(HeaderDialog$1,"HeaderDialog$1");function HeaderDialog(props){return jsxRuntimeExports.jsx(DialogContent,{className:props.className,style:{backgroundColor:"#eee",paddingTop:20},children:props.children})}__name(HeaderDialog,"HeaderDialog");function FullScreenDialog(props){const{renderCustom,renderButton,children,title,onClose,open,style,className}=props,theme=createTheme();return jsxRuntimeExports.jsx(ThemeProvider,{theme,children:jsxRuntimeExports.jsxs(FullScreenDialog$1,{open,onClose,style,className,children:[jsxRuntimeExports.jsx(HeaderDialog$1,{renderCustom,renderButton,title,onClose}),jsxRuntimeExports.jsx(HeaderDialog,{className:"position-relative",children})]})})}__name(FullScreenDialog,"FullScreenDialog");const MSkeleton=React.memo(()=>jsxRuntimeExports.jsxs("div",{style:{marginLeft:8,marginRight:8},children:[jsxRuntimeExports.jsx(Skeleton,{style:{width:"40%"}}),jsxRuntimeExports.jsx(Skeleton,{animation:"wave",style:{paddingTop:16,paddingBottom:16}})]}));function Profile(props){const{account,onClose,open,onSuccess}=props,[details,setDetails]=reactExports.useState({accountDetailsDTO:{}}),[isEnableEditProfile,setIsEnableEditProfile]=reactExports.useState(!1),[isPendingDetails,setIsPendingDetails]=reactExports.useState(!1);reactExports.useEffect(()=>{account&&(setIsPendingDetails(!0),Accounts.getInfoByIdAccount(account.id).then(({...rest})=>{setDetails({...rest})}).catch(()=>CHECK_ERROR("Không thể lấy thông tin tài khoản !")).finally(()=>setIsPendingDetails(!1)))},[account]);const handleSubmit=__name(e=>{e.preventDefault();const{email:email2,phoneNumber:phoneNumber2,userName:userName2,displayName:displayName2}=details;if(["Admin","admin"].some(cur=>cur===userName2)){CHECK_WARNING("Tên đăng nhập không hợp lệ");return}account.id},"handleSubmit"),handleChange=reactExports.useCallback(({target:{value,name}})=>{setDetails(pre=>({...pre,[name]:value}))},[]);reactExports.useEffect(()=>{open||isEnableEditProfile&&setIsEnableEditProfile(!1)},[open,isEnableEditProfile]);const{userName,displayName,email,phoneNumber,about}=details,Transition2=reactExports.forwardRef(__name(function(props2,ref){return jsxRuntimeExports.jsx(Slide,{direction:"up",ref,...props2})},"Transition2"));return jsxRuntimeExports.jsx(FullScreenDialog,{title:"Thông tin tài khoản",open,onClose,TransitionComponent:Transition2,children:jsxRuntimeExports.jsxs(Grid,{container:!0,spacing:1,children:[jsxRuntimeExports.jsx(Grid,{xs:8,children:jsxRuntimeExports.jsx(Form,{onChange:handleChange,onSubmit:handleSubmit,children:jsxRuntimeExports.jsx(Card,{children:jsxRuntimeExports.jsxs(CardContent,{children:[jsxRuntimeExports.jsx("legend",{style:{marginTop:8,marginLeft:8},children:"Thông tin tài khoản"}),isPendingDetails?jsxRuntimeExports.jsxs(Grid,{container:!0,spacing:1,children:[jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsx(MSkeleton,{})}),jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsx(MSkeleton,{})})]}):jsxRuntimeExports.jsxs(Grid,{container:!0,spacing:1,children:[jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsx(TextField,{value:displayName||"",label:"Tên hiển thị",name:"displayName",disabled:!isEnableEditProfile})}),jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsx(TextField,{disabled:!isEnableEditProfile,value:userName||"",label:"Tên đăng nhập",name:"userName",...userName&&isEnableEditProfile?{invalidFeedback:"Tên đăng nhập không hợp lệ",invalid:!1}:{}})})]}),jsxRuntimeExports.jsx("legend",{style:{marginLeft:8,marginTop:16},children:"Thông tin người dùng"}),jsxRuntimeExports.jsxs(Grid,{container:!0,children:[jsxRuntimeExports.jsx(Grid,{xs:6,children:isPendingDetails?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Array.from(new Array(5).keys()).map(key=>jsxRuntimeExports.jsx(MSkeleton,{},key))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(TextField,{label:"Họ tên",name:"displayName",required:!0,value:displayName||"",disabled:!isEnableEditProfile}),jsxRuntimeExports.jsx(TextField,{label:"email",name:"email",required:!0,value:email||"",disabled:!isEnableEditProfile}),jsxRuntimeExports.jsx(TextField,{disabled:!isEnableEditProfile,label:"Số điện thoại",name:"phoneNumber",required:!0,value:phoneNumber||""})]})}),jsxRuntimeExports.jsxs(Grid,{xs:6,children:[isPendingDetails?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Array.from(new Array(5).keys()).map(key=>jsxRuntimeExports.jsx(MSkeleton,{},key))}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(TextField,{disabled:!isEnableEditProfile,label:"Thông tin bổ sung",type:"textarea",name:"About",value:about||""})}),jsxRuntimeExports.jsx(Button,{size:"small",color:"primary",...isEnableEditProfile?{type:"submit"}:{onClick:()=>setIsEnableEditProfile(!0)},children:isEnableEditProfile?"Xác nhận":"Chỉnh sửa"})]})]})]})})})}),jsxRuntimeExports.jsx(Grid,{xs:4,children:jsxRuntimeExports.jsxs("div",{className:"card card-profile card-secondary",children:[jsxRuntimeExports.jsx("div",{className:"card-header",style:{backgroundImage:'url("/assets/img/blogpost.jpg")'},children:jsxRuntimeExports.jsx("div",{className:"profile-picture",children:jsxRuntimeExports.jsx("div",{className:"avatar avatar-xl",children:account.avatar&&jsxRuntimeExports.jsx(Avatar$1,{id:account.avatar,style:{},className:"avatar-img rounded-circle"})})})}),jsxRuntimeExports.jsx("div",{className:"card-body",children:jsxRuntimeExports.jsxs("div",{className:"user-profile text-center",children:[jsxRuntimeExports.jsx("div",{className:"name",children:account.DisplayName}),jsxRuntimeExports.jsx("div",{className:"job",children:details.Email}),jsxRuntimeExports.jsx("div",{className:"desc",children:account.authorities&&account.authorities.map(e=>e.name).join(", ")})]})})]})})]})})}__name(Profile,"Profile");const ACTION="Phân quyền";function ChangePermisson({authorities,allAuthorities,accountUuid,...props}){const{onError,open,handleClose}=props;reactExports.useEffect(()=>{if(authorities&&allAuthorities){const ungratedArr=allAuthorities.filter(e=>authorities.findIndex(f=>e.id===f.id)===-1);setUngrantedAuthorities(ungratedArr),setGrantedAuthorities(authorities)}},[allAuthorities,authorities]);const[grantedAuthorities,setGrantedAuthorities]=reactExports.useState(null),[ungrantedAuthorities,setUngrantedAuthorities]=reactExports.useState(null),grantPermission=__name(function(authority){setGrantedAuthorities(pre=>{let data=[...pre];return setUngrantedAuthorities(preUn=>{const index=preUn.findIndex(e=>e.id===authority.id),dataUn=[...preUn];return dataUn.splice(index,1),dataUn}),data.push(authority),data})},"grantPermission"),revokePermission=__name(function(authority){setUngrantedAuthorities(preUn=>{let data=[...preUn];return setGrantedAuthorities(pre=>{const index=pre.findIndex(e=>e.id===authority.id),dataUn=[...pre];return dataUn.splice(index,1),dataUn}),data.push(authority),data})},"revokePermission"),handleSave=reactExports.useCallback(()=>{if(grantedAuthorities){const uuidArr=grantedAuthorities.map(e=>e.id),data={taiKhoan_ID:accountUuid,vaiTros_ID:uuidArr};Accounts.addAuthorities(data).then(()=>{handleClose()}).catch(()=>onError(ACTION))}else handleClose()},[accountUuid,grantedAuthorities,handleClose,onError]);return jsxRuntimeExports.jsx(CustomizedDialogs,{title:"Cài đặt vai trò tài khoản",maxWidth:"xs",open,handleClose,renderFooter:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(Button,{startIcon:jsxRuntimeExports.jsx(Icon,{children:"save"}),onClick:handleSave,disabled:!1,children:"Lưu"})}),children:jsxRuntimeExports.jsxs(Grid,{container:!0,children:[jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{children:"Các quyền đã được cấp"}),jsxRuntimeExports.jsx("h5",{children:"Chọn một quyền bất kì để thu hồi"}),grantedAuthorities&&grantedAuthorities.map(({name,id})=>jsxRuntimeExports.jsx(Chip,{onClick:()=>revokePermission({name,id}),label:name,clickable:!0,color:"primary",style:{margin:4}},id))]})}),jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{children:"Các quyền chưa được cấp"}),jsxRuntimeExports.jsx("h5",{children:"Chọn một quyền bất kì để cấp phát"}),ungrantedAuthorities&&ungrantedAuthorities.map(data=>jsxRuntimeExports.jsx(Chip,{onClick:()=>grantPermission({name:data==null?void 0:data.name,id:data==null?void 0:data.id}),label:data==null?void 0:data.name,clickable:!0,color:"default",style:{margin:4}},data==null?void 0:data.id))]})})]})})}__name(ChangePermisson,"ChangePermisson");const formData={displayName:{field_name:"displayName",title:"Tên hiển thị",type:"textbox",rules:{required:"Vui lòng nhập"}},email:{field_name:"email",title:"Email",type:"textbox",rules:{required:"Vui lòng nhập",pattern:{value:/\S+@\S+\.\S+/,message:"Sai định dạng email"}}},authorities:{isMulti:!0,field_name:"authorities",title:"Vai trò",type:"select-async-multi",rules:{required:"Vui lòng nhập"}},organizationId:{field_name:"organizationId",title:"Đơn vị",type:"select-async",url:"/api/buss/allow/Organizations",value_field:"id",value_label:"organName",rules:{required:"Vui lòng nhập"}}};function AccountModal({isOpen,toggle,onSuccess,onError,arrRoles,arrOrganizations}){const[data,setData]=reactExports.useState({userName:""}),[arrAuth,setArrAuthorities]=reactExports.useState([]);reactExports.useEffect(()=>{setArrAuthorities(arrRoles)},[arrRoles]);const handleChangeNS=reactExports.useCallback((name,value)=>{setData(pre=>({...pre,[name]:value}))},[]),getDataById=reactExports.useCallback(async id=>{try{return null}catch{}},[]),handleSubmit=reactExports.useCallback(async({userName,authorities,...accountDetails})=>{Accounts.addNewUsers({accountDetails,userName:accountDetails.email,authorities:authorities.map(cur=>cur.value)}).then(res=>{res.isSuccessed?onSuccess(res.resultObj):CHECK_WARNING(res.message)}).catch(()=>CHECK_WARNING("Tạo tài khoản không thành công"))},[onSuccess]),{execute,status}=useAsync(handleSubmit);return jsxRuntimeExports.jsx(Dialog,{open:!!isOpen,maxWidth:"xl",children:jsxRuntimeExports.jsxs(Form$1,{onSubmit:execute,defaultValues:()=>isOpen.id?getDataById(isOpen.id):Promise.resolve({}),children:[jsxRuntimeExports.jsx(DialogContent,{sx:{padding:"0px"},children:jsxRuntimeExports.jsxs(Card,{children:[jsxRuntimeExports.jsx(CardHeader,{title:isOpen.id?"Cập nhật":"Thêm mới"}),jsxRuntimeExports.jsx(CardContent,{sx:{background:"#E7EBF0"},children:jsxRuntimeExports.jsx(Box,{children:jsxRuntimeExports.jsx(Paper,{sx:{borderRadius:"0.3rem",padding:"1rem"},children:Object.entries(formData).map(([key,value],idx)=>jsxRuntimeExports.jsx(FormControl,{data:{...value,name:key,defaultOptions:arrAuth},rules:value.rules,name:key,value:data&&data[key],onChange:handleChangeNS,defaultValue:value.defaultValue||data[key]},idx+key))})})})]})}),jsxRuntimeExports.jsxs(DialogActions,{children:[jsxRuntimeExports.jsx(Button,{color:"error",startIcon:jsxRuntimeExports.jsx(Icon,{children:"cancel"}),onClick:toggle,disabled:!1,children:"Hủy"}),jsxRuntimeExports.jsx(Button,{type:"submit",variant:"outlined",startIcon:status==="pending"?jsxRuntimeExports.jsx(CircularProgress,{size:20}):jsxRuntimeExports.jsx(Icon,{children:"save"}),disabled:status==="pending",children:"Lưu"})]})]})})}__name(AccountModal,"AccountModal");function GetNameByArray(props){const{array,arrRoles}=props,[name,setName]=reactExports.useState([]);return reactExports.useEffect(()=>{if(arrRoles&&arrRoles.length!==0){let filteredArray;filteredArray=arrRoles?arrRoles.filter(function(f){return array.filter(function(f2){return f2.roleId===f.id}).length}):0,setName(filteredArray)}},[arrRoles,array]),jsxRuntimeExports.jsx("div",{children:name.map((e,i)=>jsxRuntimeExports.jsx(Chip,{label:e.name},i))})}__name(GetNameByArray,"GetNameByArray");const columns=[{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},type,Roles2)=>jsxRuntimeExports.jsx(GetNameByArray,{array:accountRoles,arrRoles:Roles2||[]})}];function AlertComp(props){return jsxRuntimeExports.jsx(Alert,{elevation:6,variant:"filled",...props})}__name(AlertComp,"AlertComp");const tableRef=reactExports.createRef(),reloadTable=__name(()=>tableRef.current&&tableRef.current.onQueryChange(),"reloadTable");function DanhSachTaiKhoan(){const[account,setAccount]=reactExports.useState(null),[Id,setId]=reactExports.useState(null),[authorities,setAuthorities]=reactExports.useState(null),[openProfile,setOpenProfile]=reactExports.useState(!1),[openPermisson,setOpenPermisson]=reactExports.useState(!1),[isOpenAccountModal,setIsOpenAccountModal]=reactExports.useState(!1),[allAuthorities,setAllAuthorities]=reactExports.useState([]),[arrRoles,setArrRoles]=reactExports.useState(null),[arrOrganizations,setArrOrganizations]=reactExports.useState([]),[idRole,setIdRole]=reactExports.useState(null),[condition,setCondition]=reactExports.useState("");reactExports.useEffect(()=>{Roles.getAllRoles().then(res=>{const option=[];res.forEach(cur=>{option.push({value:cur.id,label:cur.name,...cur})}),setArrRoles(option),setAllAuthorities(res)})},[]);const[openAlert,setOpenAlert]=reactExports.useState({isOpen:!1,message:"",severity:"success"}),[openDialog,setOpenDialog]=reactExports.useState({isOpen:!1,renderContent:()=>null,title:""}),handleSuccess=__name(function(action){setOpenAlert(preState=>({...preState,isOpen:!0,message:`${action} thành công`,severity:"success"})),reloadTable()},"handleSuccess"),handleError=__name(function(action){setOpenAlert(preState=>({...preState,isOpen:!0,message:`${action} thất bại, vui lòng thử lại`,severity:"error"}))},"handleError"),handleCloseDialog=reactExports.useCallback(function(){setOpenDialog(pre=>({...pre,isOpen:!1}))},[setOpenDialog]),getAuthorityOfData=reactExports.useCallback((data,roles)=>{if(data){const arrAuthority=[];data.forEach(cur=>{const{name}=roles.find(r=>r.id===cur.roleId);arrAuthority.push({id:cur.roleId,name})}),setAuthorities(arrAuthority)}},[]);return reactExports.useEffect(()=>{const where=[];idRole&&where.push(`accountRoles/any(a:a/roleId eq ${idRole})`),setCondition(where.join(" and "))},[idRole]),reactExports.useEffect(()=>{reloadTable()},[condition]),arrRoles&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(DataTable,{dataIni:arrRoles,title:jsxRuntimeExports.jsxs(Grid,{container:!0,sx:{width:"25rem",alignItems:"center"},children:[jsxRuntimeExports.jsx(Grid,{xs:6,children:"Danh sách tài khoản"}),jsxRuntimeExports.jsx(Grid,{xs:6,children:jsxRuntimeExports.jsx(SelectCustom,{placeholder:"Chọn vai trò...",value:idRole,onChange:e=>setIdRole(e?e.value:null),options:arrRoles,isClearable:!0})})]}),tableRef,url:"/admin/auth/Accounts",where:condition,columns,selectType:"withColumns",onAdd:{onClick:event=>setIsOpenAccountModal(!0)},onRowClick:(_event,rowData)=>{setAccount(rowData),setOpenProfile(!0)},onActions:[dataRow=>({icon:"redo",color:"rgb(230, 109, 204)",typeFont:"fontawesome",tooltip:"Reset mật khẩu",onClick:(event,rowData)=>{Accounts.resetPassword(rowData.userName).then(res=>{res.isSuccessed&&CHECK_SUCCESS("Mật khẩu mới",res.resultObj)})}}),dataRow=>({icon:"user-tag",color:"rgb(146, 148, 222)",typeFont:"fontawesome",tooltip:"Cài đặt vai trò",onClick:async(event,rowData)=>{getAuthorityOfData(rowData.accountRoles,arrRoles),setOpenPermisson(!0),setId(rowData.id)}}),dataRow=>({icon:"key",color:"rgb(146, 148, 222)",typeFont:"fontawesome",tooltip:"Đổi mật khẩu",onClick:async(event,rowData)=>{CHECK_CONFIRM_INPUT({mes:"Đổi mật khẩu",titles:"",typeInput:"password",placeholder:"Nhập mật khẩu"}).then(res=>{res&&res.isConfirmed&&Accounts.changePassword({username:rowData.userName,password:res.value}).then(({resultObj})=>{CHECK_SUCCESS("Đổi mật khẩu thành công")}).catch(err=>CHECK_ERROR(err.message))})}})]}),account&&jsxRuntimeExports.jsx(Profile,{account,open:openProfile,onClose:()=>setOpenProfile(!openProfile)}),authorities&&jsxRuntimeExports.jsx(ChangePermisson,{onSuccess:handleSuccess,onError:handleError,accountUuid:Id,allAuthorities,authorities,open:openPermisson,handleClose:()=>{setOpenPermisson(!openPermisson),setAuthorities(null)}}),jsxRuntimeExports.jsx(AccountModal,{onError:handleError,arrRoles,arrOrganizations,onSuccess:({password,userName})=>{setOpenDialog({isOpen:!0,renderContent:()=>(reloadTable(),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(DialogContentText,{id:"alert-dialog-slide-description",children:"Thông tin đăng nhập"}),jsxRuntimeExports.jsxs(DialogContentText,{id:"alert-dialog-slide-description",children:["Tài khoản : ",userName]}),jsxRuntimeExports.jsxs(DialogContentText,{id:"alert-dialog-slide-description",children:["Mật khẩu: ",password]})]})),title:"Đăng kí tài khoản thành công"}),setIsOpenAccountModal(!1)},isOpen:isOpenAccountModal,toggle:()=>setIsOpenAccountModal(!1)}),jsxRuntimeExports.jsxs(Dialog,{open:!!openDialog.isOpen,onClose:handleCloseDialog,children:[jsxRuntimeExports.jsx(DialogTitle,{id:"alert-dialog-slide-title",children:openDialog.title}),jsxRuntimeExports.jsx(DialogContent,{children:openDialog.renderContent()}),jsxRuntimeExports.jsx(DialogActions,{children:jsxRuntimeExports.jsx(Button,{onClick:handleCloseDialog,color:"primary",children:"Xác nhận"})})]}),jsxRuntimeExports.jsx(Snackbar,{open:openAlert.isOpen,autoHideDuration:6e3,onClose:()=>setOpenAlert(preState=>({...preState,isOpen:!1})),children:jsxRuntimeExports.jsx(AlertComp,{onClose:()=>setOpenAlert(preState=>({...preState,isOpen:!1})),severity:openAlert.severity,children:openAlert.message})})]})}__name(DanhSachTaiKhoan,"DanhSachTaiKhoan");export{DanhSachTaiKhoan as default};