import{d as E,b8 as V,r as s,qV as A,j as e,B as R,rR as L,T as N,U as D,rS as p,rT as U,pF as q,$ as Y,rU as $}from"./index-60657852.js";import{M as G}from"./MasterPageTitle-4d4d4430.js";import{A as H}from"./add.department-c626437d.js";import{d as J}from"./Delete-5ebded29.js";import{e as K}from"./Edit-abad5e84.js";import{C as Q}from"./index-61d7dc47.js";import{P as W}from"./Select-7d2a5359.js";import{T as X}from"./TextField-6b778b78.js";import{I as Z}from"./InputAdornment-12fc79ce.js";import"./index.esm-5fae0aa9.js";import"./index.esm-509a598d.js";import"./yup-75ad371b.js";import"./Divider-6555f8d4.js";import"./dividerClasses-590294d7.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./GenericThumbnailView-f8b17afa.js";import"./createClass-2b895736.js";import"./popper-f3391c26.js";import"./Grow-a21bdd26.js";import"./ScrollableList-ef4c85dc.js";import"./FormInput-6b018fe9.js";import"./FormControlLabel-95d4d7bb.js";import"./Checkbox-026acf65.js";import"./SwitchBase-3b306fc6.js";import"./componentStyles-19763afb.js";import"./TableRow-0ab1e69a.js";import"./TextArea-d897dbf9.js";import"./DialogContent-d5183bd6.js";import"./DialogTitle-66c21479.js";import"./DialogContentText-e3f3f7dd.js";import"./Grid2-09163d35.js";import"./isMuiElement-82a67859.js";import"./DialogActions-1dfa5a01.js";import"./LastPage-71f2133b.js";import"./KeyboardArrowRight-450d5bb8.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";const Wt=()=>{const o=E(),n=V(),[j,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)},b=t=>{o($({id:t,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...i,search:"",page:1,page_size:10}}))},_=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:K,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{o(L({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:J,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:g=>M(g,t==null?void 0:t.id)}),e.jsx(W,{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(N,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(D,{variant:"contained",type:"submit",color:"primary",onClick:()=>{b(m)},autoFocus:!0,children:"Yes"}),e.jsx(D,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,t.code,t.name,t.remarks,c)}),O=(t,a)=>{o(p({...i,search:"",page:a+1}))},k=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(U(""))}),[]);const f=t=>{o(q(t))},B=t=>{const a=t.target.value;x(a),o(p({...i,search:a||"",page:1,page_size:10}))},F=s.useMemo(()=>e.jsx(H,{}),[j]);return e.jsxs(e.Fragment,{children:[F,e.jsx(G,{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(X,{type:"text",sx:{width:"300px"},value:P,size:"small",InputProps:{startAdornment:e.jsx(Z,{position:"start",children:e.jsx(Y,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:e.jsx(Q,{count:T,columns:z,rows:_,loading:S,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Wt as default};
