import{d as K,r as p,b8 as U,a as W,pN as Y,b as q,j as t,B as H,eK as J,tw as Q,tx as j,R as X,T as Z,U as C,ty as n,op as L,tz as w,a3 as ee,my as te,$ as ae,tA as se}from"./index-60657852.js";import{T as re}from"./index-bcfba32e.js";import{M as oe}from"./MasterPageTitle-4d4d4430.js";import{A as ie}from"./add.moc-63d4b8b3.js";import{o as ne}from"./yup-75ad371b.js";import{c as pe,b as le,u as ce}from"./index.esm-509a598d.js";import{P as me}from"./Select-7d2a5359.js";import{C as de}from"./CardContent-f8a5d460.js";import{T as he}from"./TextField-6b778b78.js";import{I as ue}from"./InputAdornment-12fc79ce.js";import"./TableRow-0ab1e69a.js";import"./index-c6051076.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./Grow-a21bdd26.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./dividerClasses-590294d7.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";import"./index.esm-5fae0aa9.js";import"./Divider-6555f8d4.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./GenericThumbnailView-f8b17afa.js";import"./createClass-2b895736.js";import"./popper-f3391c26.js";import"./ScrollableList-ef4c85dc.js";import"./FormInput-6b018fe9.js";import"./FormControlLabel-95d4d7bb.js";import"./Checkbox-026acf65.js";import"./SwitchBase-3b306fc6.js";import"./componentStyles-19763afb.js";import"./TextArea-d897dbf9.js";import"./DialogContent-d5183bd6.js";import"./DialogTitle-66c21479.js";import"./DialogContentText-e3f3f7dd.js";import"./DialogActions-1dfa5a01.js";import"./isMuiElement-82a67859.js";const nt=()=>{const a=K(),[M,u]=p.useState(!1),i=U(),[g,x]=p.useState(null),y=!!g,[l,S]=p.useState(null),{moc:{mocList:c,pageParams:s,loading:b,mocCount:v,searchValue:ge,masterValue:z,masterEditId:T},system:{userAccessList:o}}=W(e=>({moc:Y(e),system:q(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 _=pe({search:le()});const{control:xe,handleSubmit:P,register:B,reset:E}=ce({resolver:ne(_),values:{search:s.search}}),k=(e,r)=>{S(r),x(e.currentTarget)},m=()=>{x(null)},A=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(Q({id:e==null?void 0:e.id})),f(!0),a(j(e==null?void 0:e.id))}}),(o==null?void 0:o.indexOf("Masters.delete_moc"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(X,{style:{cursor:"pointer",color:"#fc6f03"},onClick:G=>k(G,e==null?void 0:e.id)}),t.jsx(me,{id:l?String(l):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(Z,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(C,{variant:"contained",type:"submit",color:"primary",onClick:()=>{A(l)},autoFocus:!0,children:"Yes"}),t.jsx(C,{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}))},V=(e,r)=>{a(n({...s,search:"",page:r+1}))},N=e=>{a(n({...s,search:"",page:1,page_size:parseInt(e.target.value)}))};p.useEffect(()=>{a(n({...s,search:"",page:1,page_size:10})),i==null||i.setTitle("MOC"),i==null||i.setSubtitle("Masters"),E({search:""})},[]);const f=e=>{a(L({})),a(j(0)),u(e),a(w(e))},R=()=>{u(!1)},$=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:$})})}),t.jsx(re,{count:v,columns:I,rows:D,loading:b,page:s.page,pageSize:s.page_size,handleChangePage:V,handleChangeRowsPerPage:N})]})}),t.jsx(ie,{modal:M,closeModal:R,mastersName:"Moc",editId:T,mastersValue:z})]})};export{nt as default};
