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-3141de2d.js";import{M as L}from"./MasterPageTitle-e75bb457.js";import{c as w,b as ee,u as te}from"./index.esm-8b0c9a99.js";import{o as ae}from"./yup-c2fea6fa.js";import{A as re}from"./add.vendorItems-50a1cfe0.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-f90cb72f.js";import{P as ne}from"./Select-369b8a03.js";import{T as pe}from"./TextField-ec161c03.js";import{I as de}from"./InputAdornment-1680248d.js";import"./index.esm-8b587a7a.js";import"./Divider-e779ddd3.js";import"./dividerClasses-752b2dd5.js";import"./FilterFilled-94ea2c05.js";import"./AntdIcon-eb0da2c9.js";import"./objectSpread2-41b8b8d3.js";import"./index-a3f870f6.js";import"./SelectComponent-90299b7f.js";import"./Checkbox-8808455f.js";import"./SwitchBase-416973c8.js";import"./Grow-e0aea29d.js";import"./DialogContent-17781b67.js";import"./DialogTitle-16416764.js";import"./DialogContentText-c64ca110.js";import"./Grid2-488bb30d.js";import"./isMuiElement-2bebf9f1.js";import"./DialogActions-37bf04e2.js";import"./componentStyles-24f97919.js";import"./TableRow-e26106d8.js";import"./TableContainer-e4a79220.js";import"./TableHead-6dad4842.js";import"./TablePagination-377a84d4.js";import"./KeyboardArrowRight-d5826f7e.js";import"./Toolbar-c1e97401.js";import"./MenuItem-d41bf2e5.js";import"./listItemTextClasses-5f5f8755.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};
