PageSourceSearch

https://aevoice.ai/assets/ScheduledCalls-Cl7l1Y4_.js

js aevoice.ai collected 2026-10-05 15:15:04 UTC 14,946 bytes, 12 lines download raw bytes

1import{l as R,u as H,a as W,r as o,b as k,j as e,f as n,C as j,Q as S,I as d,L as G,p as i,_ as Z,P as ee,d as F,e as m,t as c}from"./index-DNGQdeph.js";import{u as te}from"./useMutation-PKYHwa1V.js";import{T as ae,a as se,b as A,c as le}from"./tabs-CvXZ4AkA.js";import{S as O,a as V,b as z,c as M,d as h}from"./select-CO7RB0GF.js";import{S as ne}from"./settings-2-baUlTeQG.js";import{P as Q}from"./plus-DUVAmSxo.js";import{C as U}from"./calendar-check-D0d2R3U1.js";import{R as re}from"./refresh-cw-CYtobtlh.js";import{E as ie}from"./external-link-Ce6kAGjt.js";import{C as ce}from"./circle-x-DwcCjJDC.js";import"./chevron-up-a4LlwORc.js";/**
2 * @license lucide-react v0.475.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 oe=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]],de=R("CalendarX",oe);/**
7 * @license lucide-react v0.475.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const me=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ue=R("Video",me),xe="https://base44.app/api/apps/69e3b213c502fe5e6e54a975/files/mp/public/69e3b213c502fe5e6e54a975/3e17b4b6b_aevoice_logo.jpg",$={pending:{label:"Pending",color:"bg-amber-500/10 text-amber-400 border-amber-500/20"},confirmed:{label:"Confirmed",color:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20"},in_progress:{label:"In Progress",color:"bg-blue-500/10 text-blue-400 border-blue-500/20"},completed:{label:"Completed",color:"bg-slate-500/10 text-slate-400 border-slate-600"},cancelled:{label:"Cancelled",color:"bg-red-500/10 text-red-400 border-red-500/20"},no_show:{label:"No Show",color:"bg-orange-500/10 text-orange-400 border-orange-500/20"}},he={inbound_callback:"📥 Callback",outbound_scheduled:"📤 Scheduled",follow_up:"🔄 Follow-up",demo:"🎯 Demo"};function pe(s){return s?new Date(s).toLocaleString("en-IN",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}):"—"}function Ge(){const{user:s}=H()||{},v=W(),[T,N]=o.useState(!1),[B,D]=o.useState(!1),[p,E]=o.useState(""),[I,q]=o.useState(!1),[L,P]=o.useState(!1),[l,r]=o.useState({client_name:"",client_phone:"",client_email:"",scheduled_at:"",duration_minutes:"15",notes:"",callback_type:"outbound_scheduled"}),{data:C=[],isLoading:K}=k({queryKey:["scheduledCalls",s==null?void 0:s.email],queryFn:()=>m.entities.ScheduledCall.filter({owner_email:s==null?void 0:s.email},"-scheduled_at",200),enabled:!!(s!=null&&s.email),refetchInterval:3e4}),{data:y}=k({queryKey:["gcalSettings",s==null?void 0:s.email],queryFn:async()=>(await m.entities.IntegrationSettings.filter({owner_email:s==null?void 0:s.email,integration_type:"google_calendar"}))[0]||null,enabled:!!(s!=null&&s.email)}),{data:ge=[]}=k({queryKey:["agents",s==null?void 0:s.email],queryFn:()=>m.entities.Agent.filter({owner_email:s==null?void 0:s.email}),enabled:!!(s!=null&&s.email)}),u=!!(y!=null&&y.api_key),_=te({mutationFn:({id:t,status:a})=>m.entities.ScheduledCall.update(t,{status:a}),onSuccess:()=>{v.invalidateQueries(["scheduledCalls"])}}),X=async()=>{if(p.trim()){q(!0);try{const t=await m.functions.gcalSync({action:"save_credentials",owner_email:s==null?void 0:s.email,token:p.trim()});t!=null&&t.ok?(c({title:"Google Calendar connected!",description:"Events will now sync automatically."}),v.invalidateQueries(["gcalSettings"]),D(!1),E("")):c({title:"Connection failed",description:(t==null?void 0:t.error)||"Invalid token",variant:"destructive"})}catch(t){c({title:"Error",description:t.message,variant:"destructive"})}q(!1)}},J=async t=>{if(t.preventDefault(),!l.client_name||!l.scheduled_at){c({title:"Required fields missing",description:"Client name and scheduled time are required.",variant:"destructive"});return}P(!0);try{const a=await m.functions.gcalSync({action:"create_event",owner_email:s==null?void 0:s.email,...l,duration_minutes:parseInt(l.duration_minutes)||15});a!=null&&a.ok?(c({title:"Call scheduled!",description:a.google_calendar_connected?"Event created in Google Calendar ✓":"Saved to your schedule. Connect Google Calendar to sync."}
11),v.invalidateQueries(["scheduledCalls"]),N(!1),r({client_name:"",client_phone:"",client_email:"",scheduled_at:"",duration_minutes:"15",notes:"",callback_type:"outbound_scheduled"})):c({title:"Scheduling failed",description:(a==null?void 0:a.error)||"Unknown error",variant:"destructive"})}catch(a){c({title:"Error",description:a.message,variant:"destructive"})}P(!1)},g=new Date,x=C.filter(t=>t.status!=="cancelled"&&t.status!=="completed"&&new Date(t.scheduled_at)>=g),w=C.filter(t=>t.status==="completed"||t.status==="cancelled"||new Date(t.scheduled_at)<g),Y=x.filter(t=>new Date(t.scheduled_at).toDateString()===g.toDateString()).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:xe,alt:"AEVOICE",className:"w-8 h-8 rounded-lg object-cover",onError:t=>t.target.style.display="none"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-foreground",children:"Scheduled Calls"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage callback appointments with Google Calendar sync"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{size:"sm",variant:"outline",className:"gap-1.5 border-border",onClick:()=>D(t=>!t),children:[e.jsx(ne,{className:"w-3.5 h-3.5"}),u?"GCal ✓":"Connect GCal"]}),e.jsxs(n,{size:"sm",className:"gap-1.5",onClick:()=>N(t=>!t),children:[e.jsx(Q,{className:"w-4 h-4"}),T?"Cancel":"Schedule Call"]})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Upcoming",value:x.length,icon:j,color:"text-primary"},{label:"Today",value:Y,icon:U,color:"text-emerald-400"},{label:"Total",value:C.length,icon:S,color:"text-cyan-400"},{label:"GCal",value:u?"Connected":"Not Connected",icon:re,color:u?"text-green-400":"text-amber-400"}].map(({label:t,value:a,icon:b,color:f})=>e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(b,{className:`w-4 h-4 ${f}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]}),e.jsx("p",{className:`text-xl font-bold ${f}`,children:a})]},t))}),B&&e.jsxs("div",{className:"bg-card border border-border rounded-xl p-5",children:[e.jsxs("h3",{className:"font-semibold text-foreground mb-1 flex items-center gap-2",children:[e.jsx(j,{className:"w-4 h-4 text-primary"}),"Google Calendar Integration"]}),u?e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-lg p-3 mb-4",children:[e.jsx("p",{className:"text-emerald-400 text-sm font-medium",children:"✅ Google Calendar is connected"}),e.jsx("p",{className:"text-muted-foreground text-xs mt-1",children:"New scheduled calls will automatically create events with Google Meet links."})]}):null,e.jsxs("p",{className:"text-muted-foreground text-sm mb-4",children:["Paste a Google OAuth access token to connect your calendar. To get a token:"," ",e.jsxs("a",{href:"https://developers.google.com/oauthplayground",target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:["Google OAuth Playground ",e.jsx(ie,{className:"w-3 h-3 inline"})]})," ","→ select ",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"calendar.events"})," scope."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{value:p,onChange:t=>E(t.target.value),placeholder:"ya29.xxx... (OAuth access token)",type:"password",className:"flex-1 font-mono text-xs"}),e.jsx(n,{onClick:X,disabled:I||!p.trim(),children:I?e.jsx(G,{className:"w-4 h-4 animate-spin"}):"Connect"})]})]}),T&&e.jsxs("form",{onSubmit:J,className:"bg-card border border-border rounded-xl p-5 space-y-4",children:[e.jsxs("h3",{className:"font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 text-primary"}),"Schedule New Callback"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Client Name *"}),e.jsx(d,{value:l.client_name,onChange:t=>r(a=>({...a,client_name:t.target.value})),placeholder:"John Smith",required:!0})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Phone Number"}),e.jsx(d,{value:l.client_phone,onChange:t=>r(a=>({...a,client_phone:t.target.value})),placeholder:"+91 98765 43210",type:"tel"})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Email (for GCal inv
11ite)"}),e.jsx(d,{value:l.client_email,onChange:t=>r(a=>({...a,client_email:t.target.value})),placeholder:"[email protected]",type:"email"})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Scheduled At *"}),e.jsx(d,{value:l.scheduled_at,onChange:t=>r(a=>({...a,scheduled_at:t.target.value})),type:"datetime-local",required:!0})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Duration"}),e.jsxs(O,{value:l.duration_minutes,onValueChange:t=>r(a=>({...a,duration_minutes:t})),children:[e.jsx(V,{children:e.jsx(z,{})}),e.jsx(M,{children:["5","10","15","20","30","45","60"].map(t=>e.jsxs(h,{value:t,children:[t," minutes"]},t))})]})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Call Type"}),e.jsxs(O,{value:l.callback_type,onValueChange:t=>r(a=>({...a,callback_type:t})),children:[e.jsx(V,{children:e.jsx(z,{})}),e.jsxs(M,{children:[e.jsx(h,{value:"inbound_callback",children:"📥 Inbound Callback"}),e.jsx(h,{value:"outbound_scheduled",children:"📤 Outbound Scheduled"}),e.jsx(h,{value:"follow_up",children:"🔄 Follow-up"}),e.jsx(h,{value:"demo",children:"🎯 Demo"})]})]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(i,{className:"text-sm text-muted-foreground mb-1.5 block",children:"Notes"}),e.jsx(d,{value:l.notes,onChange:t=>r(a=>({...a,notes:t.target.value})),placeholder:"Discuss pricing, renewal, follow-up on enquiry..."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{type:"submit",disabled:L,className:"gap-2",children:[L?e.jsx(G,{className:"w-4 h-4 animate-spin"}):e.jsx(U,{className:"w-4 h-4"}),u?"Schedule + Add to Google Calendar":"Schedule Call"]}),e.jsx(n,{type:"button",variant:"outline",onClick:()=>N(!1),children:"Cancel"})]})]}),e.jsxs(ae,{defaultValue:"upcoming",children:[e.jsxs(se,{className:"bg-card border border-border",children:[e.jsxs(A,{value:"upcoming",className:"data-[state=active]:bg-primary/20 data-[state=active]:text-primary",children:[e.jsx(j,{className:"w-3.5 h-3.5 mr-1.5"}),"Upcoming (",x.length,")"]}),e.jsxs(A,{value:"past",className:"data-[state=active]:bg-primary/20 data-[state=active]:text-primary",children:[e.jsx(S,{className:"w-3.5 h-3.5 mr-1.5"}),"Past (",w.length,")"]})]}),["upcoming","past"].map(t=>e.jsx(le,{value:t,className:"mt-4",children:K?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(G,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):(t==="upcoming"?x:w).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-14 text-center",children:[e.jsx(de,{className:"w-10 h-10 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t==="upcoming"?"No upcoming calls. Click 'Schedule Call' to add one.":"No past calls yet."})]}):e.jsx("div",{className:"space-y-3",children:(t==="upcoming"?x:w).map(a=>{const b=$[a.status]||$.pending,f=new Date(a.scheduled_at)<g;return e.jsx("div",{className:`bg-card border rounded-xl p-4 transition-colors ${f&&t==="upcoming"?"border-amber-500/20 bg-amber-500/3":"border-border hover:border-primary/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[e.jsx("span",{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border ${b.color}`,children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:he[a.callback_type]||a.callback_type}),a.gcal_event_id&&e.jsxs("span",{className:"text-xs text-emerald-400 flex items-center gap-1",children:[e.jsx(j,{className:"w-3 h-3"})," GCal"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Z,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:a.client_name})]}),a.client_phone&&e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ee,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.client_phone})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[pe(a.scheduled_at)," · ",a.duration_minutes||15," min"]})]}),a.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5 italic",children:a.notes})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.gcal_meet_link&&e.jsx("a",{href:a.gcal_meet_link,target:"_blank",rel:"noreferrer",children:e.jsxs(n,{size:"sm",variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",children:[e.jsx(ue,{className:"w-3.5 h-3.5"}),"Meet"]})}),a.status==="pending"&&e.jsxs(n,{size:"sm",variant:"outline",className:"gap-1 text-xs text-emerald-400 border-emerald-500/30",onClick:()=>_.mutate({id:a.id,status:"confirmed"}),children:[e.jsx(F,{className:"w-3.5 h-3.5"}),"Confirm"]}),(a.status==="pending"||a.status==="confirmed")&&e.jsxs(n,{size:"sm",variant:"outline",className:"gap-1 text-xs text-red-400 border-red-500/30",onClick:()=>_.mutate({id:a.id,status:"cancelled"}),children:[e.jsx(ce,{className:"w-3.5 h-3.5"}),"Cancel"]}),a.status==="in_progress"&&e.jsxs(n,{size:"sm",variant:"outline",className:"gap-1 text-xs text-blue-400 border-blue-500/30",onClick:()=>_.mutate({id:a.id,status:"completed"}),children:[e.jsx(F,{className:"w-3.5 h-3.5"}),"Complete"]})]})]})},a.id)})})},t))]})]})}export{Ge as default};
12//# sourceMappingURL=ScheduledCalls-Cl7l1Y4_.js.map

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.