import{d as F,b6 as q,r as s,pw as A,j as e,B as R,qs as V,T as L,R as D,qt as p,qu as N,oi as Y,_ as w,qv as G}from"./index-5ae5cc5e.js";import{M as H}from"./MasterPageTitle-426707bb.js";import{A as J}from"./add.department-7a26e854.js";import{d as K}from"./Delete-5ebded29.js";import{e as Q}from"./Edit-abad5e84.js";import{C as U}from"./index-b50996fd.js";import{P as W}from"./Select-6f375e89.js";import{T as X}from"./TextField-013fef4f.js";import{I as Z}from"./InputAdornment-c8af61f0.js";import"./index.esm-91b69e04.js";import"./index.esm-bd37e938.js";import"./yup-86a48159.js";import"./Divider-e1d32c28.js";import"./dividerClasses-ea2ed133.js";import"./FilterFilled-40058e95.js";import"./AntdIcon-b932f733.js";import"./objectSpread2-13a56fdb.js";import"./index-125b1c7e.js";import"./GenericThumbnailView-fac7773c.js";import"./createClass-227e27b6.js";import"./popper-f3391c26.js";import"./Grow-d70e9b6d.js";import"./ScrollableList-2ee889f8.js";import"./CircularProgress-672898c5.js";import"./FormInput-77541d96.js";import"./FormControlLabel-b2fabe81.js";import"./Checkbox-84b6779a.js";import"./SwitchBase-4fa73d90.js";import"./componentStyles-7d84c389.js";import"./TableRow-fbdd6d52.js";import"./TextArea-20f097f8.js";import"./DialogContent-e2578cbd.js";import"./DialogTitle-4a5aec12.js";import"./DialogContentText-bc10bf8d.js";import"./Grid2-48c222cb.js";import"./isMuiElement-c29cfc23.js";import"./DialogActions-ad26e3d6.js";import"./TableContainer-ed67fdcd.js";import"./TableHead-15aac70d.js";import"./TablePagination-63129eb6.js";import"./KeyboardArrowRight-8e772e39.js";import"./LastPage-aa82a010.js";import"./Toolbar-0ec32807.js";import"./MenuItem-dc2bf765.js";import"./listItemTextClasses-2547faff.js";import"./listItemIconClasses-20c36342.js";import"./index-e5978b8b.js";const Wt=()=>{const o=F(),n=q(),[j,$]=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(G({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:Q,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(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(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(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(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:T,columns:z,rows:b,loading:S,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Wt as default};
