import{d as F,b7 as A,r as s,qK as R,j as e,B as V,rG as L,T as N,R as D,rH as p,rI as q,pu as G,_ as H,rJ as J}from"./index-e79f7aad.js";import{M as K}from"./MasterPageTitle-a4f02d02.js";import{A as Y}from"./add.department-8baeb28d.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-b81f2313.js";import{P as X}from"./Select-8a61e5a6.js";import{T as Z}from"./TextField-21e22d39.js";import{I as $}from"./InputAdornment-d42c17cd.js";import"./index.esm-05058101.js";import"./index.esm-1ca67d65.js";import"./yup-96f14780.js";import"./Divider-d5c2dff6.js";import"./dividerClasses-691b251c.js";import"./FilterFilled-8d538f67.js";import"./AntdIcon-1cfbd840.js";import"./objectSpread2-d56e1476.js";import"./index-310d07a1.js";import"./GenericThumbnailView-8a83a30c.js";import"./createClass-b86a4c8d.js";import"./popper-f3391c26.js";import"./ScrollableList-5929779e.js";import"./CircularProgress-8c35778c.js";import"./FormInput-07daa19d.js";import"./FormControlLabel-bfeefc5c.js";import"./Checkbox-b895334d.js";import"./SwitchBase-e7cea42d.js";import"./componentStyles-7718fc5e.js";import"./TableRow-0ea91e40.js";import"./TextArea-ec29d1d5.js";import"./DialogContent-6a297cef.js";import"./DialogTitle-62595023.js";import"./DialogContentText-0c5306f9.js";import"./Grid2-7786e458.js";import"./isMuiElement-db2b7d4c.js";import"./DialogActions-edd1d02f.js";import"./LastPage-33ac3f68.js";import"./KeyboardArrowRight-285caa9b.js";import"./TableContainer-00013c19.js";import"./TableHead-1f8b658d.js";import"./TablePagination-6f9f31d4.js";import"./KeyboardArrowRight-4ee9435c.js";import"./LastPage-1ca2417e.js";import"./Toolbar-d2cd5725.js";import"./MenuItem-c14df0e9.js";import"./listItemTextClasses-d3a968ad.js";import"./listItemIconClasses-03011ebf.js";import"./index-e5978b8b.js";const Zt=()=>{const o=F(),n=A(),[j,w]=s.useState(!1),[h,u]=s.useState(null),y=!!h,[m,C]=s.useState(null),{departments:{departmentsList:v,pageParams:i,loading:I,departmentsCount:S},mini:{miniLocationList:tt,miniLocationLoading:et,miniLocationParams:at},system:{userAccessList:r}}=R(),T=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Description",width:10},{title:"Actions",width:10}];function z(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(J({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(V,{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(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: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(N,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(D,{variant:"contained",type:"submit",color:"primary",onClick:()=>{_(m)},autoFocus:!0,children:"Yes"}),e.jsx(D,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return z(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(q(""))}),[]);const f=t=>{o(G(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(Y,{}),[j]);return e.jsxs(e.Fragment,{children:[E,e.jsx(K,{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(H,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:e.jsx(W,{count:S,columns:T,rows:b,loading:I,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Zt as default};
