import{d as $,r as m,b8 as Q,a as U,r5 as Y,b as q,j as t,B as G,rN as H,rO as I,T as J,U as v,rP as n,r7 as K,pD as W,$ as X,rQ as Z}from"./index-60657852.js";import{M as L}from"./MasterPageTitle-4d4d4430.js";import{c as w,b as ee,u as te}from"./index.esm-509a598d.js";import{o as re}from"./yup-75ad371b.js";import{A as ae}from"./add.vendorItems-ea1ed26b.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-61d7dc47.js";import{P as ne}from"./Select-7d2a5359.js";import{T as me}from"./TextField-6b778b78.js";import{I as pe}from"./InputAdornment-12fc79ce.js";import"./index.esm-5fae0aa9.js";import"./Divider-6555f8d4.js";import"./dividerClasses-590294d7.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./SelectComponent-7b1a8800.js";import"./createClass-2b895736.js";import"./Checkbox-026acf65.js";import"./SwitchBase-3b306fc6.js";import"./Grow-a21bdd26.js";import"./DialogContent-d5183bd6.js";import"./DialogTitle-66c21479.js";import"./DialogContentText-e3f3f7dd.js";import"./Grid2-09163d35.js";import"./isMuiElement-82a67859.js";import"./DialogActions-1dfa5a01.js";import"./LastPage-71f2133b.js";import"./TableRow-0ab1e69a.js";import"./KeyboardArrowRight-450d5bb8.js";import"./componentStyles-19763afb.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";const at=()=>{const r=$(),[de,j]=m.useState(!1);m.useState("");const o=Q(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:C,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=U(e=>({vendorItem:Y(e),system:q(e)})),[g,u]=m.useState(null),V=!!g,[d,b]=m.useState(null),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor",width:100},{title:"Action",width:100}];function M(e,s,c,h,p){return{index:e,code:s,item:c,vendor:h,actions:p}}let T=w({search:ee()});const{control:ge,handleSubmit:P,register:_,reset:O}=te({resolver:re(T),values:{search:a.search}}),B=(e,s)=>{b(s),u(e.currentTarget)},l=()=>{u(null)},D=e=>{r(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:a})),r(n({...a,search:"",page:1,page_size:10})),l()},E=S.map((e,s)=>{var p,f;const c=(a.page-1)*a.page_size+(s+1),h=t.jsxs(G,{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:()=>{r(H({id:(e==null?void 0:e.id)||""})),x(!0),r(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:R=>B(R,e==null?void 0:e.id)}),t.jsx(ne,{id:d?String(d):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(J,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(v,{variant:"contained",type:"submit",color:"primary",onClick:()=>D(d),autoFocus:!0,children:"Yes"}),t.jsx(v,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return M(c,e.code||"",((p=e==null?void 0:e.item)==null?void 0:p.name)||"",((f=e==null?void 0:e.vendor)==null?void 0:f.name)||"",h)}),k=({search:e})=>{r(n({...a,search:e||"",page:1,page_size:10}))},F=(e,s)=>{r(n({...a,search:"",page:s+1}))},A=e=>{r(n({...a,search:"",page:1,page_size:parseInt(e.target.value)}))};m.useEffect(()=>{r(n({...a,search:"",page:1,page_size:10})),o==null||o.setTitle("VendorItem"),o==null||o.setSubtitle("Masters"),O({search:""})},[]);const x=e=>{r(K({})),r(I(0)),j(e),r(W(e))},N=e=>{const s=e.target.value;r(n({...a,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:P(k),children:t.jsx(me,{type:"text",sx:{width:"300px"},..._("search"),size:"small",InputProps:{startAdornment:t.jsx(pe,{position:"start",children:t.jsx(X,{size:16})})},variant:"outlined",placeholder:"Search",onChange:N})}),children:t.jsx(oe,{count:C,columns:z,rows:E,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(ae,{})]})};export{at as default};
