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-d895656a.js";import{T as re}from"./index-ea344eac.js";import{M as oe}from"./MasterPageTitle-a3ec39dd.js";import{A as ie}from"./add.moc-e237ce42.js";import{o as ne}from"./yup-9573aa79.js";import{c as le,b as pe,u as ce}from"./index.esm-1087b2f3.js";import{P as me}from"./Menu-1728e1dd.js";import{C as de}from"./CardContent-26fc99d8.js";import{T as he}from"./TextField-6f73e19a.js";import{I as ue}from"./InputAdornment-36977269.js";import"./TableRow-5557ab84.js";import"./useMediaQuery-dbbc87b0.js";import"./TableContainer-a89da0a1.js";import"./TableHead-1b575958.js";import"./Grow-d4be81a5.js";import"./TablePagination-582dd1d9.js";import"./KeyboardArrowRight-5067dfe9.js";import"./Toolbar-adca1e0f.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./MenuItem-f1f55b7e.js";import"./dividerClasses-f4dcf412.js";import"./listItemTextClasses-1ed38b44.js";import"./index.esm-44fedea2.js";import"./Divider-cb9ba1b0.js";import"./FilterFilled-9d5acdc3.js";import"./AntdIcon-19e16777.js";import"./objectSpread2-c21546fe.js";import"./index-45bf15b6.js";import"./GenericThumbnailView-532ea2d7.js";import"./popper-f3391c26.js";import"./ScrollableList-e2b22048.js";import"./CircularProgress-1f3ca34c.js";import"./FormInput-9b5da280.js";import"./FormControlLabel-2fb7bcfb.js";import"./componentStyles-866300fe.js";import"./TextArea-fb0d0821.js";import"./DialogContent-4ce43512.js";import"./DialogTitle-738ca272.js";import"./DialogContentText-8b9b0e0c.js";import"./DialogActions-7b82f6f6.js";import"./isMuiElement-424c145f.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};
