import{eh as I,F as w,b as A,a as L,hw as G,r as m,hE as T,hx as h,j as s,B as F,_ as M,Q as N,K as R,ep as U,hC as $,i5 as _}from"./index-43bf7a1c.js";import{G as K}from"./GoBack-7b84c382.js";import{T as Q}from"./index-2d303f1d.js";import{C as Z}from"./Checkbox-b7a88fca.js";import{C as q}from"./CardContent-69a98a60.js";import"./Divider-c942d994.js";import"./dividerClasses-497df10c.js";import"./LoadingButton-570cb73d.js";import"./index-913b2dc6.js";import"./useMediaQuery-d6627623.js";import"./useControlled-ab567149.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.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"./MenuItem-58b8887e.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./SwitchBase-75578ec7.js";const ye=()=>{var x,C,j,k;const{tenderId:u,documentId:c,tab:v}=I();w();const o=A(),{document:{documentList:D,pageParams:r,selectedData:y,checkedList:i},mini:{miniDocuments:e},system:{userAccessList:H}}=L(t=>G(t)),P=()=>{i.length===0?U.fire({title:'<p style="font-size:20px">Zero Documents Selected</p>',text:"Atleast select one document",icon:"info",confirmButtonText:"Close",confirmButtonColor:"#3085d6"}):o($({id:c||"",data:{tender_id:u,document_ids:i},params:r,clearData:()=>{}}))},b=(t,a,n)=>{if(n)o(_([...i,t]));else{const p=i.filter(d=>d!=t);o(_(p))}};m.useEffect(()=>{o(T({id:c}))},[]),m.useEffect(()=>{o(h({page:1,page_size:10,search:""}))},[]);const B=[{title:"S.No",width:100},{title:"Document",width:100},{title:"Is Checked",width:100}];function g(t,a,n){return{index:t,document:a,yesCheck:n}}const f=m.useMemo(()=>{var t;return(t=e==null?void 0:e.list)==null?void 0:t.map((a,n)=>{const p=(r.page-1)*r.page_size+(n+1),d=a==null?void 0:a.name,E=s.jsx(Z,{checked:!!i.find(l=>l==a.id),onChange:l=>b(a.id,"yes",l.target.checked)});return g(p,d,E)})},[e,y,g]),z=(t,a)=>{o(h({...r,search:"",page:a+1}))},S=t=>{o(h({...r,search:"",page:1,page_size:parseInt(t.target.value)}))};return s.jsx("div",{children:s.jsx(F,{children:s.jsxs(K,{is_goback:!0,title:"Documents Update",go_back_url:`/tenders/view/${u}/${v}/documents/`,showSaveButton:!1,loading:!1,children:[s.jsx(M,{children:s.jsxs(q,{children:[s.jsx(Q,{count:e==null?void 0:e.count,columns:B,rows:f||[],loading:e==null?void 0:e.loading,page:(x=e==null?void 0:e.miniParams)!=null&&x.page?(C=e==null?void 0:e.miniParams)==null?void 0:C.page:1,pageSize:(j=e==null?void 0:e.miniParams)!=null&&j.page_size?(k=e==null?void 0:e.miniParams)==null?void 0:k.page_size:10,handleChangePage:z,handleChangeRowsPerPage:S}),s.jsx(N,{container:!0,justifyContent:"flex-end",mt:3.4,children:s.jsx(R,{variant:"contained",onClick:t=>{t.preventDefault(),P()},type:"submit",color:"primary",autoFocus:!0,children:"Save"})})]})})," "]})})})};export{ye as default};
