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-def636a4.js";import{T as te}from"./index-fc769754.js";import{M as re}from"./MasterPageTitle-bbea54a4.js";import{u as ae}from"./index.esm-7d9d1491.js";import{o as se}from"./yup-c8535458.js";import{c as ie,b as oe}from"./index.esm-eec4f448.js";import{A as ne}from"./add.vendorItems-3f34af82.js";import{P as me}from"./Menu-af49d134.js";import{T as pe}from"./TextField-2ba95a45.js";import{I as le}from"./InputAdornment-196a5386.js";import"./TableContainer-5944247b.js";import"./TableRow-2c544f58.js";import"./Skeleton-5cf57ed1.js";import"./index-b5a6fbe3.js";import"./useMediaQuery-4304fb25.js";import"./TableHead-f0476938.js";import"./createSvgIcon-ff487f53.js";import"./TablePagination-7d3b42e9.js";import"./Select-2cfb5afd.js";import"./OutlinedInput-ddb8bb3f.js";import"./useFormControl-880b2f7b.js";import"./List-17cd485b.js";import"./useControlled-bd643819.js";import"./MenuItem-8fdd2340.js";import"./dividerClasses-2b953c2a.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./index.esm-c912dbcd.js";import"./FilterFilled-08c5b5a7.js";import"./AntdIcon-34324527.js";import"./objectSpread2-a4d0f5f6.js";import"./presets-dbb0f3bf.js";import"./SelectComponent-cea9b89b.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputLabel-e2e73b27.js";import"./DialogContent-0cb684b3.js";import"./DialogTitle-e2e75924.js";import"./DialogContentText-b2259947.js";import"./Tooltip-762a58b6.js";import"./Grow-85576dd3.js";import"./DialogActions-c4045764.js";import"./FormControl-1f811046.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};
