PageSourceSearch

https://crewops.lovable.app/assets/AICalls-XaEMIuo4.js

js crewops.lovable.app collected 2026-10-03 03:22:35 UTC 8,692 bytes, 6 lines download raw bytes

1import{c as P,ab as R,u as M,r as d,ad as q,bI as V,j as e,aq as K,Q as r,$ as n,P as g,bP as U,C as B,as as N,at as f,au as y,av as v,aw as a,a1 as C,V as Y,Y as z,m as t,aY as H,aZ as $,a7 as Q,aj as J,ap as Z,a_ as G,a$ as j,B as W,K as X,ac as ee,c1 as se}from"./index-B01jGDSO.js";import{E as ae}from"./external-link-Clh8aBfZ.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const te=P("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);function le(){const{orgId:h}=R(),_=M(),[i,b]=d.useState("all"),[c,E]=d.useState("all"),[x,w]=d.useState(""),[o,I]=d.useState(""),[S,T]=d.useState(null),{data:m=[],isLoading:D}=q({queryKey:["vapi-call-log",h,i,c,x,o],queryFn:async()=>{let s=X.from("vapi_call_log").select("*").eq("tenant_id",h).order("created_at",{ascending:!1}).limit(200);i!=="all"&&(s=s.eq("assistant_type",i)),c!=="all"&&(s=s.eq("status",c)),x&&(s=s.gte("created_at",ee(new Date(x)).toISOString())),o&&(s=s.lte("created_at",se(new Date(o)).toISOString()));const{data:l,error:p}=await s;if(p)throw p;return l||[]},enabled:!!h}),u=m.filter(s=>V(new Date(s.created_at))),L=u.filter(s=>s.assistant_type==="CUSTOMER_INTAKE").length,O=u.filter(s=>s.assistant_type==="EMPLOYEE_CALLIN").length,k=u.filter(s=>s.assistant_type==="CUSTOMER_INTAKE"&&s.related_entity_type==="lead").length,A=s=>s==="CUSTOMER_INTAKE"?e.jsx(t,{className:"bg-blue-100 text-blue-800 border-blue-200",children:"Customer Intake"}):s==="EMPLOYEE_CALLIN"?e.jsx(t,{className:"bg-orange-100 text-orange-800 border-orange-200",children:"Employee Call-In"}):e.jsx(t,{variant:"outline",children:s}),F=s=>s==="PROCESSED"?e.jsx(t,{variant:"default",children:"Processed"}):s==="FAILED"?e.jsx(t,{variant:"destructive",children:"Failed"}):e.jsx(t,{variant:"secondary",children:"Received"});return e.jsx(K,{title:"AI Calls",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(r,{children:e.jsxs(n,{className:"pt-4 flex items-center gap-3",children:[e.jsx(g,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Calls Today"}),e.jsx("p",{className:"text-2xl font-bold",children:u.length})]})]})}),e.jsx(r,{children:e.jsxs(n,{className:"pt-4 flex items-center gap-3",children:[e.jsx(U,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"New Leads Today"}),e.jsx("p",{className:"text-2xl font-bold",children:k})]})]})}),e.jsx(r,{children:e.jsxs(n,{className:"pt-4 flex items-center gap-3",children:[e.jsx(te,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customer Intakes"}),e.jsx("p",{className:"text-2xl font-bold",children:L})]})]})}),e.jsx(r,{children:e.jsxs(n,{className:"pt-4 flex items-center gap-3",children:[e.jsx(B,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Employee Call-Ins"}),e.jsx("p",{className:"text-2xl font-bold",children:O})]})]})})]}),e.jsx(r,{children:e.jsx(n,{className:"pt-4",children:e.jsxs("div",{className:"flex flex-wrap gap-3 items-end",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Call Type"}),e.jsxs(N,{value:i,onValueChange:b,children:[e.jsx(f,{className:"w-[160px]",children:e.jsx(y,{})}),e.jsxs(v,{children:[e.jsx(a,{value:"all",children:"All Types"}),e.jsx(a,{value:"CUSTOMER_INTAKE",children:"Customer Intake"}),e.jsx(a,{value:"EMPLOYEE_CALLIN",children:"Employee Call-In"}),e.jsx(a,{value:"OTHER",children:"Other"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsxs(N,{value:c,onValueChange:E,children:[e.jsx(f,{className:"w-[140px]",children:e.jsx(y,{})}),e.jsxs(v,{children:[e.jsx(a,{value:"all",children:"All"}),e.jsx(a,{value:"RECEIVED",children:"Received"}),e.jsx(a,{value:"PROCESSED",children:"Processed"}),e.jsx(a,{value:"FAILED",children:"Failed"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"From"}),e.jsx(C,{type:"date",value:x,onChange:s=>w(s.target.value),className:"w-[150px]"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"To"}),e.jsx(C,{type:"date",value:o,onChange:s=>I(s.target.value),className:"w-[150px]"})]})]})})}),e.jsxs(r,{children:[e.jsx(Y,{children:e.jsxs(z,{className:"flex items-center gap-2",children:[e.jsx(g,{className:"h-5 w-5"})," Call Log",e.jsxs(t,{variant:"outline",className:"ml-2",children:[m.length," calls"]})]})}),e.jsx(n,{className:"space-y-2",children:D?e.jsx("div",{className:"flex justify-center p-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):m.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No AI calls recorded yet."}):m.map(s=>{const l=S===s.id;return e.jsxs(H,{open:l,onOpenChange:()=>T(l?null:s.id),children:[e.jsx($,{className:"w-full",children:e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-accent/5 transition-colors text-left",children:[l?e.jsx(Q,{className:"h-4 w-4 shrink-0"}):e.jsx(J,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[A(s.assistant_type||"OTHER"),F(s.status||"RECEIVED"),e.jsx("span",{className:"text-sm font-medium truncate",children:s.caller_name||s.phone_number||"Unknown"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1",children:s.summary||"No summary available"})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:Z(new Date(s.created_at),"MMM d, h:mm a")}),s.duration_seconds&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.floor(s.duration_seconds/60),"m ",s.duration_seconds%60,"s"]})]})]})}),e.jsx(G,{children:e.jsxs("div",{className:"ml-7 p-4 border rounded-lg mt-1 
6space-y-4 bg-muted/5",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Phone:"})," ",s.phone_number||"—"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Caller:"})," ",s.caller_name||"—"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Assistant ID:"})," ",e.jsx("code",{className:"text-xs",children:s.assistant_id||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Vapi Call ID:"})," ",e.jsx("code",{className:"text-xs",children:s.vapi_call_id||"—"})]})]}),s.summary&&e.jsxs(e.Fragment,{children:[e.jsx(j,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"AI Summary"}),e.jsx("p",{className:"text-sm",children:s.summary})]})]}),s.transcript&&e.jsxs(e.Fragment,{children:[e.jsx(j,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Transcript"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap max-h-60 overflow-y-auto bg-background p-3 rounded border",children:s.transcript})]})]}),s.structured_data&&e.jsxs(e.Fragment,{children:[e.jsx(j,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Structured Data"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap max-h-40 overflow-y-auto bg-background p-3 rounded border",children:JSON.stringify(s.structured_data,null,2)})]})]}),s.related_entity_id&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{s.related_entity_type==="lead"&&_(`/workflow-baskets/${s.related_entity_id}`)},children:[e.jsx(ae,{className:"h-3.5 w-3.5 mr-1"}),"View ",s.related_entity_type==="lead"?"Deal":s.related_entity_type]})})]})})]},s.id)})})]})]})})}export{le 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.