import{d as F,b6 as q,r as s,pk as A,j as e,B as R,qg as V,T as L,R as j,qh as p,qi as N,o6 as Y,_ as G,qj as H}from"./index-6c48ebe4.js";import{M as J}from"./MasterPageTitle-d5826191.js";import{A as K}from"./add.department-66c3f18c.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-c4af4ad7.js";import{P as X}from"./Select-c5c274bb.js";import{T as Z}from"./TextField-3876249c.js";import{I as $}from"./InputAdornment-42748b9a.js";import"./index.esm-83aa69eb.js";import"./index.esm-fd3369ba.js";import"./yup-75ac0470.js";import"./Divider-96d02e86.js";import"./dividerClasses-28ddda01.js";import"./FilterFilled-a2396aeb.js";import"./AntdIcon-3eb8cd38.js";import"./objectSpread2-31ff416c.js";import"./index-84485105.js";import"./GenericThumbnailView-e18774c4.js";import"./createClass-8ad09c76.js";import"./popper-f3391c26.js";import"./Grow-3d640bff.js";import"./ScrollableList-e9cb113e.js";import"./CircularProgress-7b4c6820.js";import"./FormInput-345d040e.js";import"./FormControlLabel-122a731f.js";import"./Checkbox-f9887e1d.js";import"./SwitchBase-8951f097.js";import"./componentStyles-1dd5fe29.js";import"./TableRow-31f0a4a1.js";import"./TextArea-4432195b.js";import"./DialogContent-2975c76a.js";import"./DialogTitle-6235c46a.js";import"./DialogContentText-928ca488.js";import"./Grid2-70d79e93.js";import"./isMuiElement-447b74a0.js";import"./DialogActions-aa83bc6c.js";import"./TableContainer-45046f6e.js";import"./TableHead-37e5318b.js";import"./TablePagination-cd240560.js";import"./KeyboardArrowRight-345292ac.js";import"./LastPage-6dc33080.js";import"./Toolbar-6122c8d7.js";import"./MenuItem-12bffc2f.js";import"./listItemTextClasses-6920789d.js";import"./listItemIconClasses-a3efc5a3.js";import"./index-e5978b8b.js";const Xt=()=>{const o=F(),n=q(),[D,w]=s.useState(!1),[h,u]=s.useState(null),y=!!h,[m,C]=s.useState(null),{departments:{departmentsList:v,pageParams:i,loading:S,departmentsCount:T},mini:{miniLocationList:tt,miniLocationLoading:et,miniLocationParams:at},system:{userAccessList:r}}=A(),z=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Description",width:10},{title:"Actions",width:10}];function I(t,a,d,c,g){return{index:t,code:a,name:d,reamrks:c,actions:g}}const[P,x]=s.useState(""),M=(t,a)=>{C(a),u(t.currentTarget)},l=()=>{u(null)},_=t=>{o(H({id:t,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...i,search:"",page:1,page_size:10}}))},b=v.map((t,a)=>{const d=(i.page-1)*i.page_size+(a+1),c=e.jsxs(R,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("DynamicDjango.change_department"))!==-1&&e.jsx("img",{src:U,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{o(V({id:t==null?void 0:t.id})),f(!0)}}),(r==null?void 0:r.indexOf("DynamicDjango.delete_department"))!==-1&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Q,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:g=>M(g,t==null?void 0:t.id)}),e.jsx(X,{id:m?String(m):void 0,open:y,anchorEl:h,onClose:l,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsxs("div",{style:{padding:"15px"},children:[e.jsx(L,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{_(m)},autoFocus:!0,children:"Yes"}),e.jsx(j,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,t.code,t.name,t.remarks,c)}),k=(t,a)=>{o(p({...i,search:"",page:a+1}))},O=t=>{o(p({...i,search:"",page:1,page_size:parseInt(t.target.value)}))};s.useEffect(()=>(o(p({...i,search:"",page:1,page_size:10})),n==null||n.setTitle("Departments"),n==null||n.setSubtitle("Masters"),()=>{x(""),o(N(""))}),[]);const f=t=>{o(Y(t))},B=t=>{const a=t.target.value;x(a),o(p({...i,search:a||"",page:1,page_size:10}))},E=s.useMemo(()=>e.jsx(K,{}),[D]);return e.jsxs(e.Fragment,{children:[E,e.jsx(J,{prefix:"DynamicDjango",postfix:"Department",pageTitle:"Department",goBack:!0,addModelTile:(r==null?void 0:r.indexOf("DynamicDjango.add_department"))!==-1?"Add Department":void 0,modalVisible:!0,setIsModalVisible:f,pageText:"",searchComponent:e.jsx(Z,{type:"text",sx:{width:"300px"},value:P,size:"small",InputProps:{startAdornment:e.jsx($,{position:"start",children:e.jsx(G,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:e.jsx(W,{count:T,columns:z,rows:b,loading:S,page:i.page,pageSize:i.page_size,handleChangePage:k,handleChangeRowsPerPage:O,showPagination:!0})})]})};export{Xt as default};
