import{d as E,b4 as F,r as s,oA as R,j as e,B as V,pw as L,T as N,R as D,px as p,py as Y,nm as q,_ as w,pz as G}from"./index-ba11e6ab.js";import{M as H}from"./MasterPageTitle-6247bce5.js";import{A as J}from"./add.department-77672ae8.js";import{d as K}from"./Delete-5ebded29.js";import{e as Q}from"./Edit-abad5e84.js";import{C as U}from"./index-5081f854.js";import{P as W}from"./Select-f9434f8a.js";import{T as X}from"./TextField-16337ecc.js";import{I as Z}from"./InputAdornment-0f07311f.js";import"./index.esm-c4573c1c.js";import"./index.esm-39ef576a.js";import"./yup-902af9ab.js";import"./Divider-7b675f59.js";import"./dividerClasses-ab944802.js";import"./FilterFilled-94a9d775.js";import"./AntdIcon-d49f53d6.js";import"./objectSpread2-d72b34ab.js";import"./index-33824b7d.js";import"./GenericThumbnailView-511a7e33.js";import"./popper-f3391c26.js";import"./Grow-1038181b.js";import"./ScrollableList-b4fc4d99.js";import"./CircularProgress-509803a6.js";import"./FormInput-3e62ad24.js";import"./FormControlLabel-8048035a.js";import"./Checkbox-3e187368.js";import"./SwitchBase-7d4e0bc8.js";import"./componentStyles-cc6f218d.js";import"./TableRow-e1616615.js";import"./TextArea-1c46e0e4.js";import"./DialogContent-af77e042.js";import"./DialogTitle-dc43931f.js";import"./DialogContentText-990aa19e.js";import"./Grid2-12794a3c.js";import"./isMuiElement-f8265807.js";import"./DialogActions-3fe54b4c.js";import"./TableContainer-9178cc85.js";import"./TableHead-5a0d8cfc.js";import"./TablePagination-3b5112dd.js";import"./KeyboardArrowRight-36117cc9.js";import"./Toolbar-c7a1b81e.js";import"./MenuItem-e4578955.js";import"./listItemTextClasses-a4497781.js";import"./index-e5978b8b.js";const Kt=()=>{const n=E(),o=F(),[j,$]=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}}=R(),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[P,x]=s.useState(""),M=(t,a)=>{C(a),u(t.currentTarget)},l=()=>{u(null)},_=t=>{n(G({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:Q,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{n(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:K,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:()=>{_(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}))},A=s.useMemo(()=>e.jsx(J,{}),[j]);return e.jsxs(e.Fragment,{children:[A,e.jsx(H,{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(w,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:e.jsx(U,{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};
