import{b as Y,r as l,e8 as $,a as G,vM as K,h as Q,j as t,B as W,b2 as q,wl as H,wm as v,v as J,T as L,K as I,wn as n,vO as U,uO as X,Q as Z,Y as w,wo as ee}from"./index-76d4793e.js";import{T as te}from"./index-1fae9bc3.js";import{M as re}from"./MasterPageTitle-e8b467fa.js";import{u as ae}from"./index.esm-3adfd9f7.js";import{o as se}from"./yup-688ec4f6.js";import{c as ie,b as oe}from"./index.esm-ad8a7c9f.js";import{A as ne}from"./add.vendorItems-888e0bd3.js";import{P as le}from"./Menu-ed7c6894.js";import{T as me}from"./TextField-9c64a4a2.js";import{I as pe}from"./InputAdornment-b99403ce.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.js";import"./useMediaQuery-8cb39c65.js";import"./TableHead-c6031541.js";import"./createSvgIcon-01ec10fc.js";import"./TablePagination-5e47b2d0.js";import"./Select-338083eb.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./List-4c24b3e8.js";import"./useControlled-e03384de.js";import"./MenuItem-cff1abce.js";import"./dividerClasses-45958eb8.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./index.esm-d9f89842.js";import"./FilterFilled-aa7d40e4.js";import"./AntdIcon-55dc1b5f.js";import"./objectSpread2-51b6810f.js";import"./SelectComponent-3c1140e6.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputLabel-5ed57f0e.js";import"./DialogContent-7bd8dd8f.js";import"./DialogTitle-71dd5b3a.js";import"./DialogContentText-7642f81f.js";import"./Tooltip-0a59b9eb.js";import"./Grow-84b30c0e.js";import"./DialogActions-5a5e1db9.js";import"./FormControl-c671c595.js";const at=()=>{const r=Y(),[de,j]=l.useState(!1);l.useState("");const o=$(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:M,searchValue:ce,masterValue:he,masterEditId:ue},system:{userAccessList:i}}=G(e=>({vendorItem:K(e),system:Q(e)})),[u,g]=l.useState(null),b=!!u,[p,C]=l.useState(null),V=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor/OEM",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=ie({search:oe()});const{control:ge,handleSubmit:O,register:_,reset:P}=ae({resolver:se(T),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 m,f;const c=(a.page-1)*a.page_size+(s+1),h=t.jsxs(W,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_vendoritem"))!==-1&&t.jsx(q,{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(le,{id:p?String(p):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(p),autoFocus:!0,children:"Yes"}),t.jsx(I,{variant:"outlined",size:"small",onClick:d,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)}))};l.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:O(D),children:t.jsx(Z,{container:!0,mb:2,children:t.jsx(me,{type:"text",sx:{width:"500px"},..._("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(pe,{position:"start",children:t.jsx(w,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:R})})}),t.jsx(te,{count:M,columns:V,rows:k,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A})]}),t.jsx(ne,{})]})};export{at as default};
