import{b as V,e8 as N,r as s,vF as R,j as t,B as Y,b2 as $,wC as G,v as K,T as Q,K as f,wD as p,uV as W,Q as j,Y as q,wE as w}from"./index-43bf7a1c.js";import{T as H}from"./index-2d303f1d.js";import{M as J}from"./MasterPageTitle-e54f2b5e.js";import{A as U}from"./add.department-a7ec7208.js";import{u as X}from"./index.esm-0548c843.js";import{o as Z}from"./yup-3b80ed10.js";import{c as ee,b as te}from"./index.esm-f9e0a906.js";import{P as ae}from"./Menu-362130d3.js";import{T as re}from"./TextField-4da97115.js";import{I as ie}from"./InputAdornment-b1a1aa58.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.js";import"./useMediaQuery-d6627623.js";import"./TableHead-fb4972c5.js";import"./createSvgIcon-f118be02.js";import"./TablePagination-9147f93d.js";import"./Select-44fd3147.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./List-6fcc4821.js";import"./useControlled-ab567149.js";import"./MenuItem-58b8887e.js";import"./dividerClasses-497df10c.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./index.esm-d1bd9bb6.js";import"./FilterFilled-ccc86e02.js";import"./AntdIcon-634507e8.js";import"./objectSpread2-c31b885b.js";import"./presets-bb9bdfd8.js";import"./componentStyles-4624000e.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-913b2dc6.js";import"./InputLabel-6c7474f0.js";import"./FormInput-33b720a4.js";import"./FormControlLabel-15b42e5e.js";import"./Checkbox-b7a88fca.js";import"./SwitchBase-75578ec7.js";/* empty css                   */import"./ScrollableList-e19132c3.js";import"./Loader-aabe9ed3.js";import"./TextArea-23730be7.js";import"./DialogContent-d5902709.js";import"./DialogTitle-20dc6f66.js";import"./DialogContentText-abf03c9f.js";import"./DialogActions-d63c6496.js";import"./Grow-ca573f65.js";import"./FormControl-8d011aab.js";const st=()=>{const o=V(),n=N(),[D,oe]=s.useState(!1),[g,u]=s.useState(null),y=!!g,[m,v]=s.useState(null),{departments:{departmentsList:C,pageParams:a,loading:S,departmentsCount:b},mini:{miniLocationList:ne,miniLocationLoading:se,miniLocationParams:pe},system:{userAccessList:i}}=R(),z=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Description",width:10},{title:"Actions",width:10}];function T(e,r,c,d,h){return{index:e,code:r,name:c,reamrks:d,actions:h}}let P=ee({search:te()});const{control:me,handleSubmit:I,register:M,reset:le}=X({resolver:Z(P),values:{search:a.search}}),_=(e,r)=>{v(r),u(e.currentTarget)},l=()=>{u(null)},O=e=>{o(w({id:e,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},k=C.map((e,r)=>{const c=(a.page-1)*a.page_size+(r+1),d=t.jsxs(Y,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("DynamicDjango.change_department"))!==-1&&t.jsx($,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{o(G({id:e==null?void 0:e.id})),x(!0)}}),(i==null?void 0:i.indexOf("DynamicDjango.delete_department"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(K,{style:{cursor:"pointer",color:"#fc6f03"},onClick:h=>_(h,e==null?void 0:e.id)}),t.jsx(ae,{id:m?String(m):void 0,open:y,anchorEl:g,onClose:l,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(Q,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>{O(m)},autoFocus:!0,children:"Yes"}),t.jsx(f,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return T(c,e.code,e.name,e.remarks,d)}),B=({search:e})=>{o(p({...a,search:e||"",page:1,page_size:10}))},F=(e,r)=>{o(p({...a,search:"",page:r+1}))},E=e=>{o(p({...a,search:"",page:1,page_size:parseInt(e.target.value)}))};s.useEffect(()=>{o(p({...a,search:"",page:1,page_size:10})),n==null||n.setTitle("Departments"),n==null||n.setSubtitle("Masters")},[]);const x=e=>{o(W(e))},L=e=>{const r=e.target.value;o(p({...a,search:r||"",page:1,page_size:10}))},A=s.useMemo(()=>t.jsx(U,{}),[D]);return t.jsxs(t.Fragment,{children:[A,t.jsxs(J,{prefix:"DynamicDjango",postfix:"Department",pageTitle:"Department",goBack:!0,addModelTile:(i==null?void 0:i.indexOf("DynamicDjango.add_department"))!==-1?"Add Department":void 0,modalVisible:!0,setIsModalVisible:x,pageText:"",children:[t.jsx("form",{action:"",onSubmit:I(B),children:t.jsx(j,{container:!0,my:2,spacing:2,children:t.jsx(j,{children:t.jsx(re,{type:"text",sx:{width:"500px"},...M("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(ie,{position:"start",children:t.jsx(q,{size:16})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:L})})})}),t.jsx(H,{count:b,columns:z,rows:k,loading:S,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:E})]})]})};export{st as default};
