1import{j as e}from"./index-DtztfY4P.js";import{k as T,b as i}from"./react-vendor-CXpynOok.js";import{S as B}from"./SignaturePad-BQAvHbIf.js";const g="";function l(a){return(Number(a)||0).toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:2})+" â¬"}function d(a){return a?new Date(a).toLocaleDateString("de-DE"):"â"}const E={sent:["Offen","b-yellow"],accepted:["Angenommen","b-green"],declined:["Abgelehnt","b-red"],expired:["Abgelaufen","b-red"]};function q(){const{token:a}=T(),[s,h]=i.useState(null),[u,r]=i.useState(""),[f,b]=i.useState(!0),[j,x]=i.useState(!1),[o,v]=i.useState(""),[p,y]=i.useState(null),[c,m]=i.useState(!1);async function S(){b(!0);try{const t=await fetch(`${g}/api/public/quote/${a}`);if(!t.ok)throw new Error("Dieses Angebot ist nicht (mehr) verfügbar.");h(await t.json())}catch(t){r(t.message)}finally{b(!1)}}i.useEffect(()=>{S()},[a]);async function w(){if(!o.trim()){r("Bitte Namen eingeben.");return}m(!0),r("");try{const t=await fetch(`${g}/api/public/quote/${a}/accept`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({signerName:o.trim(),signature:p})});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error||"Fehler");h(await t.json()),x(!1)}catch(t){r(t.message)}finally{m(!1)}}async function A(){if(confirm("Angebot wirklich ablehnen?")){m(!0),r("");try{const t=await fetch(`${g}/api/public/quote/${a}/decline`,{method:"POST"});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error||"Fehler");h(await t.json())}catch(t){r(t.message)}finally{m(!1)}}}if(f)return e.jsx("div",{className:"empty",style:{marginTop:"20vh"},children:"Lädt â¦"});if(!s)return e.jsxs("div",{className:"empty",style:{marginTop:"20vh"},children:["â ï¸ ",u||"Angebot nicht gefunden."]});const n=s.company||{},[k,_]=E[s.expired&&s.status==="sent"?"expired":s.status]||[s.status,"b-gray"],N=s.status==="sent"||s.status==="expired";return e.jsxs("div",{style:{maxWidth:820,margin:"0 auto",padding:"2rem 1rem"},children:[e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex jb ic wrap",style:{borderBottom:"3px solid var(--accent)",paddingBottom:14,marginBottom:18},children:[e.jsxs("div",{children:[n.logo?e.jsx("img",{src:n.logo,alt:n.name,style:{maxHeight:50}}):e.jsx("div",{style:{fontSize:22,fontWeight:800,color:"var(--accent)"},children:n.name}),e.jsxs("div",{className:"txs muted",style:{marginTop:4},children:[[n.address,n.email,n.phone].filter(Boolean).join(" · "),n.taxId?` · USt-IdNr: ${n.taxId}`:"",n.taxNumber?` · St-Nr: ${n.taxNumber}`:""]})]}),e.jsxs("div",{style:{textAlign:"right"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:700},children:"ANGEBOT"}),e.jsxs("div",{className:"txs muted",children:["Nr. ",e.jsx("b",{children:s.number})]}),e.jsxs("div",{className:"txs muted",children:["Datum: ",d(s.issue_date)]}),e.jsxs("div",{className:"txs muted",children:["Gültig bis: ",d(s.valid_until)]}),e.jsx("span",{className:`badge ${_}`,style:{marginTop:6},children:k})]})]}),e.jsxs("div",{className:"flex jb wrap mb2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"txs muted",children:"Angebot für"}),e.jsx("b",{children:s.customer_name||"â"}),s.title?e.jsx("div",{className:"tsm",children:s.title}):null]}),s.start_date?e.jsxs("div",{style:{textAlign:"right"},children:[e.jsx("div",{className:"txs muted",children:"Zeitraum"}),d(s.start_date)," â ",d(s.end_date)]}):null]}),e.jsxs("table",{className:"mb2",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Position"}),e.jsx("th",{children:"Menge"}),e.jsx("th",{children:"Tage"}),e.jsx("th",{style:{textAlign:"right"},children:"Satz"}),e.jsx("th",{style:{textAlign:"right"},children:"Betrag"})]})}),e.jsxs("tbody",{children:[s.lines.map((t,$)=>e.jsxs("tr",{children:[e.jsxs("td",{className:"fw7",children:[t.name,t.sku?e.jsxs("span",{className:"txs muted",children:[" (",t.sku,")"]}):null,t.role?e.jsxs("span",{className:"txs muted",children:[" ",t.role]}):null]}),e.jsxs("td",{children:[t.qty,"Ã"]}),e.jsx("td",{children:t.days}),e.jsx("td",{style:{textAlign:"right"},children:l(t.rate)}),e.jsx("td",{style:{textAlign:"right"},children:l(t.amount)})]},$)),!s.lines.length&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"muted",children:"Keine Positionen"})})]})]}),e.jsxs("div",{style:{textAlign:"right"},className:"mb2",children:[Number(s.discount)?e.jsxs("div",{className:"muted",children:["Rabatt: ",s.discount_type==="amount"?l(s.discount):`${Number(s.discount)}%`,s.discount_reason?` (${s.discount_reason})`:""]}):null,e.jsxs("div",{className:"muted",children:["Netto: ",l(s.net_total)]}),e.jsxs("div",{className:"muted",children:["USt ",Number(s.vat_rate),"%: ",l(s.vat_amount)]}),e.jsxs("div",{className:"fw7",style:{fontSize:"1.15rem",color:"var(--accent)"},children:["Gesamt: ",l(s.gross_total)]})]}),s.notes&&e.jsx("div",{className:"muted tsm mb2",style:{whiteSpace:"pre-wrap"},children:s.notes}),(n.bank||n.footer)&&e.jsxs("div",{className:"txs muted",style:{borderTop:"1px solid var(--line)",paddingTop:10},children:[n.bank?`Bankverbindung: ${n.bank}. `:"",n.footer]}),u&&e.jsx("div",{className:"login-error mt2",children:u}),s.status==="accepted"&&e.jsx("div",{className:"card mt2",style:{background:"var(--green-bg)",borderColor:"var(--green)"},children:e.jsxs("div",{className:"fw7",style:{color:"var(--green)"},children:["â Angenommen",s.signer_name?` von ${s.signer_name}`:"",s.signed_at?` am ${d(s.signed_at)}`:""]})}),s.status==="declined"&&e.jsx("div",{className:"card mt2",style:{background:"var(--red-bg)",borderColor:"var(--red)"},children:e.jsx("div",{className:"fw7",style:{color:"var(--red)"},children:"Dieses Angebot wurde abgelehnt."})}),N&&!j&&e.jsxs("div",{className:"flex g1 ic mt2",children:[e.jsx("button",{className:"btn btn-accent",onClick:()=>
1x(!0),disabled:c,children:"Annehmen & signieren"}),e.jsx("button",{className:"btn btn-outline",onClick:A,disabled:c,children:"Ablehnen"})]}),N&&j&&e.jsxs("div",{className:"card mt2",children:[e.jsx("div",{className:"section-title",children:"Angebot annehmen"}),e.jsxs("div",{className:"fg",children:[e.jsx("label",{className:"lbl",children:"Ihr Name *"}),e.jsx("input",{value:o,onChange:t=>v(t.target.value),placeholder:"Vor- und Nachname",autoFocus:!0})]}),e.jsxs("div",{className:"fg",children:[e.jsx("label",{className:"lbl",children:"Unterschrift"}),e.jsx(B,{onChange:y})]}),e.jsxs("div",{className:"flex g1 ic mt1",children:[e.jsx("button",{className:"btn btn-accent",onClick:w,disabled:c||!o.trim(),children:c?"â¦":"Verbindlich annehmen"}),e.jsx("button",{className:"btn btn-ghost",onClick:()=>x(!1),disabled:c,children:"Abbrechen"})]})]})]}),e.jsx("div",{className:"txs muted",style:{textAlign:"center",marginTop:12},children:"Bereitgestellt über Riggr"})]})}export{q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.