PageSourceSearch

https://medifit-nienburg.de/assets/Contracts-B549Oifi.js

js medifit-nienburg.de collected 2026-10-04 03:32:11 UTC 40,533 bytes, 14 lines download raw bytes

1import{a as c,j as e}from"./trpc-vendor-Bta84Nsh.js";import{u as ge,t as g,B as Y,C as se,h as ne,i as q,w as ce,D as ae,a as le,L as v,I,T as ue}from"./index-_3-B0itT.js";import{u as pe}from"./react-vendor-DpXpH6G7.js";import{t as h,q as X,aD as fe,aC as be,m as je,f as me,an as xe,as as Ne,a3 as de,a_ as he,K as ve,ap as ye,X as ee,D as Se,n as we,A as oe,g as Ce,F as Me,au as ie,bJ as ke,am as De}from"./ui-vendor-NEZNvIbV.js";function re({icon:u,title:d,children:o}){return e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 pb-2 border-b border-border/50",children:[e.jsx(u,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:d})]}),e.jsx("div",{className:"space-y-2",children:o})]})}function x({label:u,value:d}){return d?e.jsxs("div",{className:"flex gap-3 py-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-32 shrink-0 mt-0.5",children:u}),e.jsx("span",{className:"text-sm font-medium break-all flex-1",children:d})]}):null}function Ae({contractId:u,onClose:d,startInEdit:o}){const y=g.useUtils(),{data:t,isLoading:M}=g.contracts.detail.useQuery({id:u}),[m,L]=c.useState(o??!1),[j,D]=c.useState(""),[f,N]=c.useState(""),[z,p]=c.useState("online"),[s,a]=c.useState(""),[S,$]=c.useState(""),[b,A]=c.useState(""),[U,W]=c.useState(""),[E,K]=c.useState(""),[P,l]=c.useState(""),[w,O]=c.useState(""),[B,G]=c.useState(""),[Z,J]=c.useState(null),te={current:!1};t&&m&&!j&&!te.current&&(te.current=!0,setTimeout(()=>{D(t.value??"0.00"),N(t.notes??""),p(t.contractSource??"online"),a(t.birthDate??""),$(t.address??""),A(t.postalCode??""),W(t.city??""),K(t.sepaIban??""),l(t.sepaBic??""),O(t.sepaAccountHolder??"")},0));const i=g.contracts.update.useMutation({onSuccess:()=>{y.contracts.list.invalidate(),y.contracts.detail.invalidate({id:u}),L(!1),J(null),G(""),h.success("Vertrag aktualisiert")},onError:r=>h.error(r.message)}),{data:C}=g.leads.list.useQuery({search:B,limit:8},{enabled:B.length>=2}),H=()=>{t&&(D(t.value??"0.00"),N(t.notes??""),p(t.contractSource??"online"),a(t.birthDate??""),$(t.address??""),A(t.postalCode??""),W(t.city??""),K(t.sepaIban??""),l(t.sepaBic??""),O(t.sepaAccountHolder??""),L(!0))},F=r=>({online:"Online-Checkout",appointment:"Termin",studio:"Studio vor Ort"})[r??""]??r??"–",n=r=>r??null,R=r=>r?q(Number(r)):null,V=r=>r?`${r} Monate`:null,k=r=>r?ce(r):null;return e.jsx(ae,{open:!0,onOpenChange:r=>!r&&d(),children:e.jsxs(le,{className:"max-w-xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs("div",{className:"flex items-start justify-between p-5 border-b border-border sticky top-0 bg-background z-10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx(Me,{className:"w-4 h-4 text-primary"}),e.jsxs("span",{className:"font-bold text-base",children:["Vertragsdokumentation #",u]})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unterzeichnet am ",k(t.signedAt??t.createdAt)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!m&&t&&e.jsx("button",{onClick:H,className:"text-muted-foreground hover:text-foreground",title:"Bearbeiten",children:e.jsx(he,{className:"w-4 h-4"})}),e.jsx("button",{onClick:d,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ee,{className:"w-4 h-4"})})]})]}),M?e.jsx("div",{className:"py-12 text-center text-muted-foreground text-sm",children:"Lade Vertragsdaten..."}):t?m?e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Umsatz Moremembers (€)"}),e.jsx(I,{type:"number",step:"0.01",min:"0",value:j,onChange:r=>D(r.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Quelle"}),e.jsxs("select",{value:z,onChange:r=>p(r.target.value),className:"w-full mt-1 h-9 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"online",children:"Online-Checkout"}),e.jsx("option",{value:"appointment",children:"Termin"}),e.jsx("option",{value:"studio",children:"Studio vor Ort"})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Notizen"}),e.jsx(ue,{value:f,onChange:r=>N(r.target.value),rows:3,className:"mt-1 resize-none"})]}),e.jsxs("div",{className:"pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-2 uppercase tracking-wide",children:"Magicline-Pflichtfelder"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Geburtsdatum"}
1),e.jsx(I,{type:"date",value:s,onChange:r=>a(r.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Straße + Nr."}),e.jsx(I,{placeholder:"Musterstraße 12",value:S,onChange:r=>$(r.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"PLZ"}),e.jsx(I,{placeholder:"12345",value:b,onChange:r=>A(r.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Stadt"}),e.jsx(I,{placeholder:"Berlin",value:U,onChange:r=>W(r.target.value),className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"IBAN"}),e.jsx(I,{placeholder:"DE89 3704 0044 0532 0130 00",value:E,onChange:r=>K(r.target.value),className:"mt-1 font-mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Kontoinhaber"}),e.jsx(I,{placeholder:"Vor- und Nachname",value:w,onChange:r=>O(r.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"BIC (optional)"}),e.jsx(I,{placeholder:"z.B. COBADEFFXXX",value:P,onChange:r=>l(r.target.value),className:"mt-1 font-mono"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Bei Aenderung wird Magicline-Sync sofort neu angetriggert."})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Lead neu zuweisen (optional)"}),Z?e.jsxs("div",{className:"mt-1 flex items-center gap-2 rounded-md border border-primary/50 bg-primary/5 px-3 py-2 text-sm",children:[e.jsx(ie,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"flex-1 font-medium",children:Z.name}),e.jsx("button",{onClick:()=>J(null),className:"text-muted-foreground hover:text-foreground",children:e.jsx(ee,{className:"w-3.5 h-3.5"})})]}):e.jsxs("div",{className:"relative mt-1",children:[e.jsx(I,{placeholder:"Lead-Name suchen…",value:B,onChange:r=>G(r.target.value)}),B.length>=2&&C?.rows&&C.rows.length>0&&e.jsx("div",{className:"absolute z-50 top-full mt-1 w-full rounded-md border border-border bg-background shadow-lg max-h-48 overflow-y-auto",children:C.rows.map(r=>e.jsxs("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-muted/50 flex items-center gap-2",onClick:()=>{J({id:r.id,name:`${r.firstName??""} ${r.lastName??""}`.trim()}),G("")},children:[e.jsx(ie,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsxs("span",{children:[r.firstName," ",r.lastName]}),r.brandName&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:r.brandName})]},r.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Nur ausfüllen, wenn der Vertrag einem falschen Lead zugeordnet wurde."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(Y,{className:"flex-1",disabled:i.isPending,onClick:()=>i.mutate({id:u,value:Number(j).toFixed(2),notes:f||null,contractSource:z,...Z&&{leadId:Z.id},...s&&{dateOfBirth:s},...S.trim()&&{street:S.trim()},...b.trim()&&{zipCode:b.trim()},...U.trim()&&{city:U.trim()},...E&&{sepaIban:E},...w&&{sepaAccountHolder:w},sepaBic:P||null}),children:i.isPending?"Speichern...":"Speichern"}),e.jsx(Y,{variant:"outline",onClick:()=>{L(!1),J(null),G("")},children:"Abbrechen"})]})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(re,{icon:ie,title:"Persönliche Daten",children:[e.jsx(x,{label:"Vorname",value:n(t.firstName)}),e.jsx(x,{label:"Nachname",value:n(t.lastName)}),e.jsx(x,{label:"Geburtsdatum",value:n(t.birthDate)}),e.jsx(x,{label:"E-Mail",value:n(t.email)}),e.jsx(x,{label:"Telefon",value:n(t.phone)}),e.jsx(x,{label:"Adresse",value:n(t.address)}),e.jsx(x,{label:"PLZ",value:n(t.postalCode)}),e.jsx(x,{label:"Stadt",value:n(t.city)})]}),e.jsxs(re,{icon:ke,title:"Vertragsdetails",children:[e.jsx(x,{label:"Vertragstyp",value:n(t.contractTypeName)}),e.jsx(x,{label:"Preis / Monat",value:R(t.value??t.price)}),e.jsx(x,{label:"Laufzeit",value:V(t.durationMonths)}),e.jsx(x,{label:"Gesamtwert",value:t.durationMonths?R(String(Number(t.price)*t.durationMonths)):null}),e.jsx(x,{label:"Vertragsstart",value:n(t.contractStart)}),e.jsx(x,{label:"Quelle",value:F(t.contractSource)}),e.jsx(x,{label:"Abschluss am",value:k(t.createdAt)}),t.notes&&e.jsx(x,{label:"Notizen",value:t.notes}),(()=>{let r=[];try{const T=t.modules;r=T?typeof T=="string"?JSON.parse(T):T:[]}catch{r=[]}const Q=T=>T==="yearly"?"/ Jahr":T==="half_yearly"?"/ Halbjahr":T==="quarterly"?"/ Quartal":T==="once"?"einmalig":"/ Monat";return!Array.isArray(r)||r.length===0?e.jsx(x,{label:"Module",value:"Keine Module dazugebucht"}):e.jsx(x,{label:"Module",value:r.map(T=>`${T.name} (+ ${Number(T.price).toFixed(2)} € ${Q(T.interval)})`).join(" · ")})})()]}),e.jsx(re,{icon:xe,title:"Empfehlung / Referral",children:t.hasReferral?e.jsxs(e.Fragment,{children:[e.jsx(x,{label:"Über Referral",value:"Ja — mit Empfehlungscode angemeldet"}),t.referralCode&&e.jsx(x,{label:"Empfehlungscode",value:t.referralCode}),t.referredByName&&e.jsx(x,{label:"Geworben von",value:t.referredByName}),t.referrerMemberNumber&&e.jsx(x,{label:"Werber-Mitgliedsnr. (Magicline)",value:t.referrerMemberNumber}),t.utmCampaign&&e.jsx(x,{label:"UTM-Kampagne",value:t.utmCampaign})]}):e.jsx(x,{label:"Über Referral",value:"Nein — kein Empfehlungscode"})}),e.jsxs(re,{icon:De,title:"SEPA-Lastschrift",children:[e.jsx(x,{label:"IBAN",value:n(t.sepaIban)}),e.jsx(x,{label:"Kontoinhaber",value:n(t.sepaAccountHolder)}),t.sepaSignedAt&&e.jsx(x,{label:"Mandat erteilt am",value:k(t.sepaSignedAt)})]})]}):e.jsx("div",{className:"py-12 text-center text-muted-foreground text-sm",children:"Keine Daten gefunden"})]})})}const _=1e3,Ee=39.8;function Le(u){if(!u)return null;const d=u.toLowerCase();return d.includes("dfoc")||d.includes("online contract conclusion rejected")?"Magicline lehnt den Online-/Fernabschluss (DFOC) fuer diesen Tarif ab. Das Studio muss den Fernabsatz-Abschluss fuer diesen Tarif in Magicline freischalten – oder den Vertrag manuell in Magicline anlegen.":d.includes("iban")||d.includes("sepa")||d.includes("bank account")||d.includes("direct debit")||d.includes("lastschrift")?"Bankdaten-Problem: die IBAN ist ungültig ODER das Konto lässt keine SEPA-Lastschrift zu. Neue, lastschriftfähige Bankdaten holen (per IBAN-Update-Link unten) und erneut synchronisieren.":d.includes("minderj")||d.includes("minor")?"Interessent ist minderjaehrig – Magicline verlangt einen Erziehungsberechtigten. Zum Termin einladen (unten).":d.includes("rate-bundle")||d.includes("ratebundle")||d.includes("rate bundle")?"Der gewaehlte Tarif (Rate-Bundle) ist in Magicline nicht (mehr) verfuegbar. Tarif in Magicline pruefen.":d.includes("duplicate")||d.includes("already exists")?"Mitglied existiert in Magicline bereits – ggf. schon manuell angelegt.":null}function Te({contractId:u,status:d,error:o,memberId:y,syncNotBefore:t}){const M=g.useUtils(),m=g.magicline.syncContract.useMutation({onSuccess:s=>
1{M.contracts.list.invalidate(),s.success?h.success("Magicline-Sync erfolgreich"):h.error(`Sync fehlgeschlagen: ${s.error??s.reason??"Unbekannter Fehler"}`)},onError:s=>h.error(s.message)}),L=g.contracts.sendIbanUpdateLink.useMutation({onSuccess:s=>h.success(`IBAN-Update-Link gesendet an ${s.sentTo}`),onError:s=>h.error(s.message)}),j=!!o&&/iban|sepa|bank account|direct debit|lastschrift/i.test(o),D=!!o&&/minderj/i.test(o),f=g.contracts.inviteMinorToAppointment.useMutation({onSuccess:s=>h.success(`Termin-Einladung per ${s.channel==="whatsapp"?"WhatsApp":"E-Mail"} gesendet (${s.sentTo})`),onError:s=>h.error(s.message)}),N=g.magicline.setSyncDelay.useMutation({onSuccess:()=>{M.contracts.list.invalidate(),h.success("Sync-Termin gespeichert")},onError:s=>h.error(s?.message??"Speichern fehlgeschlagen")}),z=()=>{const s=t?new Date(t).toISOString().slice(0,10):"",a=window.prompt(`Sync-Termin verschieben — bis zu welchem Datum soll Magicline NICHT synchronisieren?
2
3Format: YYYY-MM-DD (z.B. 2026-06-15 = wird ab dem 15.06. morgens gepusht)
4
5Leer lassen + OK = sofort syncen (Verzoegerung aufheben).`,s);if(a===null)return;const S=a.trim();S===""?N.mutate({contractId:u,syncDate:null}):/^\d{4}-\d{2}-\d{2}$/.test(S)?N.mutate({contractId:u,syncDate:S}):h.error("Format YYYY-MM-DD erwartet (z.B. 2026-06-15)")},p=e.jsx("button",{onClick:z,disabled:N.isPending,className:"text-muted-foreground hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:"Sync-Termin verschieben (z.B. weil alter Vertrag noch laeuft)",children:e.jsx(we,{className:"w-3.5 h-3.5"})});if(t&&t>Date.now()&&d!=="synced"){const s=new Date(t).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});return e.jsxs("button",{onClick:z,disabled:N.isPending,className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline-offset-2 hover:underline",title:`Magicline-Sync verzoegert bis ${s}. Klicken zum Aendern.`,children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),"Geplant: ",s]})}return!d||d==="skipped"?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>m.mutate({contractId:u}),disabled:m.isPending,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-amber-600 dark:hover:text-amber-400",title:"Diesen Vertrag jetzt an Magicline senden",children:[m.isPending?e.jsx(X,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(X,{className:"w-3.5 h-3.5"}),"Synchronisieren"]}),p]}):d==="synced"?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 dark:text-green-400",title:y?`Mitglieds-ID: ${y}`:"Synchronisiert",children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),"Synced"]}),p]}):d==="pending"?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>m.mutate({contractId:u}),disabled:m.isPending,className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 hover:text-amber-700 dark:hover:text-amber-300",title:"Jetzt synchronisieren",children:[m.isPending?e.jsx(X,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(oe,{className:"w-3.5 h-3.5"}),"Ausstehend"]}),p]}):d==="failed"?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>m.mutate({contractId:u}),disabled:m.isPending,className:"flex items-center gap-1 text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300",children:[m.isPending?e.jsx(X,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"}),"Fehler – Retry"]}),p]}),o&&(()=>{const s=Le(o);return e.jsx("span",{className:"text-xs text-red-500/70 max-w-[240px] break-words",title:o,children:s??o})})(),j&&e.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:e.jsxs("button",{type:"button",onClick:()=>{const s=window.prompt(`An welche Adresse soll der IBAN-Update-Link gehen?
6
7Leer lassen = Original-Email des Leads (Standard).
8Eigene Adresse eintragen = Test-Versand an dich.`,"");if(s===null)return;const a=s.trim()||void 0;L.mutate({contractId:u,overrideEmail:a})}
8,disabled:L.isPending,className:"text-[10px] text-blue-600 dark:text-blue-400 hover:underline flex items-center gap-1",title:"Kunde bekommt Mail mit Link zur Bankdaten-Eingabe. Mit Override-Email auch als Test an dich.",children:["📧 ",L.isPending?"Sende…":"IBAN-Update-Link senden"]})}),D&&e.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:e.jsxs("button",{type:"button",onClick:()=>{const s=window.confirm(`Termin-Einladung per WhatsApp senden?
9
10OK = WhatsApp · Abbrechen = per E-Mail`);f.mutate({contractId:u,channel:s?"whatsapp":"email"})},disabled:f.isPending,className:"text-[10px] text-emerald-600 dark:text-emerald-400 hover:underline flex items-center gap-1",title:"Lädt den minderjährigen Interessenten zu einem Termin ein (mit Elternteil) — per WhatsApp oder E-Mail",children:["📅 ",f.isPending?"Sende…":"Zum Termin einladen"]})})]}):null}function Ie({onClose:u}){const d=g.useUtils(),[o,y]=c.useState(""),[t,M]=c.useState(null),[m,L]=c.useState("39.80"),[j,D]=c.useState("online"),[f,N]=c.useState(""),{data:z}=g.leads.list.useQuery({search:o,limit:10},{enabled:o.length>=2}),p=z?.rows,s=g.contracts.create.useMutation({onSuccess:()=>{d.contracts.list.invalidate(),d.contracts.stats.invalidate(),h.success("Vertrag angelegt"),u()},onError:a=>h.error(a.message)});return e.jsx(ae,{open:!0,onOpenChange:a=>!a&&u(),children:e.jsxs(le,{className:"max-w-md p-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-border",children:[e.jsx("span",{className:"font-bold",children:"Vertrag manuell anlegen"}),e.jsx("button",{onClick:u,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ee,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Lead suchen"}),t?e.jsxs("div",{className:"flex items-center justify-between mt-1 px-3 py-2 rounded-md border border-primary bg-primary/10",children:[e.jsx("span",{className:"text-sm font-medium",children:t.name}),e.jsx("button",{onClick:()=>M(null),className:"text-muted-foreground hover:text-foreground",children:e.jsx(ee,{className:"w-3.5 h-3.5"})})]}):e.jsxs("div",{className:"relative mt-1",children:[e.jsx(I,{placeholder:"Name eingeben...",value:o,onChange:a=>y(a.target.value),autoFocus:!0}),p&&p.length>0&&e.jsx("div",{className:"absolute z-50 w-full mt-1 rounded-md border border-border bg-background shadow-lg max-h-48 overflow-y-auto",children:p.map(a=>e.jsxs("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-muted transition-colors",onClick:()=>{M({id:a.id,name:`${a.firstName} ${a.lastName}`}),y("")},children:[e.jsxs("span",{className:"font-medium",children:[a.firstName," ",a.lastName]}),a.phone&&e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:a.phone})]},a.id))})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Umsatz Moremembers (€)"}),e.jsx(I,{type:"number",step:"0.01",min:"0",value:m,onChange:a=>L(a.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Quelle"}),e.jsxs("select",{value:j,onChange:a=>D(a.target.value),className:"w-full mt-1 h-9 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"online",children:"Online-Checkout"}),e.jsx("option",{value:"appointment",children:"Termin"}),e.jsx("option",{value:"studio",children:"Studio vor Ort"})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Notizen (optional)"}),e.jsx(ue,{value:f,onChange:a=>N(a.target.value),rows:2,className:"mt-1 resize-none"})]}),e.jsx(Y,{className:"w-full",disabled:!t||s.isPending,onClick:()=>s.mutate({leadId:t.id,value:Number(m).toFixed(2),contractSource:j,notes:f||void 0}),children:s.isPending?"Speichern...":"Vertrag anlegen"})]})]})})}function ze({signupId:u,onClose:d}){const{data:o,isLoading:y}=g.contracts.signupDetail.useQuery({id:u}),t=g.useUtils();return g.contracts.convertSignup.useMutation({onSuccess:()=>
10{t.contracts.list.invalidate(),t.contracts.stats.invalidate(),d()}}),e.jsx(ae,{open:!0,onOpenChange:M=>!M&&d(),children:e.jsxs(le,{className:"max-w-md p-0",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-border flex items-center justify-between",children:[e.jsx("h2",{className:"font-semibold text-sm",children:"Online-Signup Details"}),e.jsx("button",{onClick:d,children:e.jsx(ee,{className:"w-4 h-4 text-muted-foreground"})})]}),y?e.jsx("div",{className:"p-8 flex justify-center",children:e.jsx("div",{className:"h-5 w-5 border-2 border-primary border-t-transparent rounded-full animate-spin"})}):o?e.jsxs("div",{className:"p-6 space-y-3 text-sm",children:[e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[["Name",`${o.firstName??""} ${o.lastName??""}`.trim()],["E-Mail",o.email],["Telefon",o.phone],["Studio",o.brandName],["Vertragstyp",o.contractTypeName],["Vertragsstart",o.contractStart],["Adresse",o.address],["Geburtsdatum",o.birthDate],["IBAN",o.sepaIban],["BIC",o.sepaBic],["Kontoinhaber",o.sepaAccountHolder],["UTM-Quelle",o.utmSource],["UTM-Kampagne",o.utmCampaign],["Eingegangen",o.createdAt?new Date(o.createdAt).toLocaleString("de-DE"):null]].map(([M,m])=>m?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:M}),e.jsx("p",{className:"font-medium break-all",children:m})]},M):null)}),e.jsx("div",{className:"pt-3 border-t border-border text-xs text-muted-foreground",children:"Online-Signup — Vertrag wird automatisch angelegt"})]}):e.jsx("p",{className:"p-6 text-sm text-muted-foreground",children:"Keine Daten gefunden."})]})})}function Fe(){const[,u]=pe(),[d,o]=c.useState(null),[y,t]=c.useState(null),[M,m]=c.useState(null),[L,j]=c.useState(!1),[D,f]=c.useState(null),[N,z]=c.useState(""),[p,s]=c.useState("all"),[a,S]=c.useState(!1),{user:$}=ge(),b=["admin","manager"].includes($?.role),A=g.useUtils(),{data:U,isLoading:W}=g.contracts.stats.useQuery(),{data:E,isLoading:K,error:P}=g.contracts.list.useQuery(),l=g.contracts.delete.useMutation({onSuccess:()=>{A.contracts.list.invalidate(),A.contracts.stats.invalidate(),h.success("Vertrag gelöscht"),f(null)},onError:i=>h.error(i.message)}),w=g.contracts.resendSignupNotification.useMutation({onSuccess:i=>h.success(`Vertrag inkl. PDF an ${i.recipient} gesendet`),onError:i=>h.error("Fehler: "+i.message)}),O=g.contracts.fixMergeConflicts.useMutation({onSuccess:i=>{A.contracts.list.invalidate(),A.contracts.stats.invalidate(),i.fixed.length===0?h.success("Keine Konflikte gefunden – alles in Ordnung"):h.success(`${i.fixed.length} Konflikt(e) behoben: ${i.fixed.map(C=>C.name).join(", ")}`)},onError:i=>h.error(i.message)}),B=U?.total??0,G=U?.totalValue??0,Z=Math.round(B/_*100),J=_-B,te=_*Ee;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Verträge"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{size:"sm",variant:"outline",disabled:O.isPending,onClick:()=>O.mutate(),title:"Signups bei denen der Name nicht zum Lead passt automatisch korrigieren",children:O.isPending?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Prüfe…"]}):"Merge-Konflikte fixen"}),e.jsx(Y,{size:"sm",onClick:()=>j(!0),children:"+ Vertrag anlegen"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ziel: ",_," Verträge · 01.05. – 01.09."]})]})]}),L&&e.jsx(Ie,{onClose:()=>j(!1)}),e.jsx(se,{className:"bg-card border-border",children:e.jsxs(ne,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-3xl font-bold text-foreground",children:B}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["von ",_," Verträgen"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-2xl font-bold text-primary",children:[Z,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[J," verbleibend"]})]})]}),e.jsx("div",{className:"h-6 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-primary/70 rounded-full transition-all duration-700",style:{width:`${Math.min(Z,100)}%`}})}),e.jsx("div",{className:"flex justify-between mt-2 text-xs text-muted-foreground",children:[250,500,750,1e3].map(i=>e.jsx("span",{className:B>=i?"text-primary font-medium":"",children:i},i))})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(se,{className:"bg-card border-border",children:e.jsx(ne,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:"Umsatz"}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:q(G)})]}),e.jsx(fe,{className:"h-5 w-5 text-green-400 mt-1"})]})})}),e.jsx(se,{className:"bg-card border-border",children:e.jsx(ne,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:"Zielumsatz"}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:q(te)})]}),e.jsx(be,{className:"h-5 w-5 text-primary mt-1"})]})})}),e.jsx(se,{className:"bg-card border-border",children:e.jsx(ne,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:"Ø pro Tag"}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:B>0?(B/Math.max(1,Math.ceil((Date.now()-new Date("2026-05-01").getTime())/864e5))).toFixed(1):"–"})]}),e.jsx(je,{className:"h-5 w-5 text-amber-400 mt-1"})]})})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:"Alle Verträge"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{value:p,onChange:i=>s(i.target.value),className:"text-sm bg-muted/40 border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-1 focus:ring-primary",title:"Nach Studio filtern",children:[e.jsx("option",{value:"all",children:"Alle Studios"}),Array.from(new Set((E??[]).map(i=>
10i.brandName).filter(Boolean))).sort().map(i=>e.jsx("option",{value:i,children:i},i))]}),e.jsx("input",{type:"text",placeholder:"Name, E-Mail oder Studio suchen…",value:N,onChange:i=>z(i.target.value),className:"text-sm bg-muted/40 border border-border rounded-lg px-3 py-1.5 w-72 placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary"}),(()=>{const i=(E??[]).filter(C=>C.magiclineSyncStatus==="failed").length;return e.jsxs("button",{onClick:()=>S(C=>!C),className:`text-sm px-3 py-1.5 rounded-lg border inline-flex items-center gap-1.5 ${a?"bg-red-500/15 border-red-400/50 text-red-500 font-medium":i>0?"border-red-400/40 text-red-500 hover:bg-red-500/10":"border-border text-muted-foreground hover:bg-muted"}`,title:"Nur Verträge mit Sync-Fehler (Klärfälle)",children:[e.jsx(me,{className:"w-4 h-4"})," Nur Klärfälle",i>0&&e.jsx("span",{className:"ml-0.5 text-xs font-bold px-1.5 py-0.5 rounded-full bg-red-500 text-white",children:i})]})})(),e.jsx(Be,{})]})]}),(()=>{const i=p==="all"?E??[]:(E??[]).filter(R=>R.brandName===p);if(i.length===0)return null;const C=R=>i.filter(V=>(V.contractSource??"online")===R).length,H=C("online"),F=C("appointment"),n=C("studio");return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3 text-xs",children:[e.jsxs("span",{className:"px-2.5 py-1 rounded-full border border-border bg-muted/30 text-foreground font-semibold",children:[i.length," Verträge gesamt"]}),e.jsxs("span",{className:"px-2.5 py-1 rounded-full border border-border text-foreground",children:["🌐 ",H," Online"]}),e.jsxs("span",{className:"px-2.5 py-1 rounded-full border border-border text-foreground",children:["📅 ",F," über Termin (vor Ort)"]}),e.jsxs("span",{className:"px-2.5 py-1 rounded-full border border-border text-foreground",children:["🏋️ ",n," direkt im Studio"]}),e.jsxs("span",{className:"px-2.5 py-1 rounded-full border border-primary/40 bg-primary/10 text-primary font-semibold",children:["Vor Ort gesamt: ",F+n]})]})})(),e.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/50 border-b border-border",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"#"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Lead"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Studio"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Vertragstyp"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Datum"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Wert"}),b&&e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Provision"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Magicline"}),e.jsx("th",{className:"text-left px-4 py-3 text-xs text-muted-foreground font-medium",children:"Notizen"}),e.jsx("th",{className:"px-4 py-3 w-10"})]})}),e.jsx("tbody",{children:K?Array.from({length:5}).map((i,C)=>e.jsx("tr",{className:"border-b border-border",children:Array.from({length:10}).map((H,F)=>e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"h-4 bg-muted animate-pulse rounded w-20"})},F))},C)):P?e.jsx("tr",{children:e.jsxs("td",{colSpan:b?10:9,className:"px-4 py-12 text-center text-destructive text-xs",children:["Fehler: ",P.message]})}):(E??[]).length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:b?10:9,className:"px-4 py-12 text-center text-muted-foreground",children:"Noch keine Verträge"})}):(()=>{const i=N.toLowerCase().trim(),C=p==="all"?E??[]:(E??[]).filter(n=>n.brandName===p),H=i?C.filter(n=>n.leadName?.toLowerCase().includes(i)||n.brandName?.toLowerCase().includes(i)||n.contractTypeName?.toLowerCase().includes(i)||n.leadEmail?.toLowerCase().includes(i)):C,F=a?H.filter(n=>n.magiclineSyncStatus==="failed"):H;return F.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:b?10:9,className:"px-4 py-12 text-center text-muted-foreground",children:["Keine Treffer",p!=="all"?` für ${p}`:"",i?` · „${N}"`:""]})}):F.map((n,R)=>{const V=n.isOrphaned===!0||n.id<0;return e.jsxs("tr",{className:`border-b border-border hover:bg-muted/20 ${V?"opacity-75":""}`,children:[e.jsx("td",{className:"px-4 py-3 text-muted-foreground text-xs",children:(E?.length??0)-R}),e.jsxs("td",{className:"px-4 py-3",children:[n.leadId&&n.leadId>0?e.jsx("button",{className:"text-primary hover:underline font-medium",onClick:()=>u(`/leads/${n.leadId}`),children:n.leadName??`Lead #${n.leadId}`}):e.jsx("span",{className:"font-medium text-foreground",children:n.leadName??"Unbe
10kannt"}),V&&e.jsx("span",{className:"ml-2 text-xs text-amber-400 border border-amber-400/30 px-1 rounded",children:"Online-Signup"}),n.hasReferral&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-emerald-400 border border-emerald-400/30 px-1 rounded",title:`Über Empfehlungscode angemeldet${n.referrerMemberNumber?` (Werber-Nr. ${n.referrerMemberNumber})`:""}`,children:[e.jsx(xe,{className:"w-3 h-3"})," Referral"]})]}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground",children:n.brandName??"–"}),e.jsxs("td",{className:"px-4 py-3 text-xs text-muted-foreground",children:[n.contractTypeName??"–",(()=>{let k=[];try{const Q=n.modules;k=Q?typeof Q=="string"?JSON.parse(Q):Q:[]}catch{k=[]}if(!Array.isArray(k)||k.length===0)return null;const r=k.map(Q=>Q?.name).filter(Boolean).join(", ");return e.jsxs("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-amber-500/15 text-amber-500 px-1.5 py-0.5 text-[10px] font-semibold align-middle",title:r?`Zusatz: ${r}`:"Upgrade/Modul gebucht",children:["+ ",k.length===1&&r?r:`${k.length} Upgrade${k.length>1?"s":""}`]})})()]}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground text-xs",children:ce(n.signedAt)}),e.jsx("td",{className:"px-4 py-3 text-green-400 font-medium",children:q(n.value)}),b&&e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground",children:n.contractTypeCommission?q(n.contractTypeCommission):"–"}),e.jsx("td",{className:"px-4 py-3",children:!V&&e.jsx(Te,{contractId:n.id,status:n.magiclineSyncStatus,error:n.magiclineSyncError,memberId:n.magiclineMemberId,syncNotBefore:n.magiclineSyncNotBefore})}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground text-xs max-w-[200px] truncate",children:n.notes||"–"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[n.phone&&e.jsx("a",{href:`tel:${n.phone}`,className:"text-muted-foreground hover:text-green-500 transition-colors",title:`Anrufen: ${n.phone}`,children:e.jsx(Ne,{className:"w-4 h-4"})}),V&&e.jsx(e.Fragment,{children:e.jsx("button",{onClick:()=>t(n.id),className:"text-muted-foreground hover:text-primary transition-colors",title:"Signup-Daten anzeigen",children:e.jsx(de,{className:"w-4 h-4"})})}),!V&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>o(n.id),className:"text-muted-foreground hover:text-primary transition-colors",title:"Details anzeigen",children:e.jsx(de,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{o(n.id),setTimeout(()=>m(n.id),50)},className:"text-muted-foreground hover:text-amber-400 transition-colors",title:"Bearbeiten",children:e.jsx(he,{className:"w-4 h-4"})})]}),!V&&(D===n.id?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l.mutate({id:n.id}),disabled:l.isPending,className:"text-xs text-red-400 hover:text-red-300 font-medium",children:l.isPending?"...":"Ja, löschen"}),e.jsx("button",{onClick:()=>f(null),className:"text-xs text-muted-foreground hover:text-foreground ml-1",children:"Abbrechen"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{const k=window.prompt(`Vertrag inkl. PDF senden an welche E-Mail?
11
12• Deine eigene Adresse = sicherer TEST (nur du bekommst es)
13• Leer lassen = an das Studio/den Inhaber`,"[email protected]");if(k===null)return;const r=k.trim();w.mutate(r?{contractId:n.id,overrideEmail:r}:{contractId:n.id})},disabled:w.isPending,className:"text-muted-foreground hover:text-blue-400 transition-colors",title:"Vertrag mit PDF senden — an dich zum Test oder an den Inhaber",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>f(n.id),className:"text-muted-foreground hover:text-red-400 transition-colors",title:"Vertrag löschen",children:e.jsx(ye,{className:"w-4 h-4"})})]}))]})})]},n.id)})})()})]})})]}),d!==null&&e.jsx(Ae,{contractId:d,onClose:()=>{o(null),m(null)},startInEdit:M===d}),y!==null&&e.jsx(ze,{signupId:y,onClose:()=>t(null)})]})}function Be(){const u=g.useUtils(),{data:d=[]}=g.brands.list.useQuery(),[o,y]=c.useState(!1),[t,M]=c.useState(!1),[m,L]=c.useState("all"),[j,D]=c.useState(""),[f,N]=c.useState(""),z=s=>{const a=new Date,S=A=>A.toISOString().slice(0,10);if(s==="all"){D(""),N("");return}const $=new Date(a);$.setHours(23,59,59,999);let b=new Date(a);if(s==="month")b=new Date(a.getFullYear(),a.getMonth(),1);else if(s==="lastMonth"){b=new Date(a.getFullYear(),a.getMonth()-1,1);const A=new Date(a.getFullYear(),a.getMonth(),0,23,59,59,999);D(S(b)),N(S(A));return}
13else s==="30d"?b=new Date(Date.now()-30*864e5):s==="90d"?b=new Date(Date.now()-90*864e5):s==="year"&&(b=new Date(a.getFullYear(),0,1));D(S(b)),N(S($))},p=async()=>{M(!0);try{const s={};m!=="all"&&(s.brandId=Number(m)),j&&(s.from=new Date(j+"T00:00:00").getTime()),f&&(s.to=new Date(f+"T23:59:59").getTime());const a=await u.contracts.exportAll.fetch(s),S=m==="all"?"Alle-Marken":d.find(l=>l.id===Number(m))?.studioName??`Brand-${m}`;if(!a.length){h.info(`Keine Verträge fuer "${S}" im Zeitraum gefunden.`);return}const b=[["Vertrag-ID","Datum","Vorname","Nachname","E-Mail","Telefon","PLZ","Stadt","Strasse","Marke","Studio","Vertragstyp","Wert","Quelle","Lead-Quelle","Provisionspflichtig","Referral","Referral-Code/Werber-Nr","UTM-Kampagne","Magicline-Sync","Magicline-Sync-Datum","Magicline-Member-ID","Magicline-Fehler","SEPA-IBAN","SEPA-Inhaber","Akquise-Quelle","Kaufgrund","Notizen"].join(",")],A=l=>{if(l==null)return"";const w=String(l);return/[",\n]/.test(w)?`"${w.replace(/"/g,'""')}"`:w};for(const l of a)b.push([l.
13id,l.signedAt?new Date(Number(l.signedAt)).toLocaleString("de-DE"):"",l.firstName??"",l.lastName??"",l.email??"",l.phone??"",l.zipCode??"",l.city??"",l.street??"",l.brandName??"",l.studioName??"",l.contractTypeName??"",l.value??"",l.contractSource??"",l.leadSource??"",l.commissionable===!1?"nein (provisionsfrei)":"ja",(()=>{const w=l.utmCampaign;return(l.referrerMemberNumber??(w&&w.startsWith("MAG-")?w.slice(4):null))||l.referredById?"ja":"nein"})(),(()=>{const w=l.utmCampaign;return l.referrerMemberNumber??(w&&w.startsWith("MAG-")?w.slice(4):null)??(l.referredById?`Lead #${l.referredById}`:"")})(),l.utmCampaign??"",l.magiclineSyncStatus??"",l.magiclineSyncedAt?new Date(Number(l.magiclineSyncedAt)).toLocaleString("de-DE"):"",l.magiclineMemberId??"",l.magiclineSyncError??"",l.sepaIban??"",l.sepaAccountHolder??"",l.acquisitionSource??"",l.purchaseReason??"",l.notes??""].map(A).join(","));const U=S.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),W=j||f?`_${j||"start"}_bis_${f||"heute"}`:"",E=new Blob(["\uFEFF"+b.join(`
14`)],{type:"text/csv;charset=utf-8"}),K=URL.createObjectURL(E),P=document.createElement("a");P.href=K,P.download=`vertraege-${U}${W}-${new Date().toISOString().slice(0,10)}.csv`,P.click(),URL.revokeObjectURL(K),h.success(`${a.length} Vertrag${a.length===1?"":"e"} (${S}) exportiert`),y(!1)}catch(s){h.error(s?.message??"Export fehlgeschlagen")}finally{M(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",size:"sm",className:"h-8 gap-1.5",onClick:()=>y(!0),children:[e.jsx(Se,{className:"w-3.5 h-3.5"})," CSV-Export"]}),e.jsx(ae,{open:o,onOpenChange:y,children:e.jsx(le,{className:"max-w-md",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Verträge exportieren"}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs",children:"Marke"}),e.jsxs("select",{className:"w-full bg-zinc-900 border border-zinc-700 rounded px-3 py-2 text-sm mt-1",value:m,onChange:s=>L(s.target.value),children:[e.jsx("option",{value:"all",children:"Alle Marken"}),d.map(s=>e.jsx("option",{value:String(s.id),children:s.studioName??s.name},s.id))]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-xs",children:"Von"}),e.jsx(I,{type:"date",value:j,onChange:s=>D(s.target.value),className:"text-sm"})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs",children:"Bis"}),e.jsx(I,{type:"date",value:f,onChange:s=>N(s.target.value),className:"text-sm"})]})]}),e.jsxs("div",{children:[e.jsx(v,{className:"text-xs text-muted-foreground",children:"Schnellauswahl"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:[["month","Diesen Monat"],["lastMonth","Letzter Monat"],["30d","Letzte 30 Tage"],["90d","Letzte 90 Tage"],["year","Dieses Jahr"],["all","Alle"]].map(([s,a])=>e.jsx("button",{type:"button",className:"text-xs px-2 py-1 rounded border border-border hover:bg-muted/40",onClick:()=>z(s),children:a},s))})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:!j&&!f?"Alle Verträge (kein Zeitraum gewählt)":`${j||"Anfang"} → ${f||"heute"}`}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>y(!1),children:"Abbrechen"}),e.jsx(Y,{onClick:p,disabled:t,children:t?"Exportiere...":"CSV herunterladen"})]})]})})})]})}export{Fe 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.