import{d as N,r as m,b7 as Y,a as $,qW as W,b as G,j as t,B as H,rC as J,rD as I,T as K,R as v,rE as n,qY as Q,ps as U,_ as X,rF as Z}from"./index-e79f7aad.js";import{M as L}from"./MasterPageTitle-a4f02d02.js";import{c as w,b as ee,u as te}from"./index.esm-1ca67d65.js";import{o as re}from"./yup-96f14780.js";import{A as ae}from"./add.vendorItems-9b82325d.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-b81f2313.js";import{P as ne}from"./Select-8a61e5a6.js";import{T as me}from"./TextField-21e22d39.js";import{I as pe}from"./InputAdornment-d42c17cd.js";import"./index.esm-05058101.js";import"./Divider-d5c2dff6.js";import"./dividerClasses-691b251c.js";import"./FilterFilled-8d538f67.js";import"./AntdIcon-1cfbd840.js";import"./objectSpread2-d56e1476.js";import"./index-310d07a1.js";import"./SelectComponent-1ba596ac.js";import"./createClass-b86a4c8d.js";import"./Checkbox-b895334d.js";import"./SwitchBase-e7cea42d.js";import"./DialogContent-6a297cef.js";import"./DialogTitle-62595023.js";import"./DialogContentText-0c5306f9.js";import"./Grid2-7786e458.js";import"./isMuiElement-db2b7d4c.js";import"./DialogActions-edd1d02f.js";import"./LastPage-33ac3f68.js";import"./TableRow-0ea91e40.js";import"./KeyboardArrowRight-285caa9b.js";import"./componentStyles-7718fc5e.js";import"./TableContainer-00013c19.js";import"./TableHead-1f8b658d.js";import"./TablePagination-6f9f31d4.js";import"./KeyboardArrowRight-4ee9435c.js";import"./LastPage-1ca2417e.js";import"./Toolbar-d2cd5725.js";import"./MenuItem-c14df0e9.js";import"./listItemTextClasses-d3a968ad.js";import"./listItemIconClasses-03011ebf.js";import"./index-e5978b8b.js";const at=()=>{const r=N(),[de,j]=m.useState(!1);m.useState("");const o=Y(),{vendorItem:{vendorItemList:S,pageParams:a,loading:C,vendorItemCount:y,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=$(e=>({vendorItem:W(e),system:G(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:_,register:P,reset:E}=te({resolver:re(T),values:{search:a.search}}),O=(e,s)=>{b(s),u(e.currentTarget)},l=()=>{u(null)},B=e=>{r(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:a})),r(n({...a,search:"",page:1,page_size:10})),l()},D=S.map((e,s)=>{var p,f;const c=(a.page-1)*a.page_size+(s+1),h=t.jsxs(H,{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(J({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:q=>O(q,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(K,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(v,{variant:"contained",type:"submit",color:"primary",onClick:()=>B(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)}),F=({search:e})=>{r(n({...a,search:e||"",page:1,page_size:10}))},k=(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"),E({search:""})},[]);const x=e=>{r(Q({})),r(I(0)),j(e),r(U(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:_(F),children:t.jsx(me,{type:"text",sx:{width:"300px"},...P("search"),size:"small",InputProps:{startAdornment:t.jsx(pe,{position:"start",children:t.jsx(X,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R})}),children:t.jsx(oe,{count:y,columns:z,rows:D,loading:C,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(ae,{})]})};export{at as default};
