PageSourceSearch

https://olmatic.de/assets/AdminChats-D-gjIt8i.js

js olmatic.de collected 2026-10-07 08:11:36 UTC 7,459 bytes, 1 lines download raw bytes

1import{r,j as e}from"./vendor-DJCVV3L2.js";import{u as M,l as j,a6 as S,a3 as k,B as g,L as v,h as E}from"./main-DVQNsi_T.js";import{A,M as B}from"./AdminLayout-CVXtqMn2.js";import{C as n,c as l,a as q,b as K}from"./card-Dgf-Dxbh.js";import{B as x}from"./badge-BFjWlRXd.js";import{e as $,f as N}from"./admin-utils-DQrH-A6y.js";import{R as z}from"./refresh-cw-BFlv3LC1.js";import{M as D}from"./mail-DaejvSxC.js";import{E as R}from"./external-link-B8ZFG3tR.js";import"./ui-qUi9xOTj.js";import"./charts-BDPybT6A.js";import"./copy-pB5JoC1o.js";import"./linkedin-DZCNe5Ra.js";import"./users-BKIhgdMI.js";import"./rocket-A4UDKEJK.js";import"./layout-grid-D_dCZR5D.js";import"./trending-up-BNQOTo56.js";import"./chart-column-DFctOWjX.js";import"./euro-DBmZ53ji.js";import"./upload-TydSMrQH.js";import"./target-d1GUhLKH.js";import"./shield-check-e2FLYUN8.js";import"./rotate-ccw-Bks4zM0H.js";import"./markdown-BWKeh4hC.js";import"./user-DBwkCuid.js";import"./check-C_U2Wh1L.js";import"./circle-bQUgh4My.js";import"./dialog-GxSyEpzI.js";function he(){const{toast:_}=M(),[i,y]=r.useState([]),[c,h]=r.useState(!0),[m,b]=r.useState(""),[t,w]=r.useState(null),[C,u]=r.useState([]),[L,p]=r.useState(!1),f=async()=>{h(!0);const{data:s,error:a}=await j.from("chat_conversations").select("*").order("last_message_at",{ascending:!1}).limit(1e3);if(h(!1),a){_({title:"Konnte nicht laden",description:a.message,variant:"destructive"});return}y(s??[])};r.useEffect(()=>{f()},[]),r.useEffect(()=>{if(!t){u([]);return}p(!0),j.from("chat_messages").select("*").eq("conversation_id",t.id).order("created_at",{ascending:!0}).then(({data:s})=>{u(s??[]),p(!1)})},[t]);const d=i.filter(s=>{if(!m.trim())return!0;const a=m.toLowerCase();return(s.email??"").toLowerCase().includes(a)||(s.started_on_path??"").toLowerCase().includes(a)||s.session_id.toLowerCase().includes(a)}),o={total:i.length,converted:i.filter(s=>s.converted_lead).length,withEmail:i.filter(s=>s.email).length,avgMsgs:i.length?Math.round(i.reduce((s,a)=>s+a.message_count,0)/i.length*10)/10:0};return e.jsx(A,{title:"Chats",description:"Was Lea Haller (unser Chatbot) mit Website-Besuchern besprochen hat",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 lg:grid-cols-4",children:[e.jsx(n,{children:e.jsxs(l,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Konversationen"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:o.total})]})}),e.jsx(n,{children:e.jsxs(l,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Mit E-Mail"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:o.withEmail})]})}),e.jsx(n,{children:e.jsxs(l,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Zu Lead konvertiert"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-primary",children:o.converted})]})}),e.jsx(n,{children:e.jsxs(l,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ø Nachrichten"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:o.avgMsgs})]})})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[1fr_1.2fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(S,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(k,{placeholder:"E-Mail, Pfad, Session…",value:m,onChange:s=>b(s.target.value),className:"pl-9"})]}),e.jsx(g,{variant:"outline",size:"icon",onClick:f,disabled:c,children:e.jsx(z,{className:`h-4 w-4 ${c?"animate-spin":""}`})}),e.jsx(g,{variant:"outline",size:"sm",onClick:()=>$("chatverlaeufe.csv",d.map(s=>({datum:s.created_at,session_id:s.session_id,email:s.email??"",seite:s.started_on_path??"",nachrichten:s.message_count,konvertiert:s.converted_lead?"ja":"nein",conversion_typ:s.conversion_type??""}))),disabled:d.length===0,children:"CSV"})]}),e.jsx(n,{className:"overflow-hidden",children:c?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(v,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d.length===0?e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Noch keine Konversationen."}):e.jsx("div",{className:"divide-y divide-border max-h-[640px] overflow-auto",children:d.map(s=>e.jsxs("button",{onClick:()=>w(s),className:`w-full text-left p-3 hover:bg-muted/40 transition-colors ${(t==null?void 0:t.id)===s.id?"bg-muted/60":""}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:N(s.last_message_at)}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.converted_lead&&e.jsxs(x,{variant:"outline",className:"text-[10px] bg-primary/10 text-primary border-primary/30",children:[e.jsx(E,{className:"h-2.5 w-2.5 mr-1"}),"Lead"]}),e.jsxs(x,{variant:"outline",className:"text-[10px]",children:[e.jsx(B,{className:"h-2.5 w-2.5 mr-1"}),s.message_count]})]})]}),e.jsx("div",{className:"text-sm font-medium truncate",children:s.email?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"h-3 w-3 text-primary"}),s.email]}):e.jsx("span",{className:"text-muted-foreground italic",children:"Anonym"})}),s.started_on_path&&e.jsx("div",{className:"text-xs text-muted-foreground truncate mt-0.5",children:s.started_on_path})]},s.id))})})]}),e.jsx(n,{className:"min-h-[400px]",children:t?e.jsxs(e.Fragment,{children:[e.jsxs(q,{className:"border-b",children:[e.jsxs(K,{className:"text-base flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate",children:t.email||e.jsx("span",{className:"text-muted-foreground italic",children:"Anonym"})}),t.started_on_path&&e.jsxs("a",{href:t.started_on_path,target:"_blank",rel:"noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1 shrink-0 font-normal",children:[t.started_on_path,e.jsx(R,{className:"h-3 w-3"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Start: ",N(t.created_at)]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[t.message_count," Nachrichten"]}),t.converted_lead&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(x,{variant:"outline",className:"bg-primary/10 text-primary border-primary/30",children:["Lead: ",t.conversion_type]})]})]})]}),e.jsx(l,{className:"p-4 max-h-[640px] overflow-auto",children:L?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(v,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"space-y-3",children:C.map(s=>e.jsx("div",{className:`flex ${s.role==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 text-sm whitespace-pre-wrap ${s.role==="user"?"bg-primary text-primary-foreground rounded-br-md":"bg-muted text-foreground rounded-bl-md"}`,children:[s.content,e.jsx("div",{className:"text-[10px] mt-1 opacity-60",children:new Date(s.created_at).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})})]})},s.id))})})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground py-24",children:"Konversation auswählen, um Verlauf zu sehen"})})]})]})})}export{he 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.