import{d as $,r as p,b4 as Y,a as q,oM as G,b as H,j as t,B as J,ps as K,pt as I,T as Q,R as v,pu as n,oO as U,nk as W,_ as X,pv as Z}from"./index-83d9c1e2.js";import{M as L}from"./MasterPageTitle-9ab56f94.js";import{c as w,b as ee,u as te}from"./index.esm-82874186.js";import{o as ae}from"./yup-dfe9f223.js";import{A as re}from"./add.vendorItems-a23b4869.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-ffc92880.js";import{P as ne}from"./Select-1505055e.js";import{T as pe}from"./TextField-39c52322.js";import{I as de}from"./InputAdornment-4b0a9854.js";import"./index.esm-316fec71.js";import"./Divider-71865361.js";import"./dividerClasses-f18f0f93.js";import"./FilterFilled-eb3492a9.js";import"./AntdIcon-f9724de9.js";import"./objectSpread2-e5f2d908.js";import"./index-1ceef347.js";import"./SelectComponent-aff7b03c.js";import"./Checkbox-fe0b2cdb.js";import"./SwitchBase-ad42caec.js";import"./Grow-6cc6748b.js";import"./DialogContent-a75c4d06.js";import"./DialogTitle-3c642f58.js";import"./DialogContentText-ab545101.js";import"./Grid2-78565a55.js";import"./isMuiElement-5c2699ea.js";import"./DialogActions-3c3ab24c.js";import"./componentStyles-7858e543.js";import"./TableRow-1c35ea2a.js";import"./TableContainer-98997305.js";import"./TableHead-95baa189.js";import"./TablePagination-81b30c1b.js";import"./KeyboardArrowRight-b7bab219.js";import"./Toolbar-25a41873.js";import"./MenuItem-26e66f0f.js";import"./listItemTextClasses-fcd068d2.js";import"./index-e5978b8b.js";const we=()=>{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),M=!!g,[m,V]=p.useState(null),b=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor",width:100},{title:"Action",width:100}];function z(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:O,reset:P}=te({resolver:ae(T),values:{search:r.search}}),k=(e,s)=>{V(s),u(e.currentTarget)},l=()=>{u(null)},B=e=>{a(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),l()},E=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=>k(N,e==null?void 0:e.id)}),t.jsx(ne,{id:m?String(m):void 0,open:M,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:()=>B(m),autoFocus:!0,children:"Yes"}),t.jsx(v,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return z(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)}),D=({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"),P({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:_(D),children:t.jsx(pe,{type:"text",sx:{width:"300px"},...O("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:b,rows:E,loading:y,page:r.page,pageSize:r.page_size,handleChangePage:F,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(re,{})]})};export{we as default};
