import{d as Y,r as l,aV as $,a as G,nb as X,b as Z,j as t,B as H,eR 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-c5c88b67.js";import{T as re}from"./index-f0b37835.js";import{M as oe}from"./MasterPageTitle-405781d7.js";import{A as ie}from"./add.moc-f634d5c7.js";import{o as ne}from"./yup-41605283.js";import{c as le,b as pe,u as ce}from"./index.esm-81620445.js";import{P as me}from"./Menu-e7d2b2ee.js";import{C as de}from"./CardContent-5f043396.js";import{T as he}from"./TextField-78388962.js";import{I as ue}from"./InputAdornment-d66117f3.js";import"./TableRow-2b359fa8.js";import"./useMediaQuery-fe3ce37c.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./Grow-7345f8ea.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./MenuItem-81e44793.js";import"./dividerClasses-6bc0ca72.js";import"./listItemTextClasses-88792089.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./GenericThumbnailView-43782201.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./ScrollableList-21ab2b9c.js";import"./CircularProgress-13afa056.js";import"./FormInput-86f14880.js";import"./FormControlLabel-d6955dc8.js";import"./componentStyles-a5e5a830.js";import"./TextArea-aad9dffe.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./DialogActions-1232a7fa.js";import"./isMuiElement-b3c21f38.js";const it=()=>{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}))},R=(e,r)=>{a(n({...s,search:"",page:r+1}))},q=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))},A=()=>{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:R,handleChangeRowsPerPage:q})]})}),t.jsx(ie,{modal:C,closeModal:A,mastersName:"Moc",editId:T,mastersValue:z})]})};export{it as default};
