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-60a3c753.js";import{R as N}from"./ReadMoreText-0a164bab.js";import{T as O}from"./index-7e55cf46.js";import{T as U}from"./TopComponent-69eda74c.js";import"./Link-06c1146b.js";import"./DialogContent-89e21f2e.js";import"./DialogTitle-fe69da5c.js";import"./DialogActions-e754942c.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"./Menu-d1b7e1c3.js";import"./List-f567f8e4.js";import"./Grow-68442588.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./useControlled-194ef007.js";import"./MenuItem-2f410bd2.js";import"./dividerClasses-3fa67596.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./yup-92678dde.js";import"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-96c40dce.js";import"./index-900fa817.js";import"./InputLabel-71dfc9d4.js";/* empty css                   */import"./PageBreadCrumb-fcf1e00a.js";import"./PageMetaData-198e143e.js";import"./ScrollableList-1962b023.js";import"./Loader-466ccb5e.js";import"./index.esm-62d6b2f7.js";import"./TextField-32b29087.js";import"./FormControl-d13d2693.js";import"./FilterFilled-cdde02db.js";import"./AntdIcon-bed41c21.js";import"./objectSpread2-85813881.js";import"./presets-06d13753.js";import"./FilterOutlined-c131dc67.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};
