import{ek as S,b as j,a as B,eg as v,r as m,j as u,B as y}from"./index-d2b25495.js";import{T as A}from"./index-75fca24c.js";import{T as F}from"./TopComponent-23a44952.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 zt=()=>{var l;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 g(r,n,o,i){return{index:r,name:n,code:o,quantity:i}}const f=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 h,_,x;const L=r+(d+1);return g(L,(h=i==null?void 0:i.tenderitemmaster)!=null&&h.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:"")})},[g,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:((l=t.tender_items)==null?void 0:l.length)??0,columns:c,rows:f||[],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};
