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-60a3c753.js";import{T as H}from"./index-7e55cf46.js";import{M as J}from"./MasterPageTitle-8a6edc29.js";import{A as U}from"./add.department-11433e40.js";import{u as X}from"./index.esm-c494934a.js";import{o as Z}from"./yup-92678dde.js";import{c as ee,b as te}from"./index.esm-62d6b2f7.js";import{P as ae}from"./Menu-d1b7e1c3.js";import{T as re}from"./TextField-32b29087.js";import{I as ie}from"./InputAdornment-96c40dce.js";import"./TableContainer-414c12e0.js";import"./TableRow-0b33776c.js";import"./Skeleton-98c353d9.js";import"./index-a99c9f65.js";import"./useMediaQuery-dba48e3b.js";import"./TableHead-f864c753.js";import"./createSvgIcon-de433e5f.js";import"./TablePagination-218dde38.js";import"./Select-99fc0d84.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./List-f567f8e4.js";import"./useControlled-194ef007.js";import"./MenuItem-2f410bd2.js";import"./dividerClasses-3fa67596.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./index.esm-8ea8e217.js";import"./FilterFilled-cdde02db.js";import"./AntdIcon-bed41c21.js";import"./objectSpread2-85813881.js";import"./presets-06d13753.js";import"./componentStyles-7753bbb9.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-900fa817.js";import"./InputLabel-71dfc9d4.js";import"./FormInput-74e2c4d2.js";import"./FormControlLabel-950ba0c7.js";import"./Checkbox-fe59fe9f.js";import"./SwitchBase-eb3a47ff.js";/* empty css                   */import"./ScrollableList-1962b023.js";import"./Loader-466ccb5e.js";import"./TextArea-b2d5bcf9.js";import"./DialogContent-89e21f2e.js";import"./DialogTitle-fe69da5c.js";import"./DialogContentText-6688bd59.js";import"./DialogActions-e754942c.js";import"./Grow-68442588.js";import"./FormControl-d13d2693.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};
