import{d as F,aV as V,r as s,op as A,j as e,B as L,pl as N,T as R,z as D,pm as p,pn as Y,n3 as q,M as G,po as H}from"./index-c5c88b67.js";import{M as J}from"./MasterPageTitle-405781d7.js";import{A as K}from"./add.department-142f7ae2.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-e101df4a.js";import{P as X}from"./Menu-e7d2b2ee.js";import{T as Z}from"./TextField-78388962.js";import{I as $}from"./InputAdornment-d66117f3.js";import"./index.esm-0ad88c35.js";import"./index.esm-81620445.js";import"./yup-41605283.js";import"./Divider-0dc41916.js";import"./dividerClasses-6bc0ca72.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./GenericThumbnailView-43782201.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./Grow-7345f8ea.js";import"./ScrollableList-21ab2b9c.js";import"./CircularProgress-13afa056.js";import"./FormInput-86f14880.js";import"./FormControlLabel-d6955dc8.js";import"./componentStyles-a5e5a830.js";import"./TableRow-2b359fa8.js";import"./TextArea-aad9dffe.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./Grid2-0ff60c92.js";import"./isMuiElement-b3c21f38.js";import"./DialogActions-1232a7fa.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./MenuItem-81e44793.js";import"./listItemTextClasses-88792089.js";const Qt=()=>{const n=F(),o=V(),[j,w]=s.useState(!1),[h,u]=s.useState(null),y=!!h,[m,C]=s.useState(null),{departments:{departmentsList:v,pageParams:i,loading:z,departmentsCount:S},mini:{miniLocationList:tt,miniLocationLoading:et,miniLocationParams:at},system:{userAccessList:r}}=A(),T=[{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[M,x]=s.useState(""),P=(t,a)=>{C(a),u(t.currentTarget)},l=()=>{u(null)},_=t=>{n(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(L,{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:()=>{n(N({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=>P(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(R,{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 I(d,t.code,t.name,t.remarks,c)}),O=(t,a)=>{n(p({...i,search:"",page:a+1}))},k=t=>{n(p({...i,search:"",page:1,page_size:parseInt(t.target.value)}))};s.useEffect(()=>(n(p({...i,search:"",page:1,page_size:10})),o==null||o.setTitle("Departments"),o==null||o.setSubtitle("Masters"),()=>{x(""),n(Y(""))}),[]);const f=t=>{n(q(t))},B=t=>{const a=t.target.value;x(a),n(p({...i,search:a||"",page:1,page_size:10}))},E=s.useMemo(()=>e.jsx(K,{}),[j]);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:M,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:S,columns:T,rows:b,loading:z,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Qt as default};
