import{d as $,r as p,aV as Y,a as q,oB as G,b as H,j as t,B as J,ph as K,pi as I,T as Q,z as v,pj as n,oD as U,n1 as W,M as X,pk as Z}from"./index-d895656a.js";import{M as L}from"./MasterPageTitle-a3ec39dd.js";import{c as w,b as ee,u as te}from"./index.esm-1087b2f3.js";import{o as ae}from"./yup-9573aa79.js";import{A as re}from"./add.vendorItems-adeefb50.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-a3f5b318.js";import{P as ne}from"./Menu-1728e1dd.js";import{T as pe}from"./TextField-6f73e19a.js";import{I as de}from"./InputAdornment-36977269.js";import"./index.esm-44fedea2.js";import"./Divider-cb9ba1b0.js";import"./dividerClasses-f4dcf412.js";import"./FilterFilled-9d5acdc3.js";import"./AntdIcon-19e16777.js";import"./objectSpread2-c21546fe.js";import"./index-45bf15b6.js";import"./SelectComponent-32c91e44.js";import"./DialogContent-4ce43512.js";import"./DialogTitle-738ca272.js";import"./DialogContentText-8b9b0e0c.js";import"./Grid2-5bd460ea.js";import"./isMuiElement-424c145f.js";import"./DialogActions-7b82f6f6.js";import"./Grow-d4be81a5.js";import"./componentStyles-866300fe.js";import"./TableRow-5557ab84.js";import"./TableContainer-a89da0a1.js";import"./TableHead-1b575958.js";import"./TablePagination-582dd1d9.js";import"./KeyboardArrowRight-5067dfe9.js";import"./Toolbar-adca1e0f.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./MenuItem-f1f55b7e.js";import"./listItemTextClasses-1ed38b44.js";const Le=()=>{const a=$(),[me,j]=p.useState(!1);p.useState("");const o=Y(),{vendorItem:{vendorItemList:S,pageParams:r,loading:y,vendorItemCount:C,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=q(e=>({vendorItem:G(e),system:H(e)})),[g,u]=p.useState(null),V=!!g,[m,z]=p.useState(null),M=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor",width:100},{title:"Action",width:100}];function b(e,s,c,h,d){return{index:e,code:s,item:c,vendor:h,actions:d}}let T=w({search:ee()});const{control:ge,handleSubmit:_,register:P,reset:B}=te({resolver:ae(T),values:{search:r.search}}),O=(e,s)=>{z(s),u(e.currentTarget)},l=()=>{u(null)},k=e=>{a(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),l()},D=S.map((e,s)=>{var d,f;const c=(r.page-1)*r.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:()=>{a(K({id:(e==null?void 0:e.id)||""})),x(!0),a(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:N=>O(N,e==null?void 0:e.id)}),t.jsx(ne,{id:m?String(m):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(m),autoFocus:!0,children:"Yes"}),t.jsx(v,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return b(c,e.code||"",((d=e==null?void 0:e.item)==null?void 0:d.name)||"",((f=e==null?void 0:e.vendor)==null?void 0:f.name)||"",h)}),E=({search:e})=>{a(n({...r,search:e||"",page:1,page_size:10}))},F=(e,s)=>{a(n({...r,search:"",page:s+1}))},A=e=>{a(n({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};p.useEffect(()=>{a(n({...r,search:"",page:1,page_size:10})),o==null||o.setTitle("VendorItem"),o==null||o.setSubtitle("Masters"),B({search:""})},[]);const x=e=>{a(U({})),a(I(0)),j(e),a(W(e))},R=e=>{const s=e.target.value;a(n({...r,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:_(E),children:t.jsx(pe,{type:"text",sx:{width:"300px"},...P("search"),size:"small",InputProps:{startAdornment:t.jsx(de,{position:"start",children:t.jsx(X,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R})}),children:t.jsx(oe,{count:C,columns:M,rows:D,loading:y,page:r.page,pageSize:r.page_size,handleChangePage:F,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(re,{})]})};export{Le as default};
