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-60a3c753.js";import{T as te}from"./index-7e55cf46.js";import{M as re}from"./MasterPageTitle-8a6edc29.js";import{u as ae}from"./index.esm-c494934a.js";import{o as se}from"./yup-92678dde.js";import{c as ie,b as oe}from"./index.esm-62d6b2f7.js";import{A as ne}from"./add.vendorItems-76154f83.js";import{P as me}from"./Menu-d1b7e1c3.js";import{T as pe}from"./TextField-32b29087.js";import{I as le}from"./InputAdornment-96c40dce.js";import"./TableContainer-414c12e0.js";import"./TableRow-0b33776c.js";import"./Skeleton-98c353d9.js";import"./index-a99c9f65.js";import"./useMediaQuery-dba48e3b.js";import"./TableHead-f864c753.js";import"./createSvgIcon-de433e5f.js";import"./TablePagination-218dde38.js";import"./Select-99fc0d84.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./List-f567f8e4.js";import"./useControlled-194ef007.js";import"./MenuItem-2f410bd2.js";import"./dividerClasses-3fa67596.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./index.esm-8ea8e217.js";import"./FilterFilled-cdde02db.js";import"./AntdIcon-bed41c21.js";import"./objectSpread2-85813881.js";import"./presets-06d13753.js";import"./SelectComponent-e431868e.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputLabel-71dfc9d4.js";import"./DialogContent-89e21f2e.js";import"./DialogTitle-fe69da5c.js";import"./DialogContentText-6688bd59.js";import"./Tooltip-88e63512.js";import"./Grow-68442588.js";import"./DialogActions-e754942c.js";import"./FormControl-d13d2693.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};
