1 line
No EOL
4 KiB
JavaScript
1 line
No EOL
4 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,54858,e=>{"use strict";let t="/api/v1";async function a(e,t){let a=await e.text();if(!a)return t;try{let e=JSON.parse(a);return e.detail??e.message??a}catch{return a}}async function r(e,t){let a=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t}),credentials:"include"});if(!a.ok){let e=Error(await a.text()||`HTTP ${a.status}`);throw e.status=a.status,e}return a.json()}async function i(e,a){let r=await fetch(`${t}${e}`,{cache:"no-store",credentials:"include"});if(!r.ok)throw Error(`API request failed: ${r.status}`);return r.json()}async function n(e,r,i,n){let s=await fetch(`${t}${e}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(n),credentials:"include"});if(!s.ok)throw Error(await a(s,`API request failed: ${s.status}`));return s.json()}async function s(e,r){let i=await fetch(`${t}${e}`,{method:"DELETE",credentials:"include"});if(!i.ok)throw Error(await a(i,`API request failed: ${i.status}`))}async function o(e,r,i){let n=await fetch(`${t}${e}`,{...i,headers:{"Content-Type":"application/json",...i?.headers??{}},credentials:"include"});if(!n.ok)throw Error(await a(n,`API request failed: ${n.status}`));return n.json()}e.s(["API_BASE",0,t,"apiDelete",0,s,"apiFetch",0,o,"apiGet",0,i,"apiSend",0,n,"login",0,r,"normalizeValidationPayload",0,function(e){return{...e,...Object.fromEntries(["contact_id","examiner_id"].map(t=>[t,e[t]||null]))}}])},40160,e=>{"use strict";let t=(0,e.i(75254).default)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);e.s(["Download",0,t],40160)},69216,e=>{"use strict";var t=e.i(43476);let a=(0,e.i(75254).default)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var r=e.i(40160),i=e.i(22016),n=e.i(18566),s=e.i(71645),o=e.i(28779),l=e.i(54858);e.s(["default",0,function(){let{token:e}=(0,o.useAuth)(),c=(0,n.useParams)(),[d,h]=(0,s.useState)(""),[u,f]=(0,s.useState)("Vorschau wird geladen."),[w,p]=(0,s.useState)("");async function m(){let t=await fetch(`${l.API_BASE}/validations/${c.id}/report.pdf`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.json().catch(()=>null);p(e?.detail??"PDF konnte nicht erzeugt werden.");return}let a=await t.blob(),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r,i.download="validierungsbericht.pdf",i.click(),URL.revokeObjectURL(r)}return(0,s.useEffect)(()=>{e&&c.id&&fetch(`${l.API_BASE}/validations/${c.id}/report.html`,{headers:{Authorization:`Bearer ${e}`}}).then(async e=>{if(!e.ok)throw Error(await e.text());return e.text()}).then(e=>{h(e),f("")}).catch(()=>f("Vorschau konnte nicht geladen werden."))},[c.id,e]),(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("header",{className:"flex flex-col justify-between gap-3 sm:flex-row sm:items-center",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-3xl font-semibold",children:"HTML-Vorschau"}),(0,t.jsx)("p",{className:"mt-2 text-text-light",children:"Authentifiziert gerenderter Orion-Bericht."})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(i.default,{href:"/validations",className:"btn btn-secondary h-12",children:[(0,t.jsx)(a,{className:"h-4 w-4"})," Zurueck"]}),(0,t.jsxs)("button",{type:"button",onClick:m,className:"btn btn-primary h-12",children:[(0,t.jsx)(r.Download,{className:"h-4 w-4"})," PDF herunterladen"]})]})]}),w&&(0,t.jsx)("div",{className:"fixed right-4 top-4 z-50 max-w-md rounded-lg border border-danger/30 bg-white p-4 text-sm text-danger shadow-soft",children:w}),u?(0,t.jsx)("div",{className:"rounded-lg border border-border bg-surface p-6 shadow-soft",children:u}):(0,t.jsx)("iframe",{title:"Validierungsbericht",srcDoc:d,className:"h-[78vh] w-full rounded-lg border border-border bg-white shadow-soft"})]})}],69216)}]); |