import{d as F,b4 as A,r as s,oz as R,j as t,B as V,pv as L,T as N,R as D,pw as p,px as Y,nl as q,_ as w,py as G}from"./index-dc933734.js";import{M as H}from"./MasterPageTitle-7544e586.js";import{A as J}from"./add.department-312dc6c9.js";import{d as K}from"./Delete-5ebded29.js";import{e as Q}from"./Edit-abad5e84.js";import{C as U}from"./index-fd772b91.js";import{P as W}from"./Select-e75c6695.js";import{T as X}from"./TextField-a8016ff3.js";import{I as Z}from"./InputAdornment-a4d846b9.js";import"./index.esm-cd80da5b.js";import"./index.esm-288e984c.js";import"./yup-5b2e0cf9.js";import"./Divider-b8be3c1c.js";import"./dividerClasses-75377d2f.js";import"./FilterFilled-5453348f.js";import"./AntdIcon-bb02d05f.js";import"./objectSpread2-d52818a5.js";import"./index-9b86adbc.js";import"./GenericThumbnailView-69a8725b.js";import"./popper-f3391c26.js";import"./Grow-3459ea54.js";import"./ScrollableList-c8354e44.js";import"./CircularProgress-b8ef250f.js";import"./FormInput-58d4b01b.js";import"./FormControlLabel-476fd96c.js";import"./componentStyles-4df963a1.js";import"./TableRow-f425a931.js";import"./TextArea-80ac5c9b.js";import"./DialogContent-d9f48895.js";import"./DialogTitle-4ec33ac0.js";import"./DialogContentText-e0ace713.js";import"./Grid2-9337452f.js";import"./isMuiElement-f75ebb7c.js";import"./DialogActions-9dacec58.js";import"./TableContainer-dd105b51.js";import"./TableHead-2909bf19.js";import"./TablePagination-4ad2d9ff.js";import"./KeyboardArrowRight-e096ea37.js";import"./Toolbar-e48cc4d1.js";import"./MenuItem-03911a3a.js";import"./listItemTextClasses-436d31bc.js";import"./index-e5978b8b.js";const He=()=>{const n=F(),o=A(),[j,$]=s.useState(!1),[h,u]=s.useState(null),y=!!h,[m,v]=s.useState(null),{departments:{departmentsList:C,pageParams:i,loading:z,departmentsCount:S},mini:{miniLocationList:ee,miniLocationLoading:te,miniLocationParams:ae},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(e,a,d,c,g){return{index:e,code:a,name:d,reamrks:c,actions:g}}const[P,x]=s.useState(""),M=(e,a)=>{v(a),u(e.currentTarget)},l=()=>{u(null)},_=e=>{n(G({id:e,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...i,search:"",page:1,page_size:10}}))},b=C.map((e,a)=>{const d=(i.page-1)*i.page_size+(a+1),c=t.jsxs(V,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("DynamicDjango.change_department"))!==-1&&t.jsx("img",{src:Q,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{n(L({id:e==null?void 0:e.id})),f(!0)}}),(r==null?void 0:r.indexOf("DynamicDjango.delete_department"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:K,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:g=>M(g,e==null?void 0:e.id)}),t.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:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(N,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(D,{variant:"contained",type:"submit",color:"primary",onClick:()=>{_(m)},autoFocus:!0,children:"Yes"}),t.jsx(D,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,e.code,e.name,e.remarks,c)}),O=(e,a)=>{n(p({...i,search:"",page:a+1}))},k=e=>{n(p({...i,search:"",page:1,page_size:parseInt(e.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=e=>{n(q(e))},B=e=>{const a=e.target.value;x(a),n(p({...i,search:a||"",page:1,page_size:10}))},E=s.useMemo(()=>t.jsx(J,{}),[j]);return t.jsxs(t.Fragment,{children:[E,t.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:t.jsx(X,{type:"text",sx:{width:"300px"},value:P,size:"small",InputProps:{startAdornment:t.jsx(Z,{position:"start",children:t.jsx(w,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:t.jsx(U,{count:S,columns:T,rows:b,loading:z,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{He as default};
