import{r as t,j as e}from"./login-aN2dRsX6.js";import{u as w,a as y}from"./query-c3dDncii.js";import{h as P}from"./html2pdf-BXDanNDU.js";import{M as c}from"./Modal-Dn58D0E5.js";import"./app-gmlkJjeD.js";import"./typeof-QjJsDpFa.js";import"./ThemeProvider-Cx_yflmw.js";import"./index-Ci65TyJp.js";import"./setPrototypeOf-B4fUID9J.js";function U(){var f,p,u;const[n,m]=t.useState(!1),i=t.useRef(null),[o,h]=t.useState(null),a=w(),s=y();t.useEffect(()=>{if(n&&i.current){const d={margin:0,filename:"preview.pdf",image:{type:"jpeg",quality:1},html2canvas:{scale:2},jsPDF:{unit:"in",format:"letter",orientation:"landscape"}};P().from(i.current).set(d).outputPdf("bloburl").then(r=>{h(r)})}else h(null)},[n]);const A=()=>{m(!0)},x=()=>{m(!1)},j=t.useMemo(()=>{var d,r,N,g;return e.jsx("div",{style:{display:"none"},children:e.jsx("div",{ref:i,className:"bg-white p-6 shadow-md w-[21cm]",children:e.jsxs("div",{style:{padding:"0.5cm"},children:[e.jsxs("div",{className:"align-items-center d-flex gap-3",children:[e.jsx("span",{children:((d=a.data)==null?void 0:d.logo)&&e.jsx("img",{src:(r=a.data)==null?void 0:r.logo,style:{maxHeight:70}})}),e.jsxs("span",{children:[e.jsx("h5",{className:"mb-1 fw-bold",children:(N=a.data)==null?void 0:N.nama}),e.jsx("h6",{className:"mb-1 fw-bold",children:"KECAMATAN PURWOKERTO TIMUR KABUPATEN BANYUMAS PROVINSI JAWA TENGAH"}),e.jsx("div",{className:"mb-0",children:(g=a.data)==null?void 0:g.alamat})]})]}),e.jsx("hr",{}),s.data&&s.data.length>0?e.jsxs("div",{className:"text-center",children:[e.jsx("h5",{className:"mb-1 fw-bold",children:"LAPORAN NOMINATIF ANGGOTA"}),e.jsxs("h6",{className:"mb-1 fw-bold",children:["PERIODE: ",new Date().toLocaleDateString()]})]}):e.jsx("div",{className:"text-center",children:e.jsx("h5",{className:"mb-1 fw-bold",children:"Tidak ada data anggota"})}),s.data&&s.data.length>0&&e.jsxs("table",{className:"table-bordered mt-3 table",style:{fontSize:"9px",fontFamily:"Arial, sans-serif"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"No"}),e.jsx("th",{children:"Nama"}),e.jsx("th",{children:"NIK"}),e.jsx("th",{children:"Alamat"}),e.jsx("th",{children:"Jenis Kelamin"})]})}),e.jsx("tbody",{children:s.data.map((l,b)=>e.jsxs("tr",{children:[e.jsx("td",{children:b+1}),e.jsx("td",{children:l.nama_lengkap}),e.jsx("td",{children:l.nik}),e.jsx("td",{children:l.alamat}),e.jsx("td",{children:l.jenis_kelamin})]},l.id||b))})]})]})})})},[s.data,(f=a.data)==null?void 0:f.alamat,(p=a.data)==null?void 0:p.logo,(u=a.data)==null?void 0:u.nama]);return{modal:t.useMemo(()=>e.jsxs(e.Fragment,{children:[j,e.jsxs(c,{show:n,onHide:x,fullscreen:!0,children:[e.jsx(c.Header,{closeButton:!0,className:"py-2",children:e.jsx("h6",{className:"modal-title m-0",children:"Laporan Nominatif Anggota"})}),e.jsx(c.Body,{className:"p-0 d-flex",children:o?e.jsx("iframe",{src:o,title:"Preview PDF",className:"border",style:{width:"100%"}}):e.jsx("div",{children:"Loading PDF..."})})]})]}),[j,o,n]),open:A,close:x}}export{U as default};
