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-4dfc510b.js";import{M as J}from"./MasterPageTitle-68cbcd9e.js";import{A as K}from"./add.department-9831ea5d.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-71406b65.js";import{P as X}from"./Menu-0f556e12.js";import{T as Z}from"./TextField-c0d4022e.js";import{I as $}from"./InputAdornment-ccd6e8ff.js";import"./index.esm-337179d9.js";import"./index.esm-0a454763.js";import"./yup-80def618.js";import"./Divider-1794f57d.js";import"./dividerClasses-26c2a6d6.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./GenericThumbnailView-6256cad7.js";import"./popper-f3391c26.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./Grow-a7315f12.js";import"./ScrollableList-bef4a518.js";import"./CircularProgress-d36b5e75.js";import"./FormInput-f887e69c.js";import"./FormControlLabel-e49dd1e5.js";import"./componentStyles-df94248d.js";import"./TableRow-bee40746.js";import"./TextArea-a0cc14f3.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./Grid2-713975b3.js";import"./isMuiElement-7be61a21.js";import"./DialogActions-49286e71.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./MenuItem-9737e3d9.js";import"./listItemTextClasses-e85f7ff0.js";const Kt=()=>{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{Kt as default};
