import{eh as S,b as j,a as B,ed as v,r as m,j as u,B as y}from"./index-60a3c753.js";import{T as A}from"./index-7e55cf46.js";import{T as F}from"./TopComponent-69eda74c.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 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};
