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-60a3c753.js";import{G as K}from"./GoBack-ae228613.js";import{T as Q}from"./index-7e55cf46.js";import{C as Z}from"./Checkbox-fe59fe9f.js";import{C as q}from"./CardContent-faee3650.js";import"./Divider-b296c48e.js";import"./dividerClasses-3fa67596.js";import"./LoadingButton-3975ddf9.js";import"./index-900fa817.js";import"./useMediaQuery-dba48e3b.js";import"./useControlled-194ef007.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-414c12e0.js";import"./TableRow-0b33776c.js";import"./Skeleton-98c353d9.js";import"./index-a99c9f65.js";import"./TableHead-f864c753.js";import"./createSvgIcon-de433e5f.js";import"./TablePagination-218dde38.js";import"./Select-99fc0d84.js";import"./Menu-d1b7e1c3.js";import"./List-f567f8e4.js";import"./Grow-68442588.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./MenuItem-2f410bd2.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./SwitchBase-eb3a47ff.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};
