import{d as Y,r as l,aV as $,a as G,nb as X,b as Z,j as t,B as H,eS as J,qV as K,qW as M,y as Q,T as U,z as j,qX as n,lO as L,qY as w,R as ee,k9 as te,M as ae,qZ as se}from"./index-4dfc510b.js";import{T as re}from"./index-2560e6e6.js";import{M as oe}from"./MasterPageTitle-68cbcd9e.js";import{A as ie}from"./add.moc-6750c946.js";import{o as ne}from"./yup-80def618.js";import{c as le,b as pe,u as ce}from"./index.esm-0a454763.js";import{P as me}from"./Menu-0f556e12.js";import{C as de}from"./CardContent-afcdca5e.js";import{T as he}from"./TextField-c0d4022e.js";import{I as ue}from"./InputAdornment-ccd6e8ff.js";import"./TableRow-bee40746.js";import"./useMediaQuery-75ea24f6.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./Grow-a7315f12.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./MenuItem-9737e3d9.js";import"./dividerClasses-26c2a6d6.js";import"./listItemTextClasses-e85f7ff0.js";import"./index.esm-337179d9.js";import"./Divider-1794f57d.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./GenericThumbnailView-6256cad7.js";import"./popper-f3391c26.js";import"./ScrollableList-bef4a518.js";import"./CircularProgress-d36b5e75.js";import"./FormInput-f887e69c.js";import"./FormControlLabel-e49dd1e5.js";import"./componentStyles-df94248d.js";import"./TextArea-a0cc14f3.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./DialogActions-49286e71.js";import"./isMuiElement-7be61a21.js";const ot=()=>{const a=Y(),[C,u]=l.useState(!1),i=$(),[g,x]=l.useState(null),y=!!g,[p,S]=l.useState(null),{moc:{mocList:c,pageParams:s,loading:b,mocCount:v,searchValue:ge,masterValue:z,masterEditId:T},system:{userAccessList:o}}=G(e=>({moc:X(e),system:Z(e)})),I=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function O(e,r,d,h){return{index:e,code:r,name:d,actions:h}}let _=le({search:pe()});const{control:xe,handleSubmit:P,register:B,reset:V}=ce({resolver:ne(_),values:{search:s.search}}),k=(e,r)=>{S(r),x(e.currentTarget)},m=()=>{x(null)},E=e=>{a(se({id:e,clearDataFn:()=>{},navigate:r=>{},pageParams:s})),a(n({...s,search:"",page:1,page_size:10})),m()},D=c==null?void 0:c.map((e,r)=>{const d=(s.page-1)*s.page_size+(r+1),h=t.jsxs(H,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(o==null?void 0:o.indexOf("Masters.change_moc"))!==-1&&t.jsx(J,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(K({id:e==null?void 0:e.id})),f(!0),a(M(e==null?void 0:e.id))}}),(o==null?void 0:o.indexOf("Masters.delete_moc"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(Q,{style:{cursor:"pointer",color:"#fc6f03"},onClick:W=>k(W,e==null?void 0:e.id)}),t.jsx(me,{id:p?String(p):void 0,open:y,anchorEl:g,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(U,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{E(p)},autoFocus:!0,children:"Yes"}),t.jsx(j,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return O(d,e.code,e.name,h)}),F=({search:e})=>{a(n({...s,search:e||"",page:1,page_size:10}))},q=(e,r)=>{a(n({...s,search:"",page:r+1}))},A=e=>{a(n({...s,search:"",page:1,page_size:parseInt(e.target.value)}))};l.useEffect(()=>{a(n({...s,search:"",page:1,page_size:10})),i==null||i.setTitle("MOC"),i==null||i.setSubtitle("Masters"),V({search:""})},[]);const f=e=>{a(L({})),a(M(0)),u(e),a(w(e))},R=()=>{u(!1)},N=e=>{const r=e.target.value;a(n({...s,search:r||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsx(oe,{prefix:"Masters",postfix:"moc",pageTitle:"MOC",goBack:!0,addModelTile:(o==null?void 0:o.indexOf("Masters.add_moc"))!==-1?"Add MOC":void 0,modalVisible:!0,setIsModalVisible:f,pageText:""}),t.jsx(ee,{sx:{marginBottom:"20px",marginTop:"15px"},children:t.jsxs(de,{style:{padding:"10px",borderRadius:"10px"},children:[t.jsx("form",{action:"",onSubmit:P(F),children:t.jsx(te,{container:!0,mb:2,children:t.jsx(he,{type:"text",sx:{width:"500px"},...B("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(ue,{position:"start",children:t.jsx(ae,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:N})})}),t.jsx(re,{count:v,columns:I,rows:D,loading:b,page:s.page,pageSize:s.page_size,handleChangePage:q,handleChangeRowsPerPage:A})]})}),t.jsx(ie,{modal:C,closeModal:R,mastersName:"Moc",editId:T,mastersValue:z})]})};export{ot as default};
