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-c3f592b2.js";import{T as re}from"./index-6f96a8b8.js";import{M as oe}from"./MasterPageTitle-eaa6f939.js";import{A as ie}from"./add.moc-72266e92.js";import{o as ne}from"./yup-abb4a026.js";import{c as pe,b as le,u as ce}from"./index.esm-70dd1c06.js";import{P as me}from"./Select-9d10c4ab.js";import{C as de}from"./CardContent-fa813e56.js";import{T as he}from"./TextField-7d0d5009.js";import{I as ue}from"./InputAdornment-fd596377.js";import"./TableRow-974e102e.js";import"./index-88943ce1.js";import"./TableContainer-a7e6bb64.js";import"./TableHead-98885dba.js";import"./Grow-f61cc5ca.js";import"./TablePagination-fd957a04.js";import"./KeyboardArrowRight-8b3fa289.js";import"./LastPage-a52503ff.js";import"./Toolbar-ac8f3726.js";import"./MenuItem-e7a45c4b.js";import"./dividerClasses-03c42ea7.js";import"./listItemTextClasses-3ff99335.js";import"./listItemIconClasses-b60c7a41.js";import"./index.esm-1314deac.js";import"./Divider-057a9865.js";import"./FilterFilled-90800ccd.js";import"./AntdIcon-b07622f5.js";import"./objectSpread2-890c3efa.js";import"./index-78da10f4.js";import"./GenericThumbnailView-9f1d2f81.js";import"./createClass-c7973e27.js";import"./popper-f3391c26.js";import"./ScrollableList-ecbfc0f3.js";import"./FormInput-adbf55b1.js";import"./FormControlLabel-3f9f7a84.js";import"./Checkbox-38171bff.js";import"./SwitchBase-38103115.js";import"./componentStyles-b8fcedb5.js";import"./TextArea-674a9ec6.js";import"./DialogContent-b7fc1c43.js";import"./DialogTitle-5d3e2030.js";import"./DialogContentText-c3e782dc.js";import"./DialogActions-6e00f4f1.js";import"./isMuiElement-43203123.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};
