import{d as Q,r as p,b7 as W,a as Y,pC as q,b as H,j as t,B as J,eI as K,tl as U,tm as C,Q as X,T as Z,R as j,tn as n,oe as L,to as w,a2 as ee,mn as te,_ as ae,tp as re}from"./index-e79f7aad.js";import{T as se}from"./index-a65810f4.js";import{M as oe}from"./MasterPageTitle-a4f02d02.js";import{A as ie}from"./add.moc-69ea5252.js";import{o as ne}from"./yup-96f14780.js";import{c as pe,b as le,u as ce}from"./index.esm-1ca67d65.js";import{P as me}from"./Select-8a61e5a6.js";import{C as de}from"./CardContent-f9f46bc4.js";import{T as he}from"./TextField-21e22d39.js";import{I as ue}from"./InputAdornment-d42c17cd.js";import"./TableRow-0ea91e40.js";import"./useMediaQuery-9155ba05.js";import"./TableContainer-00013c19.js";import"./TableHead-1f8b658d.js";import"./TablePagination-6f9f31d4.js";import"./KeyboardArrowRight-4ee9435c.js";import"./LastPage-1ca2417e.js";import"./Toolbar-d2cd5725.js";import"./MenuItem-c14df0e9.js";import"./dividerClasses-691b251c.js";import"./listItemTextClasses-d3a968ad.js";import"./listItemIconClasses-03011ebf.js";import"./index.esm-05058101.js";import"./Divider-d5c2dff6.js";import"./FilterFilled-8d538f67.js";import"./AntdIcon-1cfbd840.js";import"./objectSpread2-d56e1476.js";import"./index-310d07a1.js";import"./GenericThumbnailView-8a83a30c.js";import"./createClass-b86a4c8d.js";import"./popper-f3391c26.js";import"./ScrollableList-5929779e.js";import"./CircularProgress-8c35778c.js";import"./FormInput-07daa19d.js";import"./FormControlLabel-bfeefc5c.js";import"./Checkbox-b895334d.js";import"./SwitchBase-e7cea42d.js";import"./componentStyles-7718fc5e.js";import"./TextArea-ec29d1d5.js";import"./DialogContent-6a297cef.js";import"./DialogTitle-62595023.js";import"./DialogContentText-0c5306f9.js";import"./DialogActions-edd1d02f.js";import"./index-e5978b8b.js";import"./isMuiElement-db2b7d4c.js";const pt=()=>{const a=Q(),[M,u]=p.useState(!1),i=W(),[g,x]=p.useState(null),y=!!g,[l,S]=p.useState(null),{moc:{mocList:c,pageParams:r,loading:b,mocCount:v,searchValue:ge,masterValue:I,masterEditId:T},system:{userAccessList:o}}=Y(e=>({moc:q(e),system:H(e)})),z=[{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 _=pe({search:le()});const{control:xe,handleSubmit:P,register:B,reset:E}=ce({resolver:ne(_),values:{search:r.search}}),k=(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(J,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(o==null?void 0:o.indexOf("Masters.change_moc"))!==-1&&t.jsx(K,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(U({id:e==null?void 0:e.id})),f(!0),a(C(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(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{D(l)},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)}),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)}))};p.useEffect(()=>{a(n({...r,search:"",page:1,page_size:10})),i==null||i.setTitle("MOC"),i==null||i.setSubtitle("Masters"),E({search:""})},[]);const f=e=>{a(L({})),a(C(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:z,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:T,mastersValue:I})]})};export{pt as default};
