import{d as Q,r as l,b4 as W,a as Y,nt as Z,b as q,j as t,B as H,eZ as J,re as K,rf as j,Q as U,T as X,R as C,rg as n,m4 as L,rh as w,a2 as ee,kr as te,_ as ae,ri as re}from"./index-dc933734.js";import{T as se}from"./index-ad373baf.js";import{M as oe}from"./MasterPageTitle-7544e586.js";import{A as ie}from"./add.moc-0025dcae.js";import{o as ne}from"./yup-5b2e0cf9.js";import{c as le,b as pe,u as ce}from"./index.esm-288e984c.js";import{P as me}from"./Select-e75c6695.js";import{C as de}from"./CardContent-06dac9b3.js";import{T as he}from"./TextField-a8016ff3.js";import{I as ue}from"./InputAdornment-a4d846b9.js";import"./TableRow-f425a931.js";import"./useMediaQuery-c00165e7.js";import"./TableContainer-dd105b51.js";import"./TableHead-2909bf19.js";import"./Grow-3459ea54.js";import"./TablePagination-4ad2d9ff.js";import"./KeyboardArrowRight-e096ea37.js";import"./Toolbar-e48cc4d1.js";import"./MenuItem-03911a3a.js";import"./dividerClasses-75377d2f.js";import"./listItemTextClasses-436d31bc.js";import"./index.esm-cd80da5b.js";import"./Divider-b8be3c1c.js";import"./FilterFilled-5453348f.js";import"./AntdIcon-bb02d05f.js";import"./objectSpread2-d52818a5.js";import"./index-9b86adbc.js";import"./GenericThumbnailView-69a8725b.js";import"./popper-f3391c26.js";import"./ScrollableList-c8354e44.js";import"./CircularProgress-b8ef250f.js";import"./FormInput-58d4b01b.js";import"./FormControlLabel-476fd96c.js";import"./componentStyles-4df963a1.js";import"./TextArea-80ac5c9b.js";import"./DialogContent-d9f48895.js";import"./DialogTitle-4ec33ac0.js";import"./DialogContentText-e0ace713.js";import"./DialogActions-9dacec58.js";import"./index-e5978b8b.js";import"./isMuiElement-f75ebb7c.js";const st=()=>{const a=Q(),[M,u]=l.useState(!1),i=W(),[g,x]=l.useState(null),y=!!g,[p,S]=l.useState(null),{moc:{mocList:c,pageParams:r,loading:b,mocCount:v,searchValue:ge,masterValue:T,masterEditId:z},system:{userAccessList:o}}=Y(e=>({moc:Z(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,s,d,h){return{index:e,code:s,name:d,actions:h}}let _=le({search:pe()});const{control:xe,handleSubmit:P,register:B,reset:k}=ce({resolver:ne(_),values:{search:r.search}}),E=(e,s)=>{S(s),x(e.currentTarget)},m=()=>{x(null)},D=e=>{a(re({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),m()},F=c==null?void 0:c.map((e,s)=>{const d=(r.page-1)*r.page_size+(s+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(j(e==null?void 0:e.id))}}),(o==null?void 0:o.indexOf("Masters.delete_moc"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(U,{style:{cursor:"pointer",color:"#fc6f03"},onClick:G=>E(G,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(X,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(C,{variant:"contained",type:"submit",color:"primary",onClick:()=>{D(p)},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)}),V=({search:e})=>{a(n({...r,search:e||"",page:1,page_size:10}))},A=(e,s)=>{a(n({...r,search:"",page:s+1}))},R=e=>{a(n({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};l.useEffect(()=>{a(n({...r,search:"",page:1,page_size:10})),i==null||i.setTitle("MOC"),i==null||i.setSubtitle("Masters"),k({search:""})},[]);const f=e=>{a(L({})),a(j(0)),u(e),a(w(e))},N=()=>{u(!1)},$=e=>{const s=e.target.value;a(n({...r,search:s||"",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(V),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(se,{count:v,columns:I,rows:F,loading:b,page:r.page,pageSize:r.page_size,handleChangePage:A,handleChangeRowsPerPage:R})]})}),t.jsx(ie,{modal:M,closeModal:N,mastersName:"Moc",editId:z,mastersValue:T})]})};export{st as default};
