import{d as E,b8 as V,r as s,qV as A,j as e,B as R,rR as L,T as N,U as D,rS as p,rT as U,pF as q,$ as Y,rU as $}from"./index-c3f592b2.js";import{M as G}from"./MasterPageTitle-eaa6f939.js";import{A as H}from"./add.department-7217d2e2.js";import{d as J}from"./Delete-5ebded29.js";import{e as K}from"./Edit-abad5e84.js";import{C as Q}from"./index-14d7673e.js";import{P as W}from"./Select-9d10c4ab.js";import{T as X}from"./TextField-7d0d5009.js";import{I as Z}from"./InputAdornment-fd596377.js";import"./index.esm-1314deac.js";import"./index.esm-70dd1c06.js";import"./yup-abb4a026.js";import"./Divider-057a9865.js";import"./dividerClasses-03c42ea7.js";import"./FilterFilled-90800ccd.js";import"./AntdIcon-b07622f5.js";import"./objectSpread2-890c3efa.js";import"./index-78da10f4.js";import"./GenericThumbnailView-9f1d2f81.js";import"./createClass-c7973e27.js";import"./popper-f3391c26.js";import"./Grow-f61cc5ca.js";import"./ScrollableList-ecbfc0f3.js";import"./FormInput-adbf55b1.js";import"./FormControlLabel-3f9f7a84.js";import"./Checkbox-38171bff.js";import"./SwitchBase-38103115.js";import"./componentStyles-b8fcedb5.js";import"./TableRow-974e102e.js";import"./TextArea-674a9ec6.js";import"./DialogContent-b7fc1c43.js";import"./DialogTitle-5d3e2030.js";import"./DialogContentText-c3e782dc.js";import"./Grid2-9e718eb0.js";import"./isMuiElement-43203123.js";import"./DialogActions-6e00f4f1.js";import"./LastPage-4fb40c42.js";import"./KeyboardArrowRight-ee7691b4.js";import"./TableContainer-a7e6bb64.js";import"./TableHead-98885dba.js";import"./TablePagination-fd957a04.js";import"./KeyboardArrowRight-8b3fa289.js";import"./LastPage-a52503ff.js";import"./Toolbar-ac8f3726.js";import"./MenuItem-e7a45c4b.js";import"./listItemTextClasses-3ff99335.js";import"./listItemIconClasses-b60c7a41.js";const Wt=()=>{const o=E(),n=V(),[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)},b=t=>{o($({id:t,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...i,search:"",page:1,page_size:10}}))},_=v.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:K,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:J,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(N,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(D,{variant:"contained",type:"submit",color:"primary",onClick:()=>{b(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(U(""))}),[]);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}))},F=s.useMemo(()=>e.jsx(H,{}),[j]);return e.jsxs(e.Fragment,{children:[F,e.jsx(G,{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(Y,{size:16})})},variant:"outlined",placeholder:"Search",onChange:B}),children:e.jsx(Q,{count:T,columns:z,rows:_,loading:S,page:i.page,pageSize:i.page_size,handleChangePage:O,handleChangeRowsPerPage:k,showPagination:!0})})]})};export{Wt as default};
