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-83d9c1e2.js";import{M as H}from"./MasterPageTitle-9ab56f94.js";import{A as J}from"./add.department-df4047d3.js";import{d as K}from"./Delete-5ebded29.js";import{e as Q}from"./Edit-abad5e84.js";import{C as U}from"./index-ffc92880.js";import{P as W}from"./Select-1505055e.js";import{T as X}from"./TextField-39c52322.js";import{I as Z}from"./InputAdornment-4b0a9854.js";import"./index.esm-316fec71.js";import"./index.esm-82874186.js";import"./yup-dfe9f223.js";import"./Divider-71865361.js";import"./dividerClasses-f18f0f93.js";import"./FilterFilled-eb3492a9.js";import"./AntdIcon-f9724de9.js";import"./objectSpread2-e5f2d908.js";import"./index-1ceef347.js";import"./GenericThumbnailView-ceecb14e.js";import"./popper-f3391c26.js";import"./Grow-6cc6748b.js";import"./ScrollableList-2bb71a63.js";import"./CircularProgress-3ce9da74.js";import"./FormInput-03b7722e.js";import"./FormControlLabel-af5c9791.js";import"./Checkbox-fe0b2cdb.js";import"./SwitchBase-ad42caec.js";import"./componentStyles-7858e543.js";import"./TableRow-1c35ea2a.js";import"./TextArea-7d949f4d.js";import"./DialogContent-a75c4d06.js";import"./DialogTitle-3c642f58.js";import"./DialogContentText-ab545101.js";import"./Grid2-78565a55.js";import"./isMuiElement-5c2699ea.js";import"./DialogActions-3c3ab24c.js";import"./TableContainer-98997305.js";import"./TableHead-95baa189.js";import"./TablePagination-81b30c1b.js";import"./KeyboardArrowRight-b7bab219.js";import"./Toolbar-25a41873.js";import"./MenuItem-26e66f0f.js";import"./listItemTextClasses-fcd068d2.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};
