import{d as N,r as p,b6 as $,a as G,pG as Y,b as H,j as t,B as J,qm as K,qn as f,T as Q,R as v,qo as n,pI as U,oe as W,_ as X,qp as Z}from"./index-e6164346.js";import{M as L}from"./MasterPageTitle-fcafb323.js";import{c as w,b as ee,u as te}from"./index.esm-0a041314.js";import{o as re}from"./yup-5fd5d57b.js";import{A as ae}from"./add.vendorItems-d4ebb915.js";import{d as se}from"./Delete-5ebded29.js";import{e as ie}from"./Edit-abad5e84.js";import{C as oe}from"./index-cde536dd.js";import{P as ne}from"./Select-9c2d8cd2.js";import{T as pe}from"./TextField-db9cff08.js";import{I as me}from"./InputAdornment-59975edf.js";import"./index.esm-42924bf1.js";import"./Divider-6099014b.js";import"./dividerClasses-932c3e8b.js";import"./FilterFilled-c0851aaa.js";import"./AntdIcon-4f5aa87b.js";import"./objectSpread2-7d7378cc.js";import"./index-ce90e1a7.js";import"./SelectComponent-3cac02a3.js";import"./createClass-ad55a3ca.js";import"./Checkbox-70f568c2.js";import"./SwitchBase-e1f0b96b.js";import"./Grow-306e2fd0.js";import"./Dialog-2e8a8e2e.js";import"./DialogTitle-8757f50f.js";import"./DialogContent-f10d6731.js";import"./DialogContentText-027be15d.js";import"./Grid2-c9c87842.js";import"./isMuiElement-5779af4f.js";import"./DialogActions-31bec80e.js";import"./componentStyles-00385170.js";import"./TableRow-bf4e60a0.js";import"./TableContainer-7ecd96ea.js";import"./TableHead-0c525f54.js";import"./TablePagination-b02830fa.js";import"./KeyboardArrowRight-73af71dd.js";import"./LastPage-b9dcf78c.js";import"./Toolbar-82d22fac.js";import"./MenuItem-8dd174fb.js";import"./listItemTextClasses-6b253cb4.js";import"./listItemIconClasses-a58b491d.js";import"./index-e5978b8b.js";const at=()=>{const r=N(),[de,j]=p.useState(!1);p.useState("");const o=$(),{vendorItem:{vendorItemList:S,pageParams:a,loading:y,vendorItemCount:C,searchValue:le,masterValue:ce,masterEditId:he},system:{userAccessList:i}}=G(e=>({vendorItem:Y(e),system:H(e)})),[g,u]=p.useState(null),V=!!g,[d,b]=p.useState(null),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Item",width:100},{title:"Vendor",width:100},{title:"Action",width:100}];function M(e,s,c,h,m){return{index:e,code:s,item:c,vendor:h,actions:m}}let T=w({search:ee()});const{control:ge,handleSubmit:_,register:P,reset:O}=te({resolver:re(T),values:{search:a.search}}),B=(e,s)=>{b(s),u(e.currentTarget)},l=()=>{u(null)},E=e=>{r(Z({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:a})),r(n({...a,search:"",page:1,page_size:10})),l()},k=S.map((e,s)=>{var m,I;const c=(a.page-1)*a.page_size+(s+1),h=t.jsxs(J,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_vendoritem"))!==-1&&t.jsx("img",{src:ie,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{r(K({id:(e==null?void 0:e.id)||""})),x(!0),r(f(e==null?void 0:e.id))}}),(i==null?void 0:i.indexOf("Masters.delete_vendoritem"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:se,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:R=>B(R,e==null?void 0:e.id)}),t.jsx(ne,{id:d?String(d):void 0,open:V,anchorEl:g,onClose:l,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(v,{variant:"contained",type:"submit",color:"primary",onClick:()=>E(d),autoFocus:!0,children:"Yes"}),t.jsx(v,{variant:"outlined",size:"small",onClick:l,style:{marginLeft:"20px"},children:"No"})]})})]})]});return M(c,e.code||"",((m=e==null?void 0:e.item)==null?void 0:m.name)||"",((I=e==null?void 0:e.vendor)==null?void 0:I.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)}))};p.useEffect(()=>{r(n({...a,search:"",page:1,page_size:10})),o==null||o.setTitle("VendorItem"),o==null||o.setSubtitle("Masters"),O({search:""})},[]);const x=e=>{r(U({})),r(f(0)),j(e),r(W(e))},q=e=>{const s=e.target.value;r(n({...a,search:s||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsx(L,{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:"",searchComponent:t.jsx("form",{onSubmit:_(D),children:t.jsx(pe,{type:"text",sx:{width:"300px"},...P("search"),size:"small",InputProps:{startAdornment:t.jsx(me,{position:"start",children:t.jsx(X,{size:16})})},variant:"outlined",placeholder:"Search",onChange:q})}),children:t.jsx(oe,{count:C,columns:z,rows:k,loading:y,page:a.page,pageSize:a.page_size,handleChangePage:F,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(ae,{})]})};export{at as default};
