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