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-0698dbe6.js";import{M as L}from"./MasterPageTitle-f4c9de66.js";import{c as w,b as ee,u as te}from"./index.esm-85d015f3.js";import{o as re}from"./yup-7a53beb8.js";import{A as ae}from"./add.vendorItems-caebedbd.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-98eb6c21.js";import{P as ne}from"./Select-371fc2c6.js";import{T as pe}from"./TextField-4222c766.js";import{I as me}from"./InputAdornment-0c2174b6.js";import"./index.esm-bda38eda.js";import"./Divider-eb09fdb8.js";import"./dividerClasses-2d12c750.js";import"./FilterFilled-b68f936d.js";import"./AntdIcon-ef833303.js";import"./objectSpread2-86ebda25.js";import"./index-c9a9ee7a.js";import"./SelectComponent-fbded912.js";import"./createClass-61c32f27.js";import"./Checkbox-987be799.js";import"./SwitchBase-6519d4d3.js";import"./Grow-ea87e600.js";import"./DialogContent-6dbfd908.js";import"./DialogTitle-a8d1726a.js";import"./DialogContentText-ceb40f80.js";import"./Grid2-a3850bef.js";import"./isMuiElement-d179539f.js";import"./DialogActions-318201e3.js";import"./componentStyles-91278318.js";import"./TableRow-2848b050.js";import"./TableContainer-99852104.js";import"./TableHead-0cf6a9bf.js";import"./TablePagination-a4795561.js";import"./KeyboardArrowRight-4fe4c481.js";import"./LastPage-1dfd52ba.js";import"./Toolbar-14560ae2.js";import"./MenuItem-aa4e2c66.js";import"./listItemTextClasses-d0728874.js";import"./listItemIconClasses-6eed47b3.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};
