import{eh as S,b as j,a as B,ed as v,r as m,j as u,B as y}from"./index-43bf7a1c.js";import{T as A}from"./index-2d303f1d.js";import{T as F}from"./TopComponent-6b8acdbd.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 zt=()=>{var h;const{id:I}=S();j();const{system:{userAccessList:E},tenders:{selectedData:t}}=B(r=>v(r)),[p,s]=m.useState(t!=null&&t.tender_items?t==null?void 0:t.tender_items:[]),[e,a]=m.useState({page:1,page_size:10});m.useEffect(()=>{t!=null&&t.tender_items&&s(t==null?void 0:t.tender_items)},[t==null?void 0:t.tender_items]);const c=[{title:"S.No",width:100},{title:"Item",width:100},{title:"Item Code",width:100},{title:"Quantity",width:100}];function f(r,n,o,i){return{index:r,name:n,code:o,quantity:i}}const g=m.useMemo(()=>{if(!p)return[];const r=(e.page-1)*e.page_size,n=r+e.page_size;return p.slice(r,n).map((i,d)=>{var l,_,x;const L=r+(d+1);return f(L,(l=i==null?void 0:i.tenderitemmaster)!=null&&l.label?(_=i==null?void 0:i.tenderitemmaster)==null?void 0:_.label:"",((x=i==null?void 0:i.tenderitemmaster)==null?void 0:x.code)??"",i.quantity?i.quantity:"")})},[f,p,e,t]),C=(r,n)=>{a({...e,page:n+1})},z=r=>{a({...e,page_size:parseInt(r.target.value)})},T=({search:r})=>{var n;if(r&&r!=""){const o=(n=t==null?void 0:t.tender_items)==null?void 0:n.filter(i=>i.tenderitemmaster.label.toLowerCase().startsWith(r.toLowerCase()));s(o||[])}else s(t!=null&&t.tender_items?t==null?void 0:t.tender_items:[])},b=r=>{var o;const n=r.target.value;if(n&&n!=""){const i=(o=t==null?void 0:t.tender_items)==null?void 0:o.filter(d=>d.tenderitemmaster.label.toLowerCase().startsWith(n.toLowerCase()));s(i||[])}else s(t!=null&&t.tender_items?t==null?void 0:t.tender_items:[])};return u.jsxs(y,{children:[u.jsx(F,{permissionPreFix:"TenderManagement",permissionPostFix:"tenderitem",navigateLink:"/tenders/"+I,showAddButton:!1,showFilterButton:!1,addButtonName:"Update Items",handleInputChange:b,handleSearch:T,filteredData:e}),u.jsx(A,{count:((h=t.tender_items)==null?void 0:h.length)??0,columns:c,rows:g||[],loading:!1,page:e!=null&&e.page?e==null?void 0:e.page:1,pageSize:e!=null&&e.page_size?e==null?void 0:e.page_size:10,handleChangePage:C,handleChangeRowsPerPage:z})]})};export{zt as default};
