import{d as N,r as p,b6 as $,a as H,pH as J,b as Y,j as t,B as G,qn as K,qo as I,T as Q,R as v,qp as n,pJ as U,of as W,_ as X,qq as Z}from"./index-aa25c5ff.js";import{M as L}from"./MasterPageTitle-4b4774f8.js";import{c as w,b as ee,u as te}from"./index.esm-a7f661dc.js";import{o as re}from"./yup-72cc4918.js";import{A as ae}from"./add.vendorItems-038429da.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-06082cde.js";import{P as ne}from"./Select-b8388c2f.js";import{T as pe}from"./TextField-55b66d20.js";import{I as me}from"./InputAdornment-1e7eea92.js";import"./index.esm-def27a11.js";import"./Divider-52e89c7e.js";import"./dividerClasses-ce522944.js";import"./FilterFilled-8e291e82.js";import"./AntdIcon-b92b7162.js";import"./objectSpread2-f5b2f6aa.js";import"./index-d4b36417.js";import"./SelectComponent-8b6a2019.js";import"./createClass-d1bae5ec.js";import"./Checkbox-d917a1e2.js";import"./SwitchBase-f1314509.js";import"./Grow-53c7e965.js";import"./Dialog-049271f6.js";import"./DialogTitle-7a3842b8.js";import"./DialogContent-f207f33c.js";import"./DialogContentText-70face94.js";import"./Grid2-d00e0f6a.js";import"./isMuiElement-1b254892.js";import"./DialogActions-2338d733.js";import"./componentStyles-e32842f3.js";import"./TableRow-ee82d902.js";import"./TableContainer-150455ba.js";import"./TableHead-7918647e.js";import"./TablePagination-7f533723.js";import"./KeyboardArrowRight-207c2b3b.js";import"./LastPage-cc741249.js";import"./Toolbar-aae1a453.js";import"./MenuItem-6f39aa2e.js";import"./listItemTextClasses-88140258.js";import"./listItemIconClasses-31a870c1.js";import"./index-e5978b8b.js";const at=()=>{const r=N(),[de,j]=p.useState(!1);p.useState("");const o=$(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:C,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=H(e=>({vendorItem:J(e),system:Y(e)})),[g,u]=p.useState(null),V=!!g,[d,b]=p.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,m){return{index:e,code:s,item:c,vendor:h,actions:m}}let T=w({search:ee()});const{control:ge,handleSubmit:_,register:P,reset:O}=te({resolver:re(T),values:{search:a.search}}),B=(e,s)=>{b(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(K({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(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 M(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}))},q=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"),O({search:""})},[]);const x=e=>{r(U({})),r(I(0)),j(e),r(W(e))},A=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:A})}),children:t.jsx(oe,{count:C,columns:z,rows:k,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:q,showPagination:!0})}),t.jsx(ae,{})]})};export{at as default};
