import{b as R,eb as V,r as s,vF as N,j as e,B as Y,b2 as $,wP as G,t as J,T as Q,J as f,wQ as p,uV as W,P as j,Y as q,wR as w}from"./index-d2b25495.js";import{T as H}from"./index-75fca24c.js";import{M as K}from"./MasterPageTitle-86504016.js";import{A as U}from"./add.department-73246b55.js";import{u as X}from"./index.esm-ce3c2c20.js";import{o as Z}from"./yup-267e586f.js";import{c as tt,b as et}from"./index.esm-3043d6d4.js";import{P as at}from"./Menu-337a466b.js";import{T as rt}from"./TextField-e155d2be.js";import{I as it}from"./InputAdornment-d0c3ebef.js";import"./TableContainer-dd7cf0ce.js";import"./TableRow-74f9cf3b.js";import"./Skeleton-1012c2e6.js";import"./index-1249dfe4.js";import"./useMediaQuery-b1fbc166.js";import"./TableHead-fac214d3.js";import"./createSvgIcon-e39ae511.js";import"./TablePagination-2c2a1682.js";import"./Select-ef36a2b2.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./useControlled-8d737f13.js";import"./MenuItem-2bdddad4.js";import"./List-863f013e.js";import"./dividerClasses-02a44d89.js";import"./listItemTextClasses-cadd4b00.js";import"./KeyboardArrowRight-7e978a8a.js";import"./index.esm-0ec21729.js";import"./FilterFilled-4dfce120.js";import"./AntdIcon-8449be55.js";import"./objectSpread2-b41ee31b.js";import"./index-709861af.js";import"./componentStyles-0e851d91.js";import"./popper-f3391c26.js";import"./index-38f860bc.js";import"./InputLabel-bb6ab40e.js";import"./FormInput-d202e905.js";import"./FormControlLabel-78be0abe.js";import"./Checkbox-d1c5682c.js";import"./SwitchBase-8b4bccce.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import"./Loader-1b927baf.js";import"./TextArea-7e39a6e1.js";import"./DialogContent-cded694d.js";import"./DialogTitle-a145b392.js";import"./DialogContentText-43575e44.js";import"./DialogActions-7c802cc8.js";import"./Grow-8719411b.js";import"./FormControl-73683015.js";const se=()=>{const o=R(),n=V(),[D,ot]=s.useState(!1),[g,u]=s.useState(null),y=!!g,[m,v]=s.useState(null),{departments:{departmentsList:b,pageParams:a,loading:C,departmentsCount:S},mini:{miniLocationList:nt,miniLocationLoading:st,miniLocationParams:pt},system:{userAccessList:i}}=N(),z=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Description",width:10},{title:"Actions",width:10}];function P(t,r,c,d,h){return{index:t,code:r,name:c,reamrks:d,actions:h}}let T=tt({search:et()});const{control:mt,handleSubmit:I,register:M,reset:lt}=X({resolver:Z(T),values:{search:a.search}}),_=(t,r)=>{v(r),u(t.currentTarget)},l=()=>{u(null)},O=t=>{o(w({id:t,clearDataFn:()=>{l()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},k=b.map((t,r)=>{const c=(a.page-1)*a.page_size+(r+1),d=e.jsxs(Y,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("DynamicDjango.change_department"))!==-1&&e.jsx($,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{o(G({id:t==null?void 0:t.id})),x(!0)}}),(i==null?void 0:i.indexOf("DynamicDjango.delete_department"))!==-1&&e.jsxs(e.Fragment,{children:[e.jsx(J,{style:{cursor:"pointer",color:"#fc6f03"},onClick:h=>_(h,t==null?void 0:t.id)}),e.jsx(at,{id:m?String(m):void 0,open:y,anchorEl:g,onClose:l,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsxs("div",{style:{padding:"15px"},children:[e.jsx(Q,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>{O(m)},autoFocus:!0,children:"Yes"}),e.jsx(f,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return P(c,t.code,t.name,t.remarks,d)}),B=({search:t})=>{o(p({...a,search:t||"",page:1,page_size:10}))},F=(t,r)=>{o(p({...a,search:"",page:r+1}))},E=t=>{o(p({...a,search:"",page:1,page_size:parseInt(t.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=t=>{o(W(t))},L=t=>{const r=t.target.value;o(p({...a,search:r||"",page:1,page_size:10}))},A=s.useMemo(()=>e.jsx(U,{}),[D]);return e.jsxs(e.Fragment,{children:[A,e.jsxs(K,{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:[e.jsx("form",{action:"",onSubmit:I(B),children:e.jsx(j,{container:!0,my:2,spacing:2,children:e.jsx(j,{children:e.jsx(rt,{type:"text",sx:{width:"500px"},...M("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:e.jsx(it,{position:"start",children:e.jsx(q,{size:16})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:L})})})}),e.jsx(H,{count:S,columns:z,rows:k,loading:C,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:E})]})]})};export{se as default};
