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-def636a4.js";import{G as K}from"./GoBack-37987f0d.js";import{T as Q}from"./index-fc769754.js";import{C as Z}from"./Checkbox-76a12c6d.js";import{C as q}from"./CardContent-c8b2d0af.js";import"./Divider-6e68cefb.js";import"./dividerClasses-2b953c2a.js";import"./LoadingButton-621a0e8f.js";import"./index-f48c8aa0.js";import"./useMediaQuery-4304fb25.js";import"./useControlled-bd643819.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-5944247b.js";import"./TableRow-2c544f58.js";import"./Skeleton-5cf57ed1.js";import"./index-b5a6fbe3.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"./MenuItem-8fdd2340.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./SwitchBase-b0dec868.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};
