import{d as G,r as p,b7 as W,a as Y,p4 as q,b as H,j as t,B as J,eI as K,sN as U,sO as j,Q as X,T as Z,R as C,sP as n,nI as L,sQ as w,a2 as ee,lR as te,_ as ae,sR as se}from"./index-952e178b.js";import{T as re}from"./index-baa25e61.js";import{M as oe}from"./MasterPageTitle-7665a485.js";import{A as ie}from"./add.moc-1f441cee.js";import{o as ne}from"./yup-d92565dd.js";import{c as pe,b as le,u as ce}from"./index.esm-6feddb16.js";import{P as me}from"./Select-41d78585.js";import{C as de}from"./CardContent-f79f90af.js";import{T as he}from"./TextField-d1a887ff.js";import{I as ue}from"./InputAdornment-020147de.js";import"./TableRow-6a27d7f4.js";import"./useMediaQuery-86e0ce33.js";import"./TableContainer-e3ecf13b.js";import"./TableHead-e31d41f4.js";import"./TablePagination-b93979a3.js";import"./KeyboardArrowRight-c3d685e2.js";import"./LastPage-54692111.js";import"./Toolbar-201b514b.js";import"./MenuItem-f41722f4.js";import"./dividerClasses-8e897c94.js";import"./listItemTextClasses-ca40551b.js";import"./listItemIconClasses-3e4286ad.js";import"./index.esm-70af4911.js";import"./Divider-342f1cfc.js";import"./FilterFilled-1ab4da14.js";import"./AntdIcon-54006664.js";import"./objectSpread2-a71852a2.js";import"./index-22eb3e7f.js";import"./GenericThumbnailView-4e535459.js";import"./createClass-5a32667f.js";import"./popper-f3391c26.js";import"./ScrollableList-cd5816a8.js";import"./CircularProgress-3b605689.js";import"./FormInput-8320115a.js";import"./FormControlLabel-973be654.js";import"./Checkbox-6c7c4dc0.js";import"./SwitchBase-bd5cc4c6.js";import"./componentStyles-00160cc0.js";import"./TextArea-ce7716c9.js";import"./DialogContent-4facb916.js";import"./DialogTitle-3aa960f8.js";import"./DialogContentText-54d95680.js";import"./DialogActions-bd200b72.js";import"./index-e5978b8b.js";import"./isMuiElement-f03a71e4.js";const pt=()=>{const a=G(),[M,u]=p.useState(!1),i=W(),[g,x]=p.useState(null),y=!!g,[l,S]=p.useState(null),{moc:{mocList:c,pageParams:s,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,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}}),R=(e,r)=>{S(r),x(e.currentTarget)},m=()=>{x(null)},k=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(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(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:$=>R($,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:()=>{k(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}))},A=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))},N=()=>{u(!1)},Q=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:Q})})}),t.jsx(re,{count:v,columns:z,rows:D,loading:b,page:s.page,pageSize:s.page_size,handleChangePage:V,handleChangeRowsPerPage:A})]})}),t.jsx(ie,{modal:M,closeModal:N,mastersName:"Moc",editId:T,mastersValue:I})]})};export{pt as default};
