import{d as N,r as m,b6 as $,a as G,pE as Y,b as H,j as t,B as J,qk as K,ql as I,T as Q,R as v,qm as n,pG as U,oc as W,_ as X,qn as Z}from"./index-e972fa8e.js";import{M as L}from"./MasterPageTitle-fc1ef7a8.js";import{c as w,b as ee,u as te}from"./index.esm-b3c20f6d.js";import{o as re}from"./yup-b3178c01.js";import{A as ae}from"./add.vendorItems-7162e7e5.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-db9d46ea.js";import{P as ne}from"./Select-a2938be0.js";import{T as me}from"./TextField-77f9d647.js";import{I as pe}from"./InputAdornment-acd34c72.js";import"./index.esm-44b3cc2a.js";import"./Divider-1d368ab1.js";import"./dividerClasses-b771f620.js";import"./FilterFilled-61dd8e74.js";import"./AntdIcon-c86cb7c3.js";import"./objectSpread2-5ffd54f7.js";import"./index-44db81fe.js";import"./SelectComponent-ef6ff29b.js";import"./createClass-8ffbea6f.js";import"./Checkbox-05d562e2.js";import"./SwitchBase-a3d90b7d.js";import"./Grow-0b3a9797.js";import"./DialogContent-51a7b314.js";import"./DialogTitle-6bcbc606.js";import"./DialogContentText-1562904b.js";import"./Grid2-936c64bd.js";import"./isMuiElement-fab695f8.js";import"./DialogActions-122de1b4.js";import"./componentStyles-7142291f.js";import"./TableRow-c60adf0a.js";import"./TableContainer-ad9de4b5.js";import"./TableHead-11d85aea.js";import"./TablePagination-63dde5fc.js";import"./KeyboardArrowRight-4b11e6b9.js";import"./LastPage-69d51b6f.js";import"./Toolbar-fca75f8a.js";import"./MenuItem-fab52ff5.js";import"./listItemTextClasses-f7cdafa8.js";import"./listItemIconClasses-bcb38dc7.js";import"./index-e5978b8b.js";const rt=()=>{const r=N(),[de,j]=m.useState(!1);m.useState("");const o=$(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:C,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=G(e=>({vendorItem:Y(e),system:H(e)})),[g,u]=m.useState(null),V=!!g,[d,b]=m.useState(null),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor",width:100},{title:"Action",width:100}];function M(e,s,c,h,p){return{index:e,code:s,item:c,vendor:h,actions:p}}let T=w({search:ee()});const{control:ge,handleSubmit:_,register:P,reset:E}=te({resolver:re(T),values:{search:a.search}}),O=(e,s)=>{b(s),u(e.currentTarget)},l=()=>{u(null)},k=e=>{r(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:a})),r(n({...a,search:"",page:1,page_size:10})),l()},B=S.map((e,s)=>{var p,f;const c=(a.page-1)*a.page_size+(s+1),h=t.jsxs(J,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_vendoritem"))!==-1&&t.jsx("img",{src:ie,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{r(K({id:(e==null?void 0:e.id)||""})),x(!0),r(I(e==null?void 0:e.id))}}),(i==null?void 0:i.indexOf("Masters.delete_vendoritem"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:se,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:R=>O(R,e==null?void 0:e.id)}),t.jsx(ne,{id:d?String(d):void 0,open:V,anchorEl:g,onClose:l,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(Q,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(v,{variant:"contained",type:"submit",color:"primary",onClick:()=>k(d),autoFocus:!0,children:"Yes"}),t.jsx(v,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return M(c,e.code||"",((p=e==null?void 0:e.item)==null?void 0:p.name)||"",((f=e==null?void 0:e.vendor)==null?void 0:f.name)||"",h)}),D=({search:e})=>{r(n({...a,search:e||"",page:1,page_size:10}))},F=(e,s)=>{r(n({...a,search:"",page:s+1}))},A=e=>{r(n({...a,search:"",page:1,page_size:parseInt(e.target.value)}))};m.useEffect(()=>{r(n({...a,search:"",page:1,page_size:10})),o==null||o.setTitle("VendorItem"),o==null||o.setSubtitle("Masters"),E({search:""})},[]);const x=e=>{r(U({})),r(I(0)),j(e),r(W(e))},q=e=>{const s=e.target.value;r(n({...a,search:s||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsx(L,{prefix:"Masters",postfix:"vendoritem",pageTitle:"Vendor Item",goBack:!0,addModelTile:(i==null?void 0:i.indexOf("Masters.add_vendoritem"))!==-1?"Add Vendor Item":void 0,modalVisible:!0,setIsModalVisible:x,pageText:"",searchComponent:t.jsx("form",{onSubmit:_(D),children:t.jsx(me,{type:"text",sx:{width:"300px"},...P("search"),size:"small",InputProps:{startAdornment:t.jsx(pe,{position:"start",children:t.jsx(X,{size:16})})},variant:"outlined",placeholder:"Search",onChange:q})}),children:t.jsx(oe,{count:C,columns:z,rows:B,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(ae,{})]})};export{rt as default};
