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-4dfc510b.js";import{M as L}from"./MasterPageTitle-68cbcd9e.js";import{c as w,b as ee,u as te}from"./index.esm-0a454763.js";import{o as ae}from"./yup-80def618.js";import{A as re}from"./add.vendorItems-983563ce.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-71406b65.js";import{P as ne}from"./Menu-0f556e12.js";import{T as pe}from"./TextField-c0d4022e.js";import{I as de}from"./InputAdornment-ccd6e8ff.js";import"./index.esm-337179d9.js";import"./Divider-1794f57d.js";import"./dividerClasses-26c2a6d6.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./SelectComponent-bfde3322.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./Grid2-713975b3.js";import"./isMuiElement-7be61a21.js";import"./DialogActions-49286e71.js";import"./Grow-a7315f12.js";import"./componentStyles-df94248d.js";import"./TableRow-bee40746.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./MenuItem-9737e3d9.js";import"./listItemTextClasses-e85f7ff0.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};
