import{eh as S,b as j,a as B,ed as v,r as m,j as u,B as y}from"./index-76d4793e.js";import{T as A}from"./index-1fae9bc3.js";import{T as F}from"./TopComponent-82b1f250.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 Ct=()=>{var h;const{id:I}=S();j();const{system:{userAccessList:E},tenders:{selectedData:t}}=B(r=>v(r)),[p,o]=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&&o(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,s,i){return{index:r,name:n,code:s,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 s=(n=t==null?void 0:t.tender_items)==null?void 0:n.filter(i=>i.tenderitemmaster.label.toLowerCase().startsWith(r.toLowerCase()));o(s||[])}else o(t!=null&&t.tender_items?t==null?void 0:t.tender_items:[])},b=r=>{var s;const n=r.target.value;if(n&&n!=""){const i=(s=t==null?void 0:t.tender_items)==null?void 0:s.filter(d=>d.tenderitemmaster.label.toLowerCase().startsWith(n.toLowerCase()));o(i||[])}else o(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{Ct as default};
