PageSourceSearch

https://medifit-nienburg.de/assets/ContractAnalytics-C0XegIey.js

js medifit-nienburg.de collected 2026-10-04 03:32:12 UTC 18,152 bytes, 1 lines download raw bytes

1import{a as i,j as e}from"./trpc-vendor-Bta84Nsh.js";import{t as k,C as F,h as E}from"./index-_3-B0itT.js";import{k as T,X,bK as Y,av as ee}from"./ui-vendor-NEZNvIbV.js";import"./react-vendor-DpXpH6G7.js";const te=["Unter 20","20–24","25–29","30–34","35–39","40–44","45–49","50–54","55–59","60–64","65+"];function v({title:n,rows:m,colorFn:a,labelFn:g,loading:c,emptyHint:r}){const o=m.reduce((l,s)=>l+s.count,0);return e.jsx(F,{className:"bg-card border-border",children:e.jsxs(E,{className:"p-5",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:n}),c?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(l=>e.jsx("div",{className:"h-4 bg-muted animate-pulse rounded"},l))}):m.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:r??"Keine Daten"}):e.jsx("div",{className:"space-y-2",children:m.map(l=>{const s=Math.round(l.count/Math.max(1,o)*100);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-foreground truncate max-w-[70%]",children:g(l.label)}),e.jsxs("span",{className:"text-muted-foreground",children:[l.count," (",s,"%)"]})]}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${a(l.label)} rounded-full`,style:{width:`${s}%`}})})]},l.label)})})]})})}function ce(){const[n,m]=i.useState(void 0),[a,g]=i.useState(void 0),[c,r]=i.useState(void 0),[o,l]=i.useState(void 0),[s,L]=i.useState(void 0),[N,S]=i.useState(""),[y,u]=i.useState(""),b=i.useMemo(()=>{const t={};return n&&(t.brandId=n),a&&(t.gender=a),c&&(t.ageGroup=c),o&&(t.durationMonths=o),s&&(t.contractTypeId=s),N&&(t.dateFrom=new Date(N).getTime()),y&&(t.dateTo=new Date(y).getTime()+864e5-1),t},[n,a,c,o,s,N,y]),{data:j}=k.brands.list.useQuery(),{data:w}=k.contractTypes.list.useQuery({activeOnly:!1,...n?{brandId:n}:{}}),{data:h,isLoading:p}=k.contracts.demographics.useQuery(b),{data:d}=k.contracts.acquisitionBreakdown.useQuery(b),f=h?.byType??[],C=h?.byGender??[],M=h?.byAge??[],z=h?.byDuration??[],$=h?.byPurchaseReason??[],K=h?.byConsideredBefore??[],R=h?.byPreviousObjection??[],D=h?.surveyStats??{completed:0,total:0},V={friend_referral:"Freund / Empfehlung",instagram:"Instagram",facebook:"Facebook",tiktok:"TikTok",google_search:"Google-Suche",google_ads:"Google-Werbung",flyer_plakat:"Flyer / Plakat",walked_by:"Vorbeigelaufen",event:"Event / Messe",other:"Sonstiges"},O={proximity:"Nähe Wohnort/Arbeit",price_value:"Preis-Leistung",equipment:"Ausstattung & Geräte",current_offer:"Aktuelles Angebot",flexibility:"Flexible Laufzeiten",atmosphere:"Atmosphäre/Konzept",other:"Sonstiges"},B={contract_term:"Vertragslaufzeit",price_too_high:"Preis zu hoch",time_doubt:"Zeit-Zweifel",comparing_studios:"Studios verglichen",forgot_followup:"Vergessen",other:"Sonstiges"},_=(d?.bySource??[]).map(t=>({label:V[t.source]??t.source,count:t.count})).sort((t,x)=>x.count-t.count),G=$.map(t=>({label:O[t.label]??t.label,count:t.count})),Z=R.map(t=>({label:B[t.label]??t.label,count:t.count})),I=K.map(t=>({label:t.label==="yes"?"Ja, schon mal überlegt":t.label==="no"?"Nein, erstmals":t.label,count:t.count})),W=t=>t==="MALE"?"Männlich":t==="FEMALE"?"Weiblich":t==="DIVERSE"?"Divers":"Unbekannt",q=t=>t==="MALE"?"bg-blue-500":t==="FEMALE"?"bg-pink-500":"bg-muted-foreground",Q=t=>{const x=parseInt(t);return x<=1?"bg-emerald-400":x<=12?"bg-emerald-500":"bg-emerald-700"},U=t=>t.startsWith("Ja")?"bg-orange-500":"bg-slate-400",H=Array.from(new Set(z.map(t=>parseInt(t.label)).filter(t=>!isNaN(t)))),P=[n,a,c,o,s,N,y].filter(Boolean).length,J=()=>{m(void 0),g(void 0),r(void 0),l(void 0),L(void 0),S(""),u("")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-5 h-5 text-muted-foreground"}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Vertrags-Auswertung"})]}),P>0&&e.jsxs("button",{type:"button",onClick:J,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[e.jsx(X,{className:"w-3 h-3"}),"Filter zurücksetzen (",P,")"]})]}),e.jsx(F,{className:"bg-card border-border",children:e.jsxs(E,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"Filter"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Marke"}),e.jsxs("select",{className:"w-full text-sm bg-background border border-border rounded-md px-2 py-1.5 text-foreground",value:n??"",onChange:t=>m(t.target.value?Number(t.target.value):void 0),children:[e.jsx("option",{value:"",children:"Alle Marken"}),(j??[]).map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Vertragstyp"}),e.jsxs("select",{className:"w-full text-sm bg-background border border-border rounded-md px-2 py-1.5 text-foreground",value:s??"",onChange:t=>L(t.target.value?Number(t.target.value):void 0),children:[e.jsx("option",{value:"",children:"Alle Typen"}),(w??[]).map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Laufzeit"}),e.jsxs("select",{className:"w-full text-sm bg-background border border-border rounded-md px-2 py-1.5 text-foreground",value:o??"",onChange:t=>l(t.target.value?Number(t.target.value):void 0),children:[e.jsx("option",{value:"",children:"Alle Laufzeiten"}),H.sort((t,x)=>t-x).map(t=>e.jsxs("option",{value:t,children:[t," Monate"]},t))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Geschlecht"}),e.jsx("div",{className:"flex gap-1",children:["MALE","FEMALE","DIVERSE"].map(t=>e.jsx("button",{type:"button",onClick:()=>g(a===t?void 0:t),className:`flex-1 text-xs px-2 py-1.5 rounded-md border transition-colors ${a===t?"bg-primary text-primary-foreground border-primary":"bg-background text-foreground border-border hover:bg-muted"}`,children:t==="MALE"?"M":t==="FEMALE"?"W":"D"},t))})]}),e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Altersgruppe"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:te.map(t=>e.jsx("button",{type:"button",onClick:()=>r(c===t?void 0:t),className:`text-xs px-2 py-1.5 rounded-md border transition-colors ${c===t?"bg-primary text-primary-foreground border-primary":"bg-background text-foreground border-border hover:bg-muted"}`,children:t},t))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Von"}),e.jsx("input",{type:"date",value:N,onChange:t=>S(t.target.value),className:"w-full text-sm bg-background border border-border rounded-md px-2 py-1.5 text-foreground"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Bis"}),e.jsx("input",{type:"date",value:y,onChange:t=>u(t.target.value),className:"w-full text-sm bg-background border border-border rounded-md px-2 py-1.5 text-foreground"})]})]})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Gesamt Verträge",value:f.reduce((t,x)=>t+x.count,0)},{label:"Akquise erfasst",value:d?`${d.totalWithSource} / ${d.totalWithSource+d.totalWithoutSource}`:"–"},{label:"Umfrage abgeschlossen",value:`${D.completed} / ${D.total}`},{label:"Mit Geschlecht / Alter",value:`${C.reduce((t,x)=>t+x.count,0)} / ${M.reduce((t,x)=>t+x.count,0)}`}].map(({label:t,value:x})=>e.jsx(F,{className:"bg-card border-border",children:e.jsxs(E,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:t}),e.jsx("p",{className:"text-xl font-bold text-foreground",children:p?"–":x})]})},t))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(v,{title:"Vertragstypen",rows:f,colorFn:()=>"bg-primary",labelFn:t=>t,loading:p}),e.jsx(v,{title:"Laufzeit",rows:z,colorFn:Q,labelFn:t=>t,loading:p}),e.jsx(v,{title:"Geschlecht",rows:C,colorFn:q,labelFn:W,loading:p}),e.jsx(v,{title:"Altersgruppen",rows:M,colorFn:()=>"bg-amber-500",labelFn:t=>t,loading:p})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(T,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Umfrage-Antworten"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(v,{title:"Akquise-Quellen (Frage 1)",rows:_,colorFn:()=>"bg-orange-500",labelFn:t=>t,loading:!d}),e.jsx(v,{title:"Kaufgrund (Frage 2)",rows:G,colorFn:()=>"bg-violet-500",labelFn:t=>t,loading:p,emptyHint:"Noch keine Antworten in diesem Filter"}),e.jsx(v,{title:"Schon mal überlegt? (Frage 3)",rows:I,colorFn:U,labelFn:t=>t,loading:p,emptyHint:"Noch keine Antworten in diesem Filter"}),e.jsx(v,{title:"Hürden bei Wiederkommer (Frage 3b)",rows:Z,colorFn:()=>"bg-red-500",labelFn:t=>t,loading:p,emptyHint:"Noch keine Wiederkommer-Antworten"})]}),e.jsx(re,{brandId:n,dateFrom:b.dateFrom,dateTo:b.dateTo}),e.jsx(ae,{brandId:n,dateFrom:b.dateFrom,dateTo:b.dateTo})]})}function re({brandId:n,dateFrom:m,dateTo:a}){const[g,c]=i.useState(!0),r=k.contracts.distanceBuckets.useQuery({brandId:n??0,dateFrom:m,dateTo:a,bucketSizeKm:2,maxKm:30,onlyOnline:g},{enabled:!!n});if(!n)return e.jsx("div",{className:"rounded-xl border border-border p-4 text-sm text-muted-foreground",children:"Wähle eine Marke um die Distanz-Verteilung zu sehen."});if(r.isLoading)return e.jsx("div",{className:"rounded-xl border border-border p-4 text-sm",children:"Lade Distanz-Daten…"});if(!r.data)return null;const o=r.data;if(!o.brand?.hasCoords)return e.jsxs("div",{className:"rounded-xl border border-yellow-500/40 bg-yellow-500/5 p-4 text-sm",children:[e.jsx("strong",{children:"Studio-Koordinaten fehlen."}),' Bitte in den Brand-Einstellungen unter „Studio-Lat/Lng" hinterlegen, damit die Distanz-Auswertung funktioniert.']});const l=Math.max(1,...o.buckets.map(s=>s.count));return e.jsxs("div",{className:"rounded-xl border border-border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 gap-3 flex-wrap",children:[e.jsx("h3",{className:"font-semibold",children:"Verträge nach Entfernung zum Studio"}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-xs",children:[e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:s=>c(s.target.checked)}),"Nur Online-Verträge"]}),e.jsxs("div",{className:"text-muted-foreground",children:["⌀ Distanz: ",e.jsx("strong",{children:o.avgKm!=null?`${o.avgKm} km`:"—"})," · ",o.withDistance,"/",o.totalContracts," mit PLZ",o.withoutDistance>0&&` · ${o.withoutDistance} ohne PLZ`]})]})]}),e.jsx("div",{className:"space-y-1.5",children:o.buckets.map(s=>e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("div",{className:"w-24 text-xs text-muted-foreground tabular-nums",children:s.rangeKm}),e.jsxs("div",{className:"flex-1 h-6 bg-muted rounded overflow-hidden relative",children:[e.jsx("div",{className:"h-full bg-orange-500 transition-all",style:{width:`${s.count/l*100}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center px-2 text-xs font-semibold",children:s.count>0?`${s.count} (${s.pct}%)`:"—"})]})]},s.rangeKm))}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["Distanz via P
1LZ-Lookup (DE-Postleitzahlen).",g?" Standardmäßig nur Online-Verträge — bei Magicline-Imports + Studio-Walk-ins fehlt meist die PLZ. Toggle abschalten um alle zu sehen.":" Magicline-Importe und Studio-Walk-ins haben oft keine PLZ — wenn 'ohne PLZ' hoch ist, ist das normal."]})]})}let A=null;const se=[{js:"https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js",css:"https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"},{js:"https://unpkg.com/[email protected]/dist/leaflet.js",css:"https://unpkg.com/[email protected]/dist/leaflet.css"}];function ne(){return typeof window<"u"&&window.L?Promise.resolve():A||(A=(async()=>{let n=null;for(const m of se)try{if(!document.querySelector("link[data-leaflet-css]")){const a=document.createElement("link");a.rel="stylesheet",a.href=m.css,a.setAttribute("data-leaflet-css","1"),document.head.appendChild(a)}if(await new Promise((a,g)=>{const c=document.createElement("script");c.src=m.js,c.onload=()=>a(),c.onerror=()=>g(new Error(`CDN ${m.js} blockiert oder offline`)),document.head.appendChild(c)}),window.L)return}catch(a){n=a;continue}throw n??new Error("Leaflet konnte nicht geladen werden")})(),A)}function ae({brandId:n,dateFrom:m,dateTo:a}){const[g,c]=i.useState(!0),r=k.contracts.contractPinMap.useQuery({brandId:n??0,dateFrom:m,dateTo:a,onlyOnline:g},{enabled:!!n}),o=i.useRef(null),l=i.useRef(null),s=i.useRef(null),[L,N]=i.useState(!1),[S,y]=i.useState(null);return i.useEffect(()=>{ne().then(()=>N(!0)).catch(u=>y(u.message))},[]),i.useEffect(()=>{if(!L||!o.current||!r.data||!r.data.brand?.hasCoords)return;const u=window.L,b=Number(r.data.brand.lat),j=Number(r.data.brand.lng);if(!Number.isFinite(b)||!Number.isFinite(j))return;if(!l.current){const d=u.map(o.current,{scrollWheelZoom:!1}).setView([b,j],11);u.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"© OpenStreetMap",maxZoom:18}).addTo(d),l.current=d}const w=l.current;s.current&&(w.removeLayer(s.current),s.current=null);const h=u.layerGroup().addTo(w);s.current=h;const p=u.divIcon({className:"",html:'<div style="background:#10b981;width:26px;height:26px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);border:2px solid #fff;box-shadow:0 2px 6px rgba(0,0,0,0.4);display:flex;align-items:center;justify-content:center"><span style="transform:rotate(45deg);color:#fff;font-weight:bold;font-size:12px">★</span></div>',iconSize:[26,26],iconAnchor:[13,26]});u.marker([b,j],{icon:p}).addTo(h).bindPopup(`<b>${r.data.brand.name??"Studio"}</b><br/>Studio-Standort`),r.data.avgKm&&u.circle([b,j],{radius:r.data.avgKm*1e3,color:"#f97316",fillColor:"#f97316",fillOpacity:.05,weight:1,dashArray:"6 6"}).addTo(h).bindPopup(`Durchschnitts-Radius: <b>${r.data.avgKm} km</b>`);for(const d of r.data.pins){const f=Math.min(48,20+d.count*4),C=u.divIcon({className:"",html:`<div style="background:#f97316;color:#fff;width:${f}px;height:${f}px;border-radius:50%;border:2px solid #fff;box-shadow:0 2px 6px rgba(0,0,0,0.4);display:flex;align-items:center;justify-content:center;font-size:${Math.max(10,f/3)}px;font-weight:bold">${d.count}</div>`,iconSize:[f,f],iconAnchor:[f/2,f/2]});u.marker([d.lat,d.lng],{icon:C}).addTo(h).bindPopup(`<b>${d.count} Vertrag${d.count===1?"":"e"}</b><br/>PLZ: ${d.zipCodes.join(", ")}<br/>Distanz: ${d.distanceKm} km`)}if(r.data.pins.length>0){const d=u.latLngBounds([[b,j],...r.data.pins.map(f=>[f.lat,f.lng])]);w.fitBounds(d,{padding:[40,40],maxZoom:13})}else w.setView([b,j],11);setTimeout(()=>w.invalidateSize(),100)},[L,r.data]),i.useEffect(()=>()=>{l.current&&(l.current.remove(),l.current=null,s.current=null)},[]),n?r.isLoading?e.jsx("div",{className:"rounded-xl border border-border p-4 text-sm",children:"Lade Karten-Daten…"}):r.data?r.data.brand?.hasCoords?e.jsxs("div",{className:"rounded-xl border border-border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"font-semibold",children:"Vertragskunden auf der Karte"})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-xs",children:[e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:u=>c(u.target.checked)}),"Nur Online-Verträge"]}),e.jsxs("div",{className:"text-muted-foreground",children:["⌀ Distanz: ",e.jsx("strong",{className:"text-foreground",children:r.data.avgKm!=null?`${r.data.avgKm} km`:"—"})," · ",e.jsx("strong",{className:"text-foreground",children:r.data.withCoords}),"/",r.data.totalContracts," auf Karte",r.data.withoutCoords>0&&` · ${r.data.withoutCoords} ohne PLZ`]})]})]}),S?e.jsxs("div",{className:"text-sm text-red-500",children:["Karte konnte nicht geladen werden: ",S]}):e.jsx("div",{ref:o,className:"w-full h-[480px] rounded-lg overflow-hidden border border-border bg-muted"}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-xs text-muted-foreground flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded-full bg-emerald-500 border border-white"})," Studio"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded-full bg-orange-500 border border-white"})," Vertragskunde (Zahl = Anzahl an dieser PLZ)"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-4 h-0.5 border-t border-dashed border-orange-500"})," Durchschnitts-Radius"]}),e.jsx("div",{className:"ml-auto",children:"Genauigkeit: PLZ-Centroid (~5–15 km)."})]})]}):e.jsxs("div",{className:"rounded-xl border border-yellow-500/40 bg-yellow-500/5 p-4 text-sm",children:[e.jsx("strong",{children:"Studio-Koordinaten fehlen."})," Bitte in den Brand-Einstellungen Studio-Lat/Lng pflegen."]}):null:e.jsx("div",{className:"rounded-xl border border-border p-4 text-sm text-muted-foreground",children:"Wähle eine Marke um die Vertragskunden auf der Karte zu sehen."})}export{ce 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.