import{eh as I,F as A,b as L,a as w,hi as G,r as m,hq as T,hj as h,j as s,B as F,_ as M,Q as N,K as R,eS as U,ho as $,hS as _}from"./index-76d4793e.js";import{G as q}from"./GoBack-71b56a16.js";import{T as K}from"./index-1fae9bc3.js";import{C as Q}from"./Checkbox-ce15672a.js";import{C as Z}from"./CardContent-2f10f9e9.js";import"./Divider-3f770145.js";import"./dividerClasses-45958eb8.js";import"./LoadingButton-89ba2db7.js";import"./index-ecea5cfc.js";import"./useMediaQuery-8cb39c65.js";import"./useControlled-e03384de.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.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"./MenuItem-cff1abce.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./SwitchBase-25e1ee17.js";const ye=()=>{var x,C,j,k;const{tenderId:u,documentId:c,tab:v}=I();A();const o=L(),{document:{documentList:D,pageParams:r,selectedData:y,checkedList:i},mini:{miniDocuments:e},system:{userAccessList:H}}=w(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:()=>{}}))},S=(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(Q,{checked:!!i.find(l=>l==a.id),onChange:l=>S(a.id,"yes",l.target.checked)});return g(p,d,E)})},[e,y,g]),B=(t,a)=>{o(h({...r,search:"",page:a+1}))},z=t=>{o(h({...r,search:"",page:1,page_size:parseInt(t.target.value)}))};return s.jsx("div",{children:s.jsx(F,{children:s.jsxs(q,{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(Z,{children:[s.jsx(K,{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:B,handleChangeRowsPerPage:z}),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};
