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-c5c88b67.js";import{M as L}from"./MasterPageTitle-405781d7.js";import{c as w,b as ee,u as te}from"./index.esm-81620445.js";import{o as ae}from"./yup-41605283.js";import{A as re}from"./add.vendorItems-30b8ccdf.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-e101df4a.js";import{P as ne}from"./Menu-e7d2b2ee.js";import{T as pe}from"./TextField-78388962.js";import{I as de}from"./InputAdornment-d66117f3.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./dividerClasses-6bc0ca72.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./SelectComponent-8c888daa.js";import"./createClass-fb49042e.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./Grid2-0ff60c92.js";import"./isMuiElement-b3c21f38.js";import"./DialogActions-1232a7fa.js";import"./Grow-7345f8ea.js";import"./componentStyles-a5e5a830.js";import"./TableRow-2b359fa8.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./MenuItem-81e44793.js";import"./listItemTextClasses-88792089.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),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{we as default};
