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-def636a4.js";import{T as H}from"./index-fc769754.js";import{M as J}from"./MasterPageTitle-bbea54a4.js";import{A as U}from"./add.department-8267fab7.js";import{u as X}from"./index.esm-7d9d1491.js";import{o as Z}from"./yup-c8535458.js";import{c as ee,b as te}from"./index.esm-eec4f448.js";import{P as ae}from"./Menu-af49d134.js";import{T as re}from"./TextField-2ba95a45.js";import{I as ie}from"./InputAdornment-196a5386.js";import"./TableContainer-5944247b.js";import"./TableRow-2c544f58.js";import"./Skeleton-5cf57ed1.js";import"./index-b5a6fbe3.js";import"./useMediaQuery-4304fb25.js";import"./TableHead-f0476938.js";import"./createSvgIcon-ff487f53.js";import"./TablePagination-7d3b42e9.js";import"./Select-2cfb5afd.js";import"./OutlinedInput-ddb8bb3f.js";import"./useFormControl-880b2f7b.js";import"./List-17cd485b.js";import"./useControlled-bd643819.js";import"./MenuItem-8fdd2340.js";import"./dividerClasses-2b953c2a.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./index.esm-c912dbcd.js";import"./FilterFilled-08c5b5a7.js";import"./AntdIcon-34324527.js";import"./objectSpread2-a4d0f5f6.js";import"./presets-dbb0f3bf.js";import"./componentStyles-41382c67.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-f48c8aa0.js";import"./InputLabel-e2e73b27.js";import"./FormInput-8d872744.js";import"./FormControlLabel-f5b899d5.js";import"./Checkbox-76a12c6d.js";import"./SwitchBase-b0dec868.js";/* empty css                   */import"./ScrollableList-a550bc32.js";import"./Loader-16c57fae.js";import"./TextArea-6c103c50.js";import"./DialogContent-0cb684b3.js";import"./DialogTitle-e2e75924.js";import"./DialogContentText-b2259947.js";import"./DialogActions-c4045764.js";import"./Grow-85576dd3.js";import"./FormControl-1f811046.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};
