import{eh as y,b as E,a as F,iC as R,r as u,j as p,B as T,c as k,K as A}from"./index-43bf7a1c.js";import{R as N}from"./ReadMoreText-bbfb5d42.js";import{T as O}from"./index-2d303f1d.js";import{T as U}from"./TopComponent-6b8acdbd.js";import"./Link-cc44beed.js";import"./DialogContent-d5902709.js";import"./DialogTitle-20dc6f66.js";import"./DialogActions-d63c6496.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.js";import"./useMediaQuery-d6627623.js";import"./TableHead-fb4972c5.js";import"./createSvgIcon-f118be02.js";import"./TablePagination-9147f93d.js";import"./Select-44fd3147.js";import"./Menu-362130d3.js";import"./List-6fcc4821.js";import"./Grow-ca573f65.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./useControlled-ab567149.js";import"./MenuItem-58b8887e.js";import"./dividerClasses-497df10c.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./yup-3b80ed10.js";import"./index.esm-0548c843.js";import"./componentStyles-4624000e.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-b1a1aa58.js";import"./index-913b2dc6.js";import"./InputLabel-6c7474f0.js";/* empty css                   */import"./PageBreadCrumb-9a31a3c1.js";import"./PageMetaData-7350980e.js";import"./ScrollableList-e19132c3.js";import"./Loader-aabe9ed3.js";import"./index.esm-f9e0a906.js";import"./TextField-4da97115.js";import"./FormControl-8d011aab.js";import"./FilterFilled-ccc86e02.js";import"./AntdIcon-634507e8.js";import"./objectSpread2-c31b885b.js";import"./presets-bb9bdfd8.js";import"./FilterOutlined-908c8e25.js";const Rt=()=>{var I;const{id:h}=y();E();const{leads:{selectedData:e},system:{userAccessList:r}}=F(n=>R(n)),[i,g]=u.useState({page:1,page_size:10}),[d,f]=u.useState(e!=null&&e.lead_items?e==null?void 0:e.lead_items:[]),S=[{title:"S.No",width:100},{title:"Item",width:100},{title:"Item Code",width:100},{title:"Quantity",width:100},{title:"Unit",width:100},{title:"Vendor/OEM",width:100},{title:"Specifications",width:100}];function x(n,s,a,t,o,m,l){return{index:n,name:s,code:a,quantity:t,unit:o,vendor:m,specifications:l}}const _=u.useMemo(()=>{if(!d)return[];const n=(i.page-1)*i.page_size,s=n+i.page_size;return d.slice(n,s).map((t,o)=>{var j,L,z,C;const m=n+(o+1),l=p.jsx(N,{text:t!=null&&t.item_specifications?t==null?void 0:t.item_specifications:"",maxLength:30}),b=(j=t==null?void 0:t.vendors)==null?void 0:j.map(c=>c==null?void 0:c.name).join(", ");return x(m,((L=t==null?void 0:t.item)==null?void 0:L.label)||"",((z=t==null?void 0:t.item)==null?void 0:z.code)||"",(t==null?void 0:t.quantity)||"",((C=t==null?void 0:t.unit)==null?void 0:C.name)||"",b||"",l)})},[x,d,i]),v=(n,s)=>{g({...i,page:s+1})},B=n=>{g({...i,page_size:parseInt(n.target.value)})},M=({search:n})=>{var s;if(n&&n!=""){const a=(s=e==null?void 0:e.lead_items)==null?void 0:s.filter(t=>{var o,m;return(m=(o=t==null?void 0:t.item)==null?void 0:o.label)==null?void 0:m.toLowerCase().startsWith(n.toLowerCase())});f(a||[])}else f(e!=null&&e.lead_items?e==null?void 0:e.lead_items:[])};return p.jsxs(T,{children:[p.jsx(U,{permissionPreFix:"LeadManagement",permissionPostFix:"lead",navigateLink:"/tenders/"+h,showAddButton:!1,showFilterButton:!1,addButtonName:"Update Items",handleSearch:M,filteredData:i,children:(r==null?void 0:r.indexOf("LeadManagement.change_leaditem"))!==-1&&p.jsx(k,{to:"/leads/"+h,children:p.jsx(A,{variant:"outlined",color:"primary",size:"large",children:"Edit Lead Items"})})}),p.jsx(O,{count:((I=e==null?void 0:e.lead_items)==null?void 0:I.length)??0,columns:S,rows:_||[],loading:!1,page:i!=null&&i.page?i==null?void 0:i.page:1,pageSize:i!=null&&i.page_size?i==null?void 0:i.page_size:10,handleChangePage:v,handleChangeRowsPerPage:B})]})};export{Rt as default};
