import{b as N,r as m,eb as Y,a as $,vR as J,g as W,j as t,B as q,b2 as H,wD as K,wE as v,t as L,T as Q,J as I,wF as n,vT as U,uT as X,P as Z,Y as w,wG as ee}from"./index-d2b25495.js";import{T as te}from"./index-75fca24c.js";import{M as re}from"./MasterPageTitle-86504016.js";import{u as ae}from"./index.esm-ce3c2c20.js";import{o as se}from"./yup-267e586f.js";import{c as ie,b as oe}from"./index.esm-3043d6d4.js";import{A as ne}from"./add.vendorItems-c02fdabb.js";import{P as me}from"./Menu-337a466b.js";import{T as pe}from"./TextField-e155d2be.js";import{I as le}from"./InputAdornment-d0c3ebef.js";import"./TableContainer-dd7cf0ce.js";import"./TableRow-74f9cf3b.js";import"./Skeleton-1012c2e6.js";import"./index-1249dfe4.js";import"./useMediaQuery-b1fbc166.js";import"./TableHead-fac214d3.js";import"./createSvgIcon-e39ae511.js";import"./TablePagination-2c2a1682.js";import"./Select-ef36a2b2.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./useControlled-8d737f13.js";import"./MenuItem-2bdddad4.js";import"./List-863f013e.js";import"./dividerClasses-02a44d89.js";import"./listItemTextClasses-cadd4b00.js";import"./KeyboardArrowRight-7e978a8a.js";import"./index.esm-0ec21729.js";import"./FilterFilled-4dfce120.js";import"./AntdIcon-8449be55.js";import"./objectSpread2-b41ee31b.js";import"./index-709861af.js";import"./SelectComponent-d286bfef.js";import"./InputLabel-bb6ab40e.js";import"./DialogContent-cded694d.js";import"./DialogTitle-a145b392.js";import"./DialogContentText-43575e44.js";import"./Tooltip-82372cdb.js";import"./popper-f3391c26.js";import"./Grow-8719411b.js";import"./DialogActions-7c802cc8.js";import"./FormControl-73683015.js";const st=()=>{const r=N(),[de,j]=m.useState(!1);m.useState("");const o=Y(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:b,searchValue:ce,masterValue:he,masterEditId:ue},system:{userAccessList:i}}=$(e=>({vendorItem:J(e),system:W(e)})),[u,g]=m.useState(null),T=!!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:P,register:_,reset:E}=ae({resolver:se(z),values:{search:a.search}}),O=(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()},D=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(H,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{r(K({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(L,{style:{cursor:"pointer",color:"#fc6f03"},onClick:G=>O(G,e==null?void 0:e.id)}),t.jsx(me,{id:l?String(l):void 0,open:T,anchorEl:u,onClose:d,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(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)}),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(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:P(F),children:t.jsx(Z,{container:!0,mb:2,children:t.jsx(pe,{type:"text",sx:{width:"500px"},..._("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:b,columns:M,rows:D,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:A})]}),t.jsx(ne,{})]})};export{st as default};
