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-def636a4.js";import{R as N}from"./ReadMoreText-bd8c59ed.js";import{T as O}from"./index-fc769754.js";import{T as U}from"./TopComponent-7f7c384d.js";import"./Link-bb09d70c.js";import"./DialogContent-0cb684b3.js";import"./DialogTitle-e2e75924.js";import"./DialogActions-c4045764.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"./Menu-af49d134.js";import"./List-17cd485b.js";import"./Grow-85576dd3.js";import"./OutlinedInput-ddb8bb3f.js";import"./useFormControl-880b2f7b.js";import"./useControlled-bd643819.js";import"./MenuItem-8fdd2340.js";import"./dividerClasses-2b953c2a.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./yup-c8535458.js";import"./index.esm-7d9d1491.js";import"./componentStyles-41382c67.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-196a5386.js";import"./index-f48c8aa0.js";import"./InputLabel-e2e73b27.js";/* empty css                   */import"./PageBreadCrumb-816019c3.js";import"./PageMetaData-0f9457e5.js";import"./ScrollableList-a550bc32.js";import"./Loader-16c57fae.js";import"./index.esm-eec4f448.js";import"./TextField-2ba95a45.js";import"./FormControl-1f811046.js";import"./FilterFilled-08c5b5a7.js";import"./AntdIcon-34324527.js";import"./objectSpread2-a4d0f5f6.js";import"./presets-dbb0f3bf.js";import"./FilterOutlined-03ee9578.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};
