import{d as F,b7 as A,r as s,qa as R,j as e,B as V,r6 as L,T as N,R as D,r7 as p,r8 as Y,oY as q,_ as G,r9 as H}from"./index-952e178b.js";import{M as J}from"./MasterPageTitle-7665a485.js";import{A as K}from"./add.department-36963439.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-8c2f17c1.js";import{P as X}from"./Select-41d78585.js";import{T as Z}from"./TextField-d1a887ff.js";import{I as $}from"./InputAdornment-020147de.js";import"./index.esm-70af4911.js";import"./index.esm-6feddb16.js";import"./yup-d92565dd.js";import"./Divider-342f1cfc.js";import"./dividerClasses-8e897c94.js";import"./FilterFilled-1ab4da14.js";import"./AntdIcon-54006664.js";import"./objectSpread2-a71852a2.js";import"./index-22eb3e7f.js";import"./GenericThumbnailView-4e535459.js";import"./createClass-5a32667f.js";import"./popper-f3391c26.js";import"./ScrollableList-cd5816a8.js";import"./CircularProgress-3b605689.js";import"./FormInput-8320115a.js";import"./FormControlLabel-973be654.js";import"./Checkbox-6c7c4dc0.js";import"./SwitchBase-bd5cc4c6.js";import"./componentStyles-00160cc0.js";import"./TableRow-6a27d7f4.js";import"./TextArea-ce7716c9.js";import"./DialogContent-4facb916.js";import"./DialogTitle-3aa960f8.js";import"./DialogContentText-54d95680.js";import"./Grid2-7b742c2a.js";import"./isMuiElement-f03a71e4.js";import"./DialogActions-bd200b72.js";import"./LastPage-9979d461.js";import"./KeyboardArrowRight-91d2ccce.js";import"./TableContainer-e3ecf13b.js";import"./TableHead-e31d41f4.js";import"./TablePagination-b93979a3.js";import"./KeyboardArrowRight-c3d685e2.js";import"./LastPage-54692111.js";import"./Toolbar-201b514b.js";import"./MenuItem-f41722f4.js";import"./listItemTextClasses-ca40551b.js";import"./listItemIconClasses-3e4286ad.js";import"./index-e5978b8b.js";const Zt=()=>{const o=F(),n=A(),[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}}=R(),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(H({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:U,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{o(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: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(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)=>{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(Y(""))}),[]);const f=t=>{o(q(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};
