import{d as F,b6 as q,r as s,pv as A,j as e,B as R,qr as V,T as L,R as D,qs as p,qt as N,oh as Y,_ as G,qu as H}from"./index-aa25c5ff.js";import{M as J}from"./MasterPageTitle-4b4774f8.js";import{A as K}from"./add.department-aef2a1c4.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-06082cde.js";import{P as X}from"./Select-b8388c2f.js";import{T as Z}from"./TextField-55b66d20.js";import{I as $}from"./InputAdornment-1e7eea92.js";import"./index.esm-def27a11.js";import"./index.esm-a7f661dc.js";import"./yup-72cc4918.js";import"./Divider-52e89c7e.js";import"./dividerClasses-ce522944.js";import"./FilterFilled-8e291e82.js";import"./AntdIcon-b92b7162.js";import"./objectSpread2-f5b2f6aa.js";import"./index-d4b36417.js";import"./GenericThumbnailView-e0343bac.js";import"./createClass-d1bae5ec.js";import"./popper-f3391c26.js";import"./Grow-53c7e965.js";import"./ScrollableList-9498bc37.js";import"./CircularProgress-d6cfca6d.js";import"./FormInput-dc74a5d8.js";import"./FormControlLabel-56777c7d.js";import"./Checkbox-d917a1e2.js";import"./SwitchBase-f1314509.js";import"./componentStyles-e32842f3.js";import"./TableRow-ee82d902.js";import"./TextArea-d1a16eb1.js";import"./Dialog-049271f6.js";import"./DialogTitle-7a3842b8.js";import"./DialogContent-f207f33c.js";import"./DialogContentText-70face94.js";import"./Grid2-d00e0f6a.js";import"./isMuiElement-1b254892.js";import"./DialogActions-2338d733.js";import"./TableContainer-150455ba.js";import"./TableHead-7918647e.js";import"./TablePagination-7f533723.js";import"./KeyboardArrowRight-207c2b3b.js";import"./LastPage-cc741249.js";import"./Toolbar-aae1a453.js";import"./MenuItem-6f39aa2e.js";import"./listItemTextClasses-88140258.js";import"./listItemIconClasses-31a870c1.js";import"./index-e5978b8b.js";const Zt=()=>{const o=F(),n=q(),[j,w]=s.useState(!1),[h,u]=s.useState(null),y=!!h,[m,v]=s.useState(null),{departments:{departmentsList:C,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)=>{v(a),u(t.currentTarget)},l=()=>{u(null)},_=t=>{o(H({id:t,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...i,search:"",page:1,page_size:10}}))},b=C.map((t,a)=>{const d=(i.page-1)*i.page_size+(a+1),c=e.jsxs(R,{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:Q,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(N(""))}),[]);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(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:P,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:T,columns:z,rows:b,loading:S,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Zt as default};
