import{eh as y,b as E,a as F,ip as R,r as u,j as p,B as T,c as k,K as A}from"./index-76d4793e.js";import{R as N}from"./ReadMoreText-881d8c17.js";import{T as O}from"./index-1fae9bc3.js";import{T as U}from"./TopComponent-82b1f250.js";import"./Link-14b4f0c1.js";import"./DialogContent-7bd8dd8f.js";import"./DialogTitle-71dd5b3a.js";import"./DialogActions-5a5e1db9.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.js";import"./useMediaQuery-8cb39c65.js";import"./TableHead-c6031541.js";import"./createSvgIcon-01ec10fc.js";import"./TablePagination-5e47b2d0.js";import"./Select-338083eb.js";import"./Menu-ed7c6894.js";import"./List-4c24b3e8.js";import"./Grow-84b30c0e.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./useControlled-e03384de.js";import"./MenuItem-cff1abce.js";import"./dividerClasses-45958eb8.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./yup-688ec4f6.js";import"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-b99403ce.js";import"./index-ecea5cfc.js";import"./InputLabel-5ed57f0e.js";/* empty css                   */import"./PageBreadCrumb-465f4085.js";import"./PageMetaData-e5080ba8.js";import"./ScrollableList-4dae3697.js";import"./Loader-9f443a4c.js";import"./index.esm-ad8a7c9f.js";import"./TextField-9c64a4a2.js";import"./FormControl-c671c595.js";import"./FilterFilled-aa7d40e4.js";import"./AntdIcon-55dc1b5f.js";import"./objectSpread2-51b6810f.js";import"./FilterOutlined-91aa15e3.js";const Ft=()=>{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{Ft as default};
