import{ek as y,b as E,a as F,is as R,r as u,j as p,B as T,c as k,J as A}from"./index-d2b25495.js";import{R as N}from"./ReadMoreText-df918569.js";import{T as O}from"./index-75fca24c.js";import{T as U}from"./TopComponent-23a44952.js";import"./Link-0d6c8639.js";import"./DialogContent-cded694d.js";import"./DialogTitle-a145b392.js";import"./DialogActions-7c802cc8.js";import"./TableContainer-dd7cf0ce.js";import"./TableRow-74f9cf3b.js";import"./Skeleton-1012c2e6.js";import"./index-1249dfe4.js";import"./useMediaQuery-b1fbc166.js";import"./TableHead-fac214d3.js";import"./createSvgIcon-e39ae511.js";import"./TablePagination-2c2a1682.js";import"./Select-ef36a2b2.js";import"./Menu-337a466b.js";import"./Grow-8719411b.js";import"./List-863f013e.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./useControlled-8d737f13.js";import"./MenuItem-2bdddad4.js";import"./dividerClasses-02a44d89.js";import"./listItemTextClasses-cadd4b00.js";import"./KeyboardArrowRight-7e978a8a.js";import"./yup-267e586f.js";import"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import"./index-709861af.js";import"./popper-f3391c26.js";import"./InputAdornment-d0c3ebef.js";import"./index-38f860bc.js";import"./InputLabel-bb6ab40e.js";/* empty css                   */import"./PageBreadCrumb-02480d86.js";import"./PageMetaData-7797a3b7.js";import"./ScrollableList-fc1de312.js";import"./Loader-1b927baf.js";import"./index.esm-3043d6d4.js";import"./TextField-e155d2be.js";import"./FormControl-73683015.js";import"./FilterFilled-4dfce120.js";import"./AntdIcon-8449be55.js";import"./objectSpread2-b41ee31b.js";import"./FilterOutlined-653b7cb0.js";const Rt=()=>{var I;const{id:g}=y();E();const{leads:{selectedData:e},system:{userAccessList:r}}=F(s=>R(s)),[i,h]=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(s,n,a,t,o,m,l){return{index:s,name:n,code:a,quantity:t,unit:o,vendor:m,specifications:l}}const _=u.useMemo(()=>{if(!d)return[];const s=(i.page-1)*i.page_size,n=s+i.page_size;return d.slice(s,n).map((t,o)=>{var j,L,z,C;const m=s+(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=(s,n)=>{h({...i,page:n+1})},B=s=>{h({...i,page_size:parseInt(s.target.value)})},M=({search:s})=>{var n;if(s&&s!=""){const a=(n=e==null?void 0:e.lead_items)==null?void 0:n.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(s.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/"+g,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/"+g,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};
