PageSourceSearch

https://www.agencycompass360.com/assets/ClientTranscriptsTab-B6wLYmz3.js

js agencycompass360.com collected 2026-10-09 22:02:58 UTC 5,912 bytes, 1 lines download raw bytes

1import{r as d,s as o,j as e,C as p,c as _,a as S,b as M,h as l,K as k,N as E,Q as T,bc as I,v as A,av as D,P as $,k as j,U as L}from"./index-cOhCav0w.js";import{M as g}from"./mic-Dvm0dI1Z.js";import{S as R}from"./star-D_iaMyws.js";function U({clientId:x,clientPhone:u}){const[h,N]=d.useState([]),[y,f]=d.useState(!0),[b,v]=d.useState(null);d.useEffect(()=>{w()},[x,u]);const w=async()=>{f(!0);const s=[],{data:r}=await o.from("live_transcriptions").select("*").eq("matched_client_id",x).order("created_at",{ascending:!1}).limit(50);let c=[];if(u){const a=u.replace(/\D/g,"").slice(-10);if(a.length>=7){const{data:n}=await o.from("live_transcriptions").select("*").or(`caller_number.ilike.%${a}%,called_number.ilike.%${a}%`).is("matched_client_id",null).order("created_at",{ascending:!1}).limit(50);c=n||[]}}const m=new Map;[...r||[],...c].forEach(a=>m.set(a.id,a));for(const a of m.values())(a.ai_summary&&a.ai_summary.trim().length>0||a.transcript&&a.transcript.trim().length>0)&&s.push({id:`lt-${a.id}`,source:"live_transcription",date:a.started_at||a.created_at,ai_summary:a.ai_summary,ai_score:null,caller_number:a.caller_number||a.called_number,agent_name:a.agent_name,status:a.status,transcript:a.transcript,segments:a.committed_segments||[],direction:a.direction,duration_seconds:null,caller_name:null,score_reason:null});const{data:i}=await o.from("policies").select("id").eq("client_id",x);if(i&&i.length>0){const a=i.map(t=>t.id),{data:n}=await o.from("policy_call_summaries").select("*").in("policy_id",a).order("created_at",{ascending:!1}).limit(50);if(n)for(const t of n)s.push({id:`pcs-${t.id}`,source:"policy_call_summary",date:t.call_started_at||t.created_at,ai_summary:t.ai_summary,ai_score:t.ai_score,caller_number:t.caller_phone||null,agent_name:t.caller_name||null,status:"completed",transcript:null,segments:[],direction:t.call_direction,duration_seconds:t.call_duration_seconds,caller_name:t.caller_name,score_reason:t.ai_score_reason})}s.sort((a,n)=>new Date(n.date).getTime()-new Date(a.date).getTime()),N(s),f(!1)},C=s=>{if(s===null)return null;const r=s>=8?"text-emerald-600 border-emerald-500":s>=6?"text-amber-600 border-amber-500":"text-rose-600 border-rose-500";return e.jsxs(l,{variant:"outline",className:`${r} text-xs`,children:[e.jsx(R,{className:"h-3 w-3 mr-0.5"}),s,"/10"]})};return y?e.jsx(p,{children:e.jsx(_,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(g,{className:"h-4 w-4 animate-pulse"}),"Loading call summaries..."]})})}):h.length===0?e.jsx(p,{children:e.jsxs(_,{className:"p-6 text-center text-muted-foreground",children:[e.jsx(g,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No call summaries yet"}),e.jsx("p",{className:"text-sm mt-1",children:"AI-generated call summaries will appear here when calls are matched to this client."})]})}):e.jsxs(p,{children:[e.jsx(S,{className:"pb-3",children:e.jsxs(M,{className:"text-base flex items-center gap-2",children:[e.jsx(g,{className:"h-4 w-4"}),"Call Summaries",e.jsx(l,{variant:"secondary",className:"ml-1",children:h.length})]})}),e.jsx(_,{className:"p-0",children:e.jsx("div",{className:"divide-y",children:h.map(s=>{var a;const r=b===s.id,c=new Date(s.date),m=s.status==="active",i=s.ai_summary?s.ai_summary.substring(0,120):((a=s.transcript)==null?void 0:a.substring(0,120))||"No summary available";return e.jsxs(k,{open:r,onOpenChange:()=>v(r?null:s.id),children:[e.jsx(E,{className:"w-full px-4 py-3 hover:bg-muted/50 transition-colors text-left",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r?e.jsx(T,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}):e.jsx(I,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:A(c,"MMM d, yyyy h:mm a")}),m&&e.jsx(l,{variant:"default",className:"bg-green-500 text-white text-xs",children:"LIVE"}),s.status==="completed"&&e.jsx(l,{variant:"outline",className:"text-xs",children:"Completed"}),s.ai_summary&&e.jsx(l,{variant:"secondary",className:"text-xs",children:"AI Summary"}),s.direction&&e.jsx(l,{variant:"secondary",className:"text-xs",children:s.direction==="outbound"?"↗ Out":"↙ In"}),C(s.ai_score)]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 truncate max-w-md",children:[i,"..."]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground flex-shrink-0",children:[s.agent_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"h-3 w-3"}),s.agent_name]}),s.caller_number&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($,{className:"h-3 w-3"}),s.caller_number]}),s.duration_seconds&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(j,{className:"h-3 w-3"}),Math.floor(s.duration_seconds/60),"m ",s.duration_seconds%60,"s"]}),s.segments.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(j,{className:"h-3 w-3"}),s.segments.length," segments"]})]})]})}),e.jsx(L,{children:e.jsxs("div",{className:"px-4 pb-4 pt-1 space-y-2",children:[s.ai_summary?e.jsx("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:s.ai_summary}):s.transcript?e.jsxs("div",{className:"text-sm text-muted-foreground italic",children:["AI summary not yet generated. Raw transcript available (",s.transcript.length," characters)."]}):e.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No detailed content available."}),s.score_reason&&e.jsxs("p",{className:"text-xs text-muted-foreground italic border-t pt-2 mt-2",children:["Score reason: ",s.score_reason]})]})})]},s.id)})})})]})}export{U as ClientTranscriptsTab};

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.