import{d as F,b4 as R,r as s,oR as A,j as e,B as N,pN as V,T as L,R as D,pO as p,pP as Q,nD as Y,_ as q,pQ as G}from"./index-858224db.js";import{M as H}from"./MasterPageTitle-cb9528e3.js";import{A as J}from"./add.department-0d3bedac.js";import{d as K}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-d0523d92.js";import{P as X}from"./Select-8b602eed.js";import{T as Z}from"./TextField-bbb2480f.js";import{I as $}from"./InputAdornment-583927e5.js";import"./index.esm-20949d74.js";import"./index.esm-241dec99.js";import"./yup-9213c3af.js";import"./Divider-262150be.js";import"./dividerClasses-3bf2d765.js";import"./FilterFilled-4ddeca5a.js";import"./AntdIcon-8f3bee6f.js";import"./objectSpread2-cfd43bb2.js";import"./index-9223140c.js";import"./GenericThumbnailView-2d7b7363.js";import"./createClass-042c577b.js";import"./popper-f3391c26.js";import"./Grow-b7b43b3f.js";import"./ScrollableList-bf78e54b.js";import"./CircularProgress-5bd54bd6.js";import"./FormInput-8eacbbd9.js";import"./FormControlLabel-c742681c.js";import"./Checkbox-57cdf644.js";import"./SwitchBase-959e94f2.js";import"./componentStyles-107bd37e.js";import"./TableRow-ef998644.js";import"./TextArea-78cda1eb.js";import"./DialogContent-e06a39bc.js";import"./DialogTitle-6e616d34.js";import"./DialogContentText-a2775ca2.js";import"./Grid2-274bb638.js";import"./isMuiElement-ec705bc2.js";import"./DialogActions-825c19e9.js";import"./TableContainer-0664e137.js";import"./TableHead-cf76ecee.js";import"./TablePagination-4cf72ac4.js";import"./KeyboardArrowRight-b25c72ab.js";import"./LastPage-c7260b25.js";import"./Toolbar-9be5abc1.js";import"./MenuItem-bf5218a0.js";import"./listItemTextClasses-ac0d77df.js";import"./listItemIconClasses-5ed9cb9d.js";import"./index-e5978b8b.js";const Xt=()=>{const o=F(),n=R(),[j,w]=s.useState(!1),[h,u]=s.useState(null),y=!!h,[m,C]=s.useState(null),{departments:{departmentsList:v,pageParams:i,loading:S,departmentsCount:T},mini:{miniLocationList:tt,miniLocationLoading:et,miniLocationParams:at},system:{userAccessList:r}}=A(),z=[{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=>{o(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(N,{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(V({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(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(L,{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)=>{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(Y(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(J,{}),[j]);return e.jsxs(e.Fragment,{children:[E,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(Z,{type:"text",sx:{width:"300px"},value:P,size:"small",InputProps:{startAdornment:e.jsx($,{position:"start",children:e.jsx(q,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:e.jsx(W,{count:T,columns:z,rows:b,loading:S,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Xt as default};
