PageSourceSearch

https://die-strategie-makler.de/assets/IndexPage-B2rAT3s6.js

js die-strategie-makler.de collected 2026-10-07 05:55:55 UTC 24,541 bytes, 1 lines download raw bytes

1import{aB as q,ar as ye,s as w,x as X,i as ee,j as e,B as D,n as J,S as se,o as te,p as ae,q as ne,t as re,T as we,C as Se}from"./index-1N2C5CnQ.js";import{r as j,N as ke,$ as De,c as Te,cn as Ee,a4 as V,f as Le,d as Ce,P as Ae,a5 as Re,L as ze,bq as Ie,B as Oe,bs as Me,U as qe}from"./icons-BbWYyV6n.js";import{T as $,a as G,b as m,c as x}from"./tabs-DijO5yvo.js";import{C as le}from"./card-D37G7Je_.js";import{B as T}from"./badge-Bvp4mm4v.js";import{T as ie,a as oe,b as I,c as v,d as ce,e as f}from"./table-BI2yTQJj.js";import{e as He,L as H,F as Be}from"./routes-CmqHD8Dj.js";import{a as Fe}from"./alleZeilen-GHwC-pDR.js";import{d as Pe,e as Ke,u as de}from"./useOnboarding-DRLpVMzL.js";import{P as Ue}from"./PipelineBoard-v5sCEI0q.js";import{E as B}from"./EmptyState-DH8EgfKW.js";import{S as ue,a as me,b as xe,c as he}from"./sheet-CVMSi9xt.js";import{T as ge}from"./TasksPanel-BmlS0IHz.js";import{M as je,A as Ve,a as $e,b as Ge}from"./MarkdownEditor-5VdGiYhv.js";import{c as We,u as Qe,b as Ye,a as Je}from"./notes-iZMFetGv.js";import{u as Ze}from"./profiles-ClDD3KxX.js";import{C as Xe}from"./ConfirmDialog-DjJBXrku.js";import{D as pe}from"./DocumentsPanel-aXPQ9m7O.js";import{A as ve}from"./ActivityFeed-ClaC-C2r.js";import{D as es,a as ss,b as ts,c as as,e as ns}from"./dialog-p9PJMBYY.js";import"./index-Db7xoDmK.js";import"./logo-white-CRZy9DU1.js";import"./types-bmIkZ_kC.js";import"./de-DSpY3tgU.js";import"./endOfMonth-BHbXobYe.js";import"./pipeline-_-at4Xyf.js";import"./index-Bh1rN9nf.js";import"./popover-WL2z18zo.js";import"./calendar-k8l8-efj.js";import"./format-TT9VSeZF.js";import"./addDays-BcKuoO3-.js";import"./tasks-C3u3FXam.js";import"./index-DWL0pzg9.js";import"./index-D1CWbAMb.js";import"./documents-A6q1xn9Q.js";import"./authentifizierung-4qEsgNgo.js";import"./useSterbegeldRueckstaende-4d9kRp--.js";import"./mappings-ClTDYwOO.js";const O=["crm","schadenstool","deals"],W=t=>q({queryKey:[...O,t??{}],queryFn:async()=>{const a=()=>{let s=w.from("crm_st_deals").select("*").order("created_at",{ascending:!1}).order("id",{ascending:!1});return t!=null&&t.stage&&(s=s.eq("stage",t.stage)),t!=null&&t.ownerId&&(s=s.eq("owner_id",t.ownerId)),t!=null&&t.partnerId&&(s=s.eq("partner_id",t.partnerId)),t!=null&&t.hausverwaltungId&&(s=s.eq("hausverwaltung_id",t.hausverwaltungId)),t!=null&&t.excludeClosed&&(s=s.not("stage","in","(aktiv,verloren)")),s};return Fe((s,l)=>a().range(s,l))}}),rs=t=>q({queryKey:[...O,"detail",t],enabled:!!t,queryFn:async()=>{const{data:a,error:s}=await w.from("crm_st_deals").select("*").eq("id",t).maybeSingle();if(s)throw s;return a}}),fe=()=>{const t=ye();return He({mutationFn:async({dealId:a,newStage:s,lostReason:l,lostReasonText:r,wonReason:i})=>{const o=new Date().toISOString().slice(0,10),n={stage:s};s==="aktiv"?(n.actual_close=o,n.won_reason=i??null):s==="verloren"&&(n.actual_close=o,n.lost_reason=l??null,n.lost_reason_text=r??null);const{data:c,error:u}=await w.from("crm_st_deals").update(n).eq("id",a).select().single();if(u)throw u;if(s==="onboarding"){const{data:h}=await w.from("crm_st_onboarding_items").select("id").eq("deal_id",a).limit(1);if(!h||h.length===0){const{data:b}=await w.from("crm_st_onboarding_templates").select("items").eq("is_default",!0).limit(1).maybeSingle(),S=(b==null?void 0:b.items)??[];if(S.length>0){const N=c.contract_start_date??o,_=new Date(N).getTime(),A=S.map(k=>{const d=k.default_due_offset_days?new Date(_+k.default_due_offset_days*864e5).toISOString().slice(0,10):null;return{deal_id:a,label:k.label,sort_order:k.sort_order,due_date:d,assignee_id:c.owner_id}});await w.from("crm_st_onboarding_items").insert(A)}}}return c},onSuccess:(a,s)=>{t.invalidateQueries({queryKey:O}),t.invalidateQueries({queryKey:[...O,"detail",s.dealId]}),t.invalidateQueries({queryKey:["crm","schadenstool","onboarding-items"]})},onError:a=>X({title:"Stage-Wechsel fehlgeschlagen",description:a.message,variant:"destructive"})})},be=["crm","schadenstool","hvs"],Q=t=>q({queryKey:[...be,{}],queryFn:async()=>{let a=w.from("crm_st_hausverwaltungen").select("*").order("created_at",{ascending:!1});const{data:s,error:l}=await a.limit(500);if(l)throw l;return s??[]}}),Ne=t=>q({queryKey:[...be,"detail",t],enabled:!!t,queryFn:async()=>{const{data:a,error:s}=await w.from("crm_st_hausverwaltungen").select("*").eq("id",t).maybeSingle();if(s)throw s;return a}}),ls={gmbh:"GmbH",ag:"AG",e_k:"e.K.",gbr:"GbR",einzel:"Einzelunternehmen",sonstige:"Sonstige"},U={preis:"Preis",konkurrent:"Konkurrent",kein_bedarf:"Kein Bedarf",kein_budget:"Kein Budget",kein_entscheider:"Kein Entscheider",sonstiges:"Sonstiges"},is={open:"Offen",done:"Erledigt",blocked:"Blockiert"},Z=["lead","erstgespraech","demo","angebot","vertragsverhandlung"],E={lead:"Lead",erstgespraech:"Erstgespräch",demo:"Demo",angebot:"Angebot",vertragsverhandlung:"Vertragsverhandlung",onboarding:"Onboarding",aktiv:"Aktiv",verloren:"Verloren"},R="st_hausverwaltung",z="st_deal";function _e({entityType:t,entityId:a,module:s,compact:l=!1}){const{data:r,isLoading:i}=We(t,a),{data:o=[]}=Ze(),n=Qe(),c=Ye(),u=Je(),{user:h}=ee(),b=j.useRef(null),[S,N]=j.useState(null),[_,A]=j.useState(null),k=d=>{d.text.trim()&&n.mutate({entity_type:t,entity_id:a,body_md:d.html,body_json:d.json,mentions:d.mentions,tags:d.tags,module:s??null},{onSuccess:()=>{var L;return(L=b.current)==null?void 0:L.clear()}})};return e.jsxs("div",{className:"space-y-3",children:[!l&&e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Notizen"}),e.jsx(je,{ref:b,onSubmit:k,placeholder:"Notiz schreiben … @ für Erwähnungen, # für Tags"}),i?e.jsx(H,{rows:2}):!r||r.length===0?l?null:e.jsx(B,{icon:ke,title:"Noch keine Notizen",description:"Schreibe oben deine erste Notiz."}):e.jsx("ul",{className:"space-y-2",children:r.map(d=>{var L,Y;return e.jsx(os,{note:d,authorName:((L=o.find(y=>y.user_id===d.author_id))==null?void 0:L.display_name)??"Unbekannt",authorAvatar:((Y=o.find(y=>y.user_id===d.author_id))==null?void 0:Y.avatar_url)??null,isOwn:(h==null?void 0:h.id)===d.author_id,isEditing:S===d.id,onEdit:()=>N(d.id),onCancelEdit:()=>N(null),onSave:async y=>{await c.mutateAsync({id:d.id,body_md:y.html,body_json:y.json,mentions:y.mentions,tags:y.tags}),N(null)},onDelete:()=>A(d.id)},d.id)})}),e.jsx(Xe,{open:!!_,onOpenChange:d=>!d&&A(null),title:"Notiz löschen?",description:"Diese Aktion kann nicht rückgängig gemacht werden.",destructive:!0,confirmLabel:"Löschen",onConfirm:async()=>{_&&await u.mutateAsync({id:_,entityType:t,entityId:a})}})]})}function os({note:t,authorName:a,authorAvatar:s,isOwn:l,isEditing:r,onEdit:i,onCancelEdit:o,onSave:n,onDelete:c}){const u=j.useRef(null);return e.jsxs("li",{className:"rounded-lg border border-border bg-card p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(Ve,{className:"h-6 w-6",children:[e.jsx($e,{src:s??void 0}),e.jsx(Ge,{className:"text-[10px]",children:a.slice(0,2).toUpperCase()})]}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:a}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",Be(t.created_at)]}),t.created_at!==t.updated_at&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"· bearbeitet"}),e.jsx("div",{className:"flex-1"}),l&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:i,children:e.jsx(De,{className:"w-3 h-3"})}),e.jsx(D,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(Te,{className:"w-3 h-3"})})]})]}),r?e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{ref:u,initialContent:t.body_md,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(D,{variant:"outline",size:"sm",onClick:o,children:"Abbrechen"}),e.jsx(D,{size:"sm",onClick:()=>{var h,b,S,N,_;return n({html:((h=u.current)==null?void 0:h.getHTML())??"",text:((b=u.current)==null?void 0:b.getText())??"",json:((S=u.current)==null?void 0:S.getJSON())??{},mentions:((N=u.current)==null?void 0:N.getMentions())??[],tags:((_=u.current)==null?void 0:_.getTags())??[]})},children:"Speichern"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert text-sm",dangerouslySetInnerHTML:{__html:t.body_md}}),t.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:t.tags.map(h=>e.jsxs(T,{variant:"secondary",className:"text-[10px] gap-0.5 h-5",children:[e.jsx(Ee,{className:"w-2.5 h-2.5"}),h]},h))})]})]})}const F=t=>
1typeof t=="number"?t.toLocaleString("de-DE"):"—";function cs({hvId:t,onClose:a}){const{data:s,isLoading:l}=Ne(t),{data:r}=W(t?{hausverwaltungId:t}:void 0);return t?e.jsx(ue,{open:!!t,onOpenChange:i=>!i&&a(),children:e.jsx(me,{side:"right",className:"w-full sm:max-w-[60vw] sm:w-[60vw] p-0 flex flex-col",children:l||!s?e.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Lädt …"}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"px-6 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-md bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(V,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(he,{className:"text-lg",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground flex-wrap",children:[s.rechtsform&&e.jsx(T,{variant:"outline",children:ls[s.rechtsform]}),s.ort&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Le,{className:"h-3 w-3"}),s.plz," ",s.ort]}),s.anzahl_einheiten&&e.jsxs("span",{children:[F(s.anzahl_einheiten)," Einheiten"]})]})]})]})}),e.jsxs($,{defaultValue:"uebersicht",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(G,{className:"mx-6 mt-3 self-start",children:[e.jsx(m,{value:"uebersicht",children:"Übersicht"}),e.jsxs(m,{value:"deals",children:["Deals (",(r==null?void 0:r.length)??0,")"]}),e.jsx(m,{value:"aufgaben",children:"Aufgaben"}),e.jsx(m,{value:"notizen",children:"Notizen"}),e.jsx(m,{value:"dokumente",children:"Dokumente"}),e.jsx(m,{value:"aktivitaet",children:"Aktivität"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[e.jsxs(x,{value:"uebersicht",className:"mt-0 space-y-4",children:[e.jsxs(P,{title:"Stammdaten",children:[e.jsx(p,{label:"Adresse",value:[s.strasse,`${s.plz??""} ${s.ort??""}`.trim(),s.land].filter(Boolean).join(", ")||"—"}),e.jsx(p,{label:"Einheiten",value:F(s.anzahl_einheiten)}),e.jsx(p,{label:"Objekte",value:F(s.anzahl_objekte)}),e.jsx(p,{label:"Aktuelle Software",value:s.software_aktuell||"—"}),e.jsx(p,{label:"Erstkontakt",value:s.erstkontakt_am?new Date(s.erstkontakt_am).toLocaleDateString("de-DE"):"—"})]}),e.jsxs(P,{title:"Ansprechpartner",children:[e.jsx(p,{label:"Name",value:s.ansprechpartner_name||"—"}),e.jsx(p,{label:"Position",value:s.ansprechpartner_position||"—"}),e.jsx(p,{label:"E-Mail",value:s.email?e.jsxs("a",{href:`mailto:${s.email}`,className:"text-primary inline-flex items-center gap-1",children:[e.jsx(Ce,{className:"h-3 w-3"}),s.email]}):"—"}),e.jsx(p,{label:"Telefon",value:s.phone?e.jsxs("a",{href:`tel:${s.phone}`,className:"text-primary inline-flex items-center gap-1",children:[e.jsx(Ae,{className:"h-3 w-3"}),s.phone]}):"—"}),e.jsx(p,{label:"Website",value:s.website?e.jsxs("a",{href:s.website,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1",children:[e.jsx(Re,{className:"h-3 w-3"}),s.website]}):"—"})]}),s.notes&&e.jsx(P,{title:"Notizen",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:s.notes})})]}),e.jsx(x,{value:"deals",className:"mt-0 space-y-2",children:(r??[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Noch keine Deals zu dieser Hausverwaltung."}):(r??[]).map(i=>e.jsxs("div",{className:"rounded-md border border-border p-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:E[i.stage]??i.stage}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["MRR ",i.value_mrr?Number(i.value_mrr).toLocaleString("de-DE",{style:"currency",currency:"EUR"}):"—"," · ","Setup ",i.value_setup?Number(i.value_setup).toLocaleString("de-DE",{style:"currency",currency:"EUR"}):"—"]})]}),e.jsx(T,{variant:"outline",children:E[i.stage]??i.stage})]},i.id))}),e.jsx(x,{value:"aufgaben",className:"mt-0",children:e.jsx(ge,{entityType:R,entityId:s.id,module:"schadenstool"})}),e.jsx(x,{value:"notizen",className:"mt-0",children:e.jsx(_e,{entityType:R,entityId:s.id,module:"schadenstool"})}),e.jsx(x,{value:"dokumente",className:"mt-0",children:e.jsx(pe,{entityType:R,entityId:s.id,module:"schadenstool"})}),e.jsx(x,{value:"aktivitaet",className:"mt-0",children:e.jsx(ve,{entityType:R,entityId:s.id,module:"schadenstool"})})]})]})]})})}):null}function P({title:t,children:a}){return e.jsxs("div",{className:"rounded-md border border-border p-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:t}),e.jsx("div",{className:"space-y-2",children:a})]})}function p({label:t,value:a}){return e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:t}),e.jsx("div",{className:"col-span-2",children:a})]})}function ds({open:t,onOpenChange:a,onConfirm:s}){const[l,r]=j.useState("preis"),[i,o]=j.useState("");return e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(ss,{children:[e.jsx(ts,{children:e.jsx(as,{children:"Deal als verloren markieren"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(J,{children:"Grund"}),e.jsxs(se,{value:l,onValueChange:n=>r(n),children:[e.jsx(te,{children:e.jsx(ae,{})}),e.jsx(ne,{children:Object.keys(U).map(n=>e.jsx(re,{value:n,children:U[n]},n))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(J,{children:"Notiz (optional)"}),e.jsx(we,{value:i,onChange:n=>o(n.target.value),rows:3,placeholder:"Details zum Verlustgrund …"})]})]}),e.jsxs(ns,{children:[e.jsx(D,{variant:"outline",onClick:()=>a(!1),children:"Abbrechen"}),e.jsx(D,{variant:"destructive",onClick:()=>{s(l,i||void 0),a(!1)},children:"Als verloren markieren"})]})]})})}const us=Object.keys(E);function ms({dealId:t,currentStage:a}){const{crmRole:s}=ee(),l=s==="partner",r=fe(),[i,o]=j.useState(!1),n=c=>{if(c!==a){if(l&&!Z.includes(c)){X({title:"Nicht erlaubt",description:"Bitte DSM-Team informieren — Vertragsabschluss läuft über uns.",variant:"destructive"});return}if(c==="verloren"){o(!0);return}r.mutate({dealId:t,newStage:c})}};return e.jsxs(e.Fragment,{children:[e.jsxs(se,{value:a,onValueChange:c=>n(c),children:[e.jsx(te,{className:"w-full",children:e.jsx(ae,{})}),e.jsx(ne,{children:us.map(c=>{const u=l&&!Z.includes(c);return e.jsxs(re,{value:c,disabled:u,children:[E[c],u?" 🔒":""]},c)})})]}),e.jsx(ds,{open:i,onOpenChange:o,onConfirm:(c,u)=>{r.mutate({dealId:t,newStage:"verloren",lostReason:c,lostReasonText:u})}})]})}function xs({dealId:t}){const{data:a,isLoading:s}=Pe(t),l=Ke();return s?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ze,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):!a||a.length===0?e.jsx(B,{icon:Ie,title:"Noch keine Onboarding-Items",description:"Items werden beim Stage-Wechsel auf 'Onboarding' automatisch erzeugt."}):e.jsx("ul",{className:"space-y-2",children:a.map(r=>{const i=r.status==="done";return e.jsxs("li",{className:"flex items-start gap-3 rounded-md border border-border p-3",children:[e.jsx(Se,{checked:i,onCheckedChange:o=>{const n=o?"done":"open";l.mutate({id:r.id,patch:{status:n}})},className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm font-medium ${i?"line-through text-muted-foreground":""}`,children:r.label}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[e.jsx(T,{variant:i?"secondary":"outline",children:is[r.status]}),r.due_date&&e.jsxs("span",{children:["Fällig: ",new Date(r.due_date).toLocaleDateString("de-DE")]}),r.completed_at&&e.jsxs("span",{children:["· erledigt ",new Date(r.completed_at).toLocaleDateString("de-DE")]})]})]})]},r.id)})})}const K=t=>
1typeof t=="number"?t.toLocaleString("de-DE",{style:"currency",currency:"EUR",maximumFractionDigits:0}):"—";function hs({dealId:t,onClose:a}){const{data:s,isLoading:l}=rs(t),{data:r}=Ne((s==null?void 0:s.hausverwaltung_id)??null),{data:i}=de(),o=i==null?void 0:i.find(c=>c.id===(s==null?void 0:s.tarif_id));if(!t)return null;const n=s&&(s.stage==="onboarding"||s.stage==="aktiv");return e.jsx(ue,{open:!!t,onOpenChange:c=>!c&&a(),children:e.jsx(me,{side:"right",className:"w-full sm:max-w-[60vw] sm:w-[60vw] p-0 flex flex-col",children:l||!s?e.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Lädt …"}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"px-6 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-md bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Oe,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(he,{className:"text-lg",children:(r==null?void 0:r.name)??"Deal"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground flex-wrap",children:[e.jsx(T,{variant:"outline",children:E[s.stage]??s.stage}),o&&e.jsx("span",{children:o.label}),e.jsxs("span",{children:["MRR ",K(s.value_mrr?Number(s.value_mrr):null)]})]})]})]})}),e.jsxs($,{defaultValue:"uebersicht",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(G,{className:"mx-6 mt-3 self-start",children:[e.jsx(m,{value:"uebersicht",children:"Übersicht"}),n&&e.jsx(m,{value:"onboarding",children:"Onboarding"}),e.jsx(m,{value:"aufgaben",children:"Aufgaben"}),e.jsx(m,{value:"notizen",children:"Notizen"}),e.jsx(m,{value:"dokumente",children:"Dokumente"}),e.jsx(m,{value:"aktivitaet",children:"Aktivität"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[e.jsxs(x,{value:"uebersicht",className:"mt-0 space-y-4",children:[e.jsx(C,{title:"Stage",children:e.jsx(ms,{dealId:s.id,currentStage:s.stage})}),e.jsxs(C,{title:"Tarif & Werte",children:[e.jsx(g,{label:"Tarif",value:(o==null?void 0:o.label)??"—"}),e.jsx(g,{label:"MRR (€/Monat)",value:K(s.value_mrr?Number(s.value_mrr):null)}),e.jsx(g,{label:"Setup (einmalig)",value:K(s.value_setup?Number(s.value_setup):null)})]}),e.jsxs(C,{title:"Vertrag",children:[e.jsx(g,{label:"Erw. Close",value:s.expected_close?new Date(s.expected_close).toLocaleDateString("de-DE"):"—"}),e.jsx(g,{label:"Tatsächlich. Close",value:s.actual_close?new Date(s.actual_close).toLocaleDateString("de-DE"):"—"}),e.jsx(g,{label:"Vertragsstart",value:s.contract_start_date?new Date(s.contract_start_date).toLocaleDateString("de-DE"):"—"}),e.jsx(g,{label:"Laufzeit",value:`${s.contract_term_months} Monate`}),e.jsx(g,{label:"Unterzeichnet",value:s.contract_signed_at?new Date(s.contract_signed_at).toLocaleDateString("de-DE"):"—"})]}),s.stage==="verloren"&&e.jsxs(C,{title:"Verlust",children:[e.jsx(g,{label:"Grund",value:s.lost_reason?U[s.lost_reason]:"—"}),s.lost_reason_text&&e.jsx(g,{label:"Notiz",value:s.lost_reason_text})]}),s.stage==="aktiv"&&s.won_reason&&e.jsx(C,{title:"Won",children:e.jsx(g,{label:"Grund",value:s.won_reason})})]}),n&&e.jsx(x,{value:"onboarding",className:"mt-0",children:e.jsx(xs,{dealId:s.id})}),e.jsx(x,{value:"aufgaben",className:"mt-0",children:e.jsx(ge,{entityType:z,entityId:s.id,module:"schadenstool"})}),e.jsx(x,{value:"notizen",className:"mt-0",children:e.jsx(_e,{entityType:z,entityId:s.id,module:"schadenstool"})}),e.jsx(x,{value:"dokumente",className:"mt-0",children:e.jsx(pe,{entityType:z,entityId:s.id,module:"schadenstool"})}),e.jsx(x,{value:"aktivitaet",className:"mt-0",children:e.jsx(ve,{entityType:z,entityId:s.id,module:"schadenstool"})})]})]})]})})})}function C({title:t,children:a}){return e.jsxs("div",{className:"rounded-md border border-border p-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:t}),e.jsx("div",{className:"space-y-2",children:a})]})}function g({label:t,value:a}){return e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:t}),e.jsx("div",{className:"col-span-2",children:a})]})}const M=t=>
1typeof t=="number"?t.toLocaleString("de-DE",{style:"currency",currency:"EUR",maximumFractionDigits:0}):"—";function tt(){const[t,a]=j.useState("pipeline"),[s,l]=j.useState(null),[r,i]=j.useState(null);return e.jsxs("div",{className:"p-4 md:p-6 max-w-7xl mx-auto space-y-4",children:[e.jsx("header",{className:"flex items-center justify-end gap-2 flex-wrap"}),e.jsxs($,{value:t,onValueChange:a,children:[e.jsxs(G,{children:[e.jsxs(m,{value:"pipeline",className:"gap-1.5",children:[e.jsx(Me,{className:"w-3.5 h-3.5"})," Pipeline"]}),e.jsxs(m,{value:"hvs",className:"gap-1.5",children:[e.jsx(qe,{className:"w-3.5 h-3.5"})," Hausverwaltungen"]}),e.jsx(m,{value:"deals",className:"gap-1.5",children:"Deals"})]}),e.jsx(x,{value:"pipeline",className:"mt-4",children:e.jsx(gs,{onOpenDeal:i})}),e.jsx(x,{value:"hvs",className:"mt-4",children:e.jsx(js,{onOpen:l})}),e.jsx(x,{value:"deals",className:"mt-4",children:e.jsx(ps,{onOpen:i})})]}),e.jsx(cs,{hvId:s,onClose:()=>l(null)}),e.jsx(hs,{dealId:r,onClose:()=>i(null)})]})}function gs({onOpenDeal:t}){const{data:a,isLoading:s}=W(),{data:l}=Q(),r=fe(),i=j.useMemo(()=>{if(!a)return[];const o=new Map((l??[]).map(n=>[n.id,n.name]));return a.map(n=>({id:n.id,title:o.get(n.hausverwaltung_id)??"Hausverwaltung",subtitle:n.value_setup?`Setup ${M(Number(n.value_setup))}`:void 0,amount:n.value_mrr?Number(n.value_mrr):void 0,stageKey:n.stage}))},[a,l]);return s?e.jsx(H,{}):e.jsx(Ue,{module:"schadenstool",entity:"deal",items:i,showSums:!0,renderItem:o=>e.jsxs("button",{type:"button",onClick:()=>t(o.id),className:"text-left w-full",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:o.title}),o.subtitle&&e.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:o.subtitle}),o.amount!==void 0&&e.jsxs("div",{className:"text-[10px] font-semibold text-foreground mt-1",children:[M(o.amount)," MRR"]})]}),onMove:(o,n)=>{r.mutate({dealId:o.id,newStage:n})}})}function js({onOpen:t}){const{data:a,isLoading:s}=Q();return s?e.jsx(H,{}):!a||a.length===0?e.jsx(B,{icon:V,title:"Keine Hausverwaltungen",description:"Lege die erste Hausverwaltung an."}):e.jsx(le,{children:e.jsxs(ie,{children:[e.jsx(oe,{children:e.jsxs(I,{children:[e.jsx(v,{children:"Name"}),e.jsx(v,{children:"Ort"}),e.jsx(v,{className:"text-right",children:"Einheiten"}),e.jsx(v,{children:"Ansprechpartner"})]})}),e.jsx(ce,{children:a.map(l=>{var r;return e.jsxs(I,{className:"cursor-pointer",onClick:()=>t(l.id),children:[e.jsx(f,{className:"font-medium",children:l.name}),e.jsx(f,{children:l.ort??"—"}),e.jsx(f,{className:"text-right",children:((r=l.anzahl_einheiten)==null?void 0:r.toLocaleString("de-DE"))??"—"}),e.jsx(f,{children:l.ansprechpartner_name??"—"})]},l.id)})})]})})}function ps({onOpen:t}){const{data:a,isLoading:s}=W(),{data:l}=Q(),{data:r}=de();if(s)return e.jsx(H,{});if(!a||a.length===0)return e.jsx(B,{icon:V,title:"Keine Deals",description:"Noch keine Deals angelegt."});const i=new Map((l??[]).map(n=>[n.id,n.name])),o=new Map((r??[]).map(n=>[n.id,n.label]));return e.jsx(le,{children:e.jsxs(ie,{children:[e.jsx(oe,{children:e.jsxs(I,{children:[e.jsx(v,{children:"Hausverwaltung"}),e.jsx(v,{children:"Stage"}),e.jsx(v,{children:"Tarif"}),e.jsx(v,{className:"text-right",children:"MRR"}),e.jsx(v,{className:"text-right",children:"Setup"}),e.jsx(v,{children:"Erw. Close"})]})}),e.jsx(ce,{children:a.map(n=>e.jsxs(I,{className:"cursor-pointer",onClick:()=>t(n.id),children:[e.jsx(f,{className:"font-medium",children:i.get(n.hausverwaltung_id)??"—"}),e.jsx(f,{children:e.jsx(T,{variant:"outline",children:E[n.stage]??n.stage})}),e.jsx(f,{children:n.tarif_id?o.get(n.tarif_id)??"—":"—"}),e.jsx(f,{className:"text-right",children:M(n.value_mrr?Number(n.value_mrr):null)}),e.jsx(f,{className:"text-right",children:M(n.value_setup?Number(n.value_setup):null)}),e.jsx(f,{children:n.expected_close??"—"})]},n.id))})]})})}export{tt 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.