import{b as Y,r as m,e8 as $,a as q,vR as G,h as K,j as t,B as Q,b2 as W,wq as H,wr as v,v as J,T as L,K as I,ws as n,vT as U,uT as X,Q as Z,Y as w,wt as ee}from"./index-43bf7a1c.js";import{T as te}from"./index-2d303f1d.js";import{M as re}from"./MasterPageTitle-e54f2b5e.js";import{u as ae}from"./index.esm-0548c843.js";import{o as se}from"./yup-3b80ed10.js";import{c as ie,b as oe}from"./index.esm-f9e0a906.js";import{A as ne}from"./add.vendorItems-057575ad.js";import{P as me}from"./Menu-362130d3.js";import{T as pe}from"./TextField-4da97115.js";import{I as le}from"./InputAdornment-b1a1aa58.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.js";import"./useMediaQuery-d6627623.js";import"./TableHead-fb4972c5.js";import"./createSvgIcon-f118be02.js";import"./TablePagination-9147f93d.js";import"./Select-44fd3147.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./List-6fcc4821.js";import"./useControlled-ab567149.js";import"./MenuItem-58b8887e.js";import"./dividerClasses-497df10c.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./index.esm-d1bd9bb6.js";import"./FilterFilled-ccc86e02.js";import"./AntdIcon-634507e8.js";import"./objectSpread2-c31b885b.js";import"./presets-bb9bdfd8.js";import"./SelectComponent-84e66b0a.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputLabel-6c7474f0.js";import"./DialogContent-d5902709.js";import"./DialogTitle-20dc6f66.js";import"./DialogContentText-abf03c9f.js";import"./Tooltip-c7371fbe.js";import"./Grow-ca573f65.js";import"./DialogActions-d63c6496.js";import"./FormControl-8d011aab.js";const st=()=>{const r=Y(),[de,j]=m.useState(!1);m.useState("");const o=$(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:T,searchValue:ce,masterValue:he,masterEditId:ue},system:{userAccessList:i}}=q(e=>({vendorItem:G(e),system:K(e)})),[u,g]=m.useState(null),b=!!u,[l,C]=m.useState(null),M=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor/OEM",width:100},{title:"Action",width:100}];function V(e,s,c,h,p){return{index:e,code:s,item:c,vendor:h,actions:p}}let z=ie({search:oe()});const{control:ge,handleSubmit:_,register:O,reset:P}=ae({resolver:se(z),values:{search:a.search}}),E=(e,s)=>{C(s),g(e.currentTarget)},d=()=>{g(null)},B=e=>{r(ee({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:a})),r(n({...a,search:"",page:1,page_size:10})),d()},k=S.map((e,s)=>{var p,f;const c=(a.page-1)*a.page_size+(s+1),h=t.jsxs(Q,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_vendoritem"))!==-1&&t.jsx(W,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{r(H({id:(e==null?void 0:e.id)||""})),x(!0),r(v(e==null?void 0:e.id))}}),(i==null?void 0:i.indexOf("Masters.delete_vendoritem"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(J,{style:{cursor:"pointer",color:"#fc6f03"},onClick:N=>E(N,e==null?void 0:e.id)}),t.jsx(me,{id:l?String(l):void 0,open:b,anchorEl:u,onClose:d,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(L,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(I,{variant:"contained",type:"submit",color:"primary",onClick:()=>B(l),autoFocus:!0,children:"Yes"}),t.jsx(I,{variant:"outlined",size:"small",onClick:d,style:{marginLeft:"20px"},children:"No"})]})})]})]});return V(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)}),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)}))};m.useEffect(()=>{r(n({...a,search:"",page:1,page_size:10})),o==null||o.setTitle("VendorItem"),o==null||o.setSubtitle("Masters"),P({search:""})},[]);const x=e=>{r(U({})),r(v(0)),j(e),r(X(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.jsxs(re,{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:"",children:[t.jsx("form",{action:"",onSubmit:_(D),children:t.jsx(Z,{container:!0,mb:2,children:t.jsx(pe,{type:"text",sx:{width:"500px"},...O("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(le,{position:"start",children:t.jsx(w,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:R})})}),t.jsx(te,{count:T,columns:M,rows:k,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A})]}),t.jsx(ne,{})]})};export{st as default};
