import{b as N,e8 as R,r as s,vA as V,j as t,B as Q,b2 as Y,wx as $,v as G,T as K,K as f,wy as p,uQ as W,Q as j,Y as q,wz as w}from"./index-76d4793e.js";import{T as H}from"./index-1fae9bc3.js";import{M as J}from"./MasterPageTitle-e8b467fa.js";import{A as U}from"./add.department-78d3f300.js";import{u as X}from"./index.esm-3adfd9f7.js";import{o as Z}from"./yup-688ec4f6.js";import{c as ee,b as te}from"./index.esm-ad8a7c9f.js";import{P as ae}from"./Menu-ed7c6894.js";import{T as re}from"./TextField-9c64a4a2.js";import{I as ie}from"./InputAdornment-b99403ce.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.js";import"./useMediaQuery-8cb39c65.js";import"./TableHead-c6031541.js";import"./createSvgIcon-01ec10fc.js";import"./TablePagination-5e47b2d0.js";import"./Select-338083eb.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./List-4c24b3e8.js";import"./useControlled-e03384de.js";import"./MenuItem-cff1abce.js";import"./dividerClasses-45958eb8.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./index.esm-d9f89842.js";import"./FilterFilled-aa7d40e4.js";import"./AntdIcon-55dc1b5f.js";import"./objectSpread2-51b6810f.js";import"./componentStyles-0803b39e.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-ecea5cfc.js";import"./InputLabel-5ed57f0e.js";import"./FormInput-8f40ded1.js";import"./FormControlLabel-77c65f77.js";import"./Checkbox-ce15672a.js";import"./SwitchBase-25e1ee17.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import"./Loader-9f443a4c.js";import"./TextArea-f4ef1e8b.js";import"./DialogContent-7bd8dd8f.js";import"./DialogTitle-71dd5b3a.js";import"./DialogContentText-7642f81f.js";import"./DialogActions-5a5e1db9.js";import"./Grow-84b30c0e.js";import"./FormControl-c671c595.js";const nt=()=>{const o=N(),n=R(),[D,oe]=s.useState(!1),[g,u]=s.useState(null),y=!!g,[m,v]=s.useState(null),{departments:{departmentsList:z,pageParams:a,loading:C,departmentsCount:S},mini:{miniLocationList:ne,miniLocationLoading:se,miniLocationParams:pe},system:{userAccessList:i}}=V(),b=[{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=z.map((e,r)=>{const c=(a.page-1)*a.page_size+(r+1),d=t.jsxs(Q,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("DynamicDjango.change_department"))!==-1&&t.jsx(Y,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{o($({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(G,{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(K,{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}))},A=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))},E=e=>{const r=e.target.value;o(p({...a,search:r||"",page:1,page_size:10}))},L=s.useMemo(()=>t.jsx(U,{}),[D]);return t.jsxs(t.Fragment,{children:[L,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:E})})})}),t.jsx(H,{count:S,columns:b,rows:k,loading:C,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A})]})]})};export{nt as default};
