1import{c as N,aa as y,ai as w,t as v,r as o,j as e,v as _,V as I,W as k,w as D,aF as R,aG as C,B as E,ap as g,aH as U,aI as F,y as f,z as S,aJ as z}from"./index-CggIIFzo.js";import{D as L}from"./DashboardLayout-B2n0xEJl.js";import{d as M}from"./storageApi-DCGE_E1s.js";import{D as B}from"./download-Rjvq0MEX.js";import"./progress-pf28ssF7.js";import"./ThemeToggle-CL-3-2JG.js";import"./DashboardV2Shell-nxzUZYx_.js";import"./dialog-BA4B4Nlh.js";import"./index-Bj8o7Yn4.js";import"./search-BuhGhL7b.js";import"./triangle-alert-DRoHRyAt.js";import"./chevron-down-BCaOraiY.js";import"./menu-D7P1yxSX.js";import"./settings-2-Cz9APQWa.js";import"./wissensbasis-BzK7G1Di.js";import"./onboardingSession-BeccaTNX.js";import"./user-plus-CAkZBYuk.js";import"./wand-sparkles-C6m3ooR7.js";import"./refresh-cw-Djg3HbAe.js";import"./sliders-horizontal-BM9MD3As.js";import"./chart-column-C9BOi9Hm.js";import"./circle-alert-W59jii8g.js";import"./clock-DdTvvi3r.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const V=N("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);function q(r,i="EUR"){if(r===null)return"â";const a=Number(r);return Number.isFinite(a)?new Intl.NumberFormat("de-DE",{style:"currency",currency:i}).format(a):"â"}const de=()=>{const{user:r,loading:i,authBackend:a}=y(),{customerId:n,loading:d}=w(),h=v(),[x,c]=o.useState([]),[j,l]=o.useState(!0);if(o.useEffect(()=>{!i&&!r&&h("/auth")},[r,i,h]),o.useEffect(()=>{d||(async()=>{if(!n){l(!1);return}if(g(r)){c(U),l(!1);return}if(a==="standalone"){try{const{items:s}=await F(n);c(s)}catch(s){console.error("Invoices failed:",s)}finally{l(!1)}return}const{data:p}=await f.from("customer_invoices").select("id, invoice_number, invoice_date, amount, file_url, file_name").eq("customer_id",n).order("invoice_date",{ascending:!1});c(p||[]),l(!1)})()},[a,n,d,r]),i||d)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});if(!r||!n)return null;const b=async t=>{if(g(r)||t.file_url==="#")return;if(a==="standalone"){if(t.file_url.startsWith("http")&&!t.file_url.includes("/storage/v1/object/")){window.open(t.file_url,"_blank","noopener,noreferrer");return}try{await M(n,t.id,t.file_name)}catch(s){S.error(s instanceof Error?s.message:"Rechnung konnte nicht geladen werden.")}return}if(!t.file_url.startsWith("http")){let s=null;const{data:m}=await f.storage.from("invoices").createSignedUrl(t.file_url,3600);if(s=(m==null?void 0:m.signedUrl)||null,!s){const{data:u}=await f.storage.from("customer-files").createSignedUrl(t.file_url,3600);s=(u==null?void 0:u.signedUrl)||null}s&&window.open(s,"_blank")}else window.open(t.file_url,"_blank")};return e.jsx(L,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"dashboard-page-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-page-eyebrow",children:"Konto & Verwaltung"}),e.jsx("h1",{className:"font-semibold text-foreground tracking-tight",children:"Rechnungen"}),e.jsx("p",{className:"text-muted-foreground",children:"Ãbersicht aller Rechnungen und Zahlungen."})]})}),e.jsxs(_,{className:"border-border",children:[e.jsx(I,{children:e.jsx(k,{className:"text-lg",children:"Rechnungshistorie"})}),e.jsx(D,{children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})}):x.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(V,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"Noch keine Rechnungen vorhanden"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-sm",children:"Deine Rechnungen werden hier angezeigt, sobald sie erstellt wurden."})]}):e.jsx("div",{className:"divide-y divide-border",children:x.map(t=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted flex items-center justify-center",children:e.jsx(R,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:t.invoice_number||t.file_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.invoice_date?C(new Date(t.invoice_date),"dd.MM.yyyy",{locale:z}):"â"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-medium text-foreground",children:q(t.amount,t.currency)}
6),e.jsx("p",{className:t.stripe_status==="paid"?"text-sm text-green-600":"text-sm text-muted-foreground",children:{paid:"Bezahlt",open:"Offen",void:"Storniert",uncollectible:"Uneinbringlich"}[t.stripe_status??""]??"Rechnung"})]}),e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>b(t),children:e.jsx(B,{className:"w-4 h-4"})})]})]},t.id))})})]})]})})};export{de 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.