import{d as $,r as p,b4 as J,a as K,p1 as Y,b as q,j as t,B as G,pJ as H,pK as I,T as Q,R as v,pL as n,p3 as U,nB as W,_ as X,pM as Z}from"./index-858224db.js";import{M as L}from"./MasterPageTitle-cb9528e3.js";import{c as w,b as ee,u as te}from"./index.esm-241dec99.js";import{o as re}from"./yup-9213c3af.js";import{A as ae}from"./add.vendorItems-9f65eccb.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-d0523d92.js";import{P as ne}from"./Select-8b602eed.js";import{T as pe}from"./TextField-bbb2480f.js";import{I as me}from"./InputAdornment-583927e5.js";import"./index.esm-20949d74.js";import"./Divider-262150be.js";import"./dividerClasses-3bf2d765.js";import"./FilterFilled-4ddeca5a.js";import"./AntdIcon-8f3bee6f.js";import"./objectSpread2-cfd43bb2.js";import"./index-9223140c.js";import"./SelectComponent-e1904bd2.js";import"./createClass-042c577b.js";import"./Checkbox-57cdf644.js";import"./SwitchBase-959e94f2.js";import"./Grow-b7b43b3f.js";import"./DialogContent-e06a39bc.js";import"./DialogTitle-6e616d34.js";import"./DialogContentText-a2775ca2.js";import"./Grid2-274bb638.js";import"./isMuiElement-ec705bc2.js";import"./DialogActions-825c19e9.js";import"./componentStyles-107bd37e.js";import"./TableRow-ef998644.js";import"./TableContainer-0664e137.js";import"./TableHead-cf76ecee.js";import"./TablePagination-4cf72ac4.js";import"./KeyboardArrowRight-b25c72ab.js";import"./LastPage-c7260b25.js";import"./Toolbar-9be5abc1.js";import"./MenuItem-bf5218a0.js";import"./listItemTextClasses-ac0d77df.js";import"./listItemIconClasses-5ed9cb9d.js";import"./index-e5978b8b.js";const rt=()=>{const r=$(),[de,j]=p.useState(!1);p.useState("");const o=J(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:C,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=K(e=>({vendorItem:Y(e),system:q(e)})),[g,u]=p.useState(null),M=!!g,[d,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,m){return{index:e,code:s,item:c,vendor:h,actions:m}}let T=w({search:ee()});const{control:ge,handleSubmit:_,register:P,reset:B}=te({resolver:re(T),values:{search:a.search}}),O=(e,s)=>{V(s),u(e.currentTarget)},l=()=>{u(null)},E=e=>{r(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:a})),r(n({...a,search:"",page:1,page_size:10})),l()},k=S.map((e,s)=>{var m,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:N=>O(N,e==null?void 0:e.id)}),t.jsx(ne,{id:d?String(d):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:()=>E(d),autoFocus:!0,children:"Yes"}),t.jsx(v,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return z(c,e.code||"",((m=e==null?void 0:e.item)==null?void 0:m.name)||"",((f=e==null?void 0:e.vendor)==null?void 0:f.name)||"",h)}),D=({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)}))};p.useEffect(()=>{r(n({...a,search:"",page:1,page_size:10})),o==null||o.setTitle("VendorItem"),o==null||o.setSubtitle("Masters"),B({search:""})},[]);const x=e=>{r(U({})),r(I(0)),j(e),r(W(e))},R=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:_(D),children:t.jsx(pe,{type:"text",sx:{width:"300px"},...P("search"),size:"small",InputProps:{startAdornment:t.jsx(me,{position:"start",children:t.jsx(X,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R})}),children:t.jsx(oe,{count:C,columns:b,rows:k,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(ae,{})]})};export{rt as default};
