PageSourceSearch

https://tariffrecoveryagency.com/assets/RelationshipsLayout-Cd8Lu9xW.js

js tariffrecoveryagency.com collected 2026-10-01 23:58:21 UTC 8,863 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-DUki8u-D.js";import{r,u as O,k as B,O as q}from"./vendor-react-DHU755GE.js";import{I as H,B as k,aO as m}from"./App-DNURBdOM.js";import{c as A,f as F,d as _}from"./rel-hub-oYy-v-4-.js";import{S as G,b as U,c as V,d as W}from"./sheet-DDAHMz7p.js";import{S as K}from"./scroll-area-C5uKDqac.js";import{a1 as T,L as Z,aB as J,cE as P,a as Q,ax as X,bZ as Y,T as I,g as ee,a$ as se,c9 as ae,aq as te,at as ne}from"./vendor-icons-D7GmeyGG.js";import{S as re,a as oe,b as ie,c as le,d as w}from"./select-BJ2LQ1BA.js";import{A as M,b as R,a as z}from"./alert-DrXqJ_mR.js";import{supabase as ce}from"./client-Dy2P3he-.js";import"./vendor-pdf-DHUBMtDJ.js";import"./error-reporter-EYiXaqJQ.js";import"./breadcrumbs-CN3GC8vy.js";import"./vendor-charts-DsctC1NR.js";import"./useTheme-DEq4C3Xf.js";import"./vendor-supabase-D2XPrbcR.js";import"./vendor-motion-DoyUfQ58.js";import"./index-BdQq_4o_.js";import"./index-BFcYZw7s.js";const de=["What's happening with my top 5 partners this week?","Which referral partners haven't I talked to in 30 days?","List my open commitments grouped by relationship","Show meetings this week and what I should prep for each"];function me({open:p,onOpenChange:N}){const[u,f]=r.useState(""),[c,S]=r.useState(!1),[h,y]=r.useState([]),o=r.useRef(null);r.useEffect(()=>{var t;(t=o.current)==null||t.scrollTo({top:o.current.scrollHeight,behavior:"smooth"})},[h,c]);async function j(t){if(!(!t.trim()||c)){y(n=>[...n,{role:"user",content:t}]),f(""),S(!0);try{const n=await A("rel-ask-ai",{prompt:t});y(g=>[...g,{role:"assistant",content:(n==null?void 0:n.answer)||"(no answer)"}])}catch(n){y(g=>[...g,{role:"assistant",content:`Error: ${(n==null?void 0:n.message)??n}`}])}finally{S(!1)}}}return e.jsx(G,{open:p,onOpenChange:N,children:e.jsxs(U,{side:"right",className:"w-full sm:max-w-xl flex flex-col p-0",children:[e.jsx(V,{className:"p-4 border-b",children:e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(T,{className:"size-4 text-violet-600"})," Ask the Relationship AI"]})}),e.jsx(K,{className:"flex-1",children:e.jsxs("div",{ref:o,className:"p-4 space-y-3",children:[h.length===0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ask anything about your contacts, threads, meetings, and tasks. The AI queries your live data."}),e.jsx("div",{className:"grid gap-2",children:de.map(t=>e.jsx("button",{onClick:()=>j(t),className:"text-left text-sm px-3 py-2 rounded-lg border bg-muted/40 hover:bg-muted transition-colors",children:t},t))})]}),h.map((t,n)=>e.jsx("div",{className:`max-w-[92%] rounded-xl px-3 py-2 text-sm whitespace-pre-wrap ${t.role==="user"?"ml-auto bg-primary text-primary-foreground":"bg-muted"}`,children:t.content},n)),c&&e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(Z,{className:"size-3.5 animate-spin"}),"Thinking…"]})]})}),e.jsxs("div",{className:"p-3 border-t flex gap-2",children:[e.jsx(H,{value:u,onChange:t=>f(t.target.value),onKeyDown:t=>{t.key==="Enter"&&j(u)},placeholder:"Ask about a relationship, task, or follow-up…",disabled:c}),e.jsx(k,{onClick:()=>j(u),disabled:c||!u.trim(),children:e.jsx(J,{className:"size-4"})})]})]})})}const ue=[{to:"/command/relationships",label:"Dashboard",icon:ee,end:!0},{to:"/command/relationships/list",label:"Relationships",icon:se},{to:"/command/relationships/tasks",label:"Tasks",icon:ae},{to:"/command/relationships/calendar",label:"Calendar",icon:te},{to:"/command/relationships/cleanup",label:"Cleanup",icon:ne}];function Re(){const[p,N]=r.useState(!1),[u,f]=r.useState(!1),[c,S]=r.useState(90),[h,y]=r.useState([]),[o,j]=r.useState(null),t=O();async function n(){const{data:s}=await _.from("rel_sync_state").select("*");y(s??[]);const{data:l}=await _.from("rel_ms_oauth_tokens").select("ms_email").maybeSingle();j(l??null)}r.useEffect(()=>{n()},[]);async function g(){try{const{data:s,error:l}=await ce.functions.invoke("rel-ms-oauth-start",{body:{returnTo:window.location.pathname}});if(l)throw l;const d=s==null?void 0:s.url;if(!d)throw new Error("No auth URL returned");const x=window.open(d,"ms-oauth","width=560,height=720"),a=v=>{var L;((L=v.data)==null?void 0:L.type)==="ms-oauth-connected"&&(window.removeEventListener("message",a),m.success(`Microsoft connected${v.data.email?` (${v.data.email})`:""}`),n())};window.addEventListener("message",a);const C=setInterval(()=>{x!=null&&x.closed&&(clearInterval(C),n())},1e3)}catch(s){m.error(`Connect failed: ${(s==null?void 0:s.message)??s}`)}}async function E(){const{error:s}=await _.from("rel_ms_oauth_tokens").delete().neq("user_id","00000000-0000-0000-0000-000000000000");s?m.error(s.message):(m.success("Microsoft account disconnected"),n())}async function $(){var s,l,d,x;N(!0);try{const a=await A("rel-outlook-sync",{days:c,resource:"both",maxItems:2500});if(a!=null&&a.queued)m.success("Sync started in background. Counts will update in 30–60s.");else{const C=((s=a==null?void 0:a.mail)==null?void 0:s.synced)??((l=a==null?void 0:a.mail)==null?void 0:l.error)??"—",v=((d=a==null?void 0:a.calendar)==null?void 0:d.synced)??((x=a==null?void 0:a.calendar)==null?void 0:x.error)??"—";m.success(`Sync complete. Mail: ${C}, Calendar: ${v}`)}try{await A("rel-cleanup",{mode:"apply"})}catch{}n()}catch(a){m.error(`Sync failed: ${(a==null?void 0:a.message)??a}`)}finally{N(!1)}}const i=h.find(s=>s.resource==="calendar"),b=h.find(s=>s.resource==="mail"),D=(i==null?void 0:i.last_status)==="error"&&/403|access.*denied|forbidden/i.test((i==null?void 0:i.last_error)??"");return e.jsxs("div",{className:"min-w-0 overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col gap-4 mb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-xl bg-gradient-to-br from-indigo-500 to-violet-600 flex items-center justify-center text-white",children:e.jsx(P,{className:"size-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Relationship Intelligence Hub"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AI-driven CRM across every partner, importer, broker, and enterprise contact.",(b==null?void 0:b.last_sync_at)&&e.jsxs("span",{className:"ml-2",children:["Mail synced ",F(b.last_sync_at)," · ",b.last_items_synced??0," items."]})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsxs(re,{value:String(c),onValueChange:s=>S(Number(s)),children:[e.jsx(oe,{className:"h-9 w-[130px]",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(w,{value:"14",children:"Last 14 days"}),e.jsx(w,{value:"30",children:"Last 30 days"}),e.jsx(w,{value:"60",children:"Last 60 days"}),e.jsx(w,{value:"90",children:"Last 90 days"}),e.jsx(w,{value:"180",children:"Last 180 days"})]})]}),o!=null&&o.ms_email?e.jsxs(k,{variant:"outline",size:"sm",onClick:E,title:`Connected as ${o.ms_email}`,children:[e.jsx(Q,{className:"size-4 mr-2 text-emerald-600"}),"MS Connected"]}):e.jsxs(k,{variant:"outline",size:"sm",onClick:g,children:[e.jsx(X,{className:"size-4 mr-2"}),"Connect Microsoft"]}),e.jsxs(k,{variant:"outline",onClick:()=>f(!0),children:[e.jsx(T,{className:"size-4 mr-2"}),"Ask AI"]}),e.jsxs(k,{onClick:$,disabled:p,children:[e.jsx(Y,{className:`size-4 mr-2 ${p?"animate-spin":""}`}),p?"Syncing…":"Sync Outlook"]})]})]}),!o&&e.jsxs(M,{className:"border-amber-300 bg-amber-50 text-amber-900 [&>svg]:text-amber-700",children:[e.jsx(I,{className:"size-4"}),e.jsx(R,{children:"Connect your Microsoft account for full sync"}),e.jsxs(z,{className:"text-xs",children:["The shared Outlook connector only grants ",e.jsx("code",{children:"Mail.Read"}),". To pull ",e.jsx("strong",{children:"calendar events"})," and read mail from ",e.jsx("em",{children:"your"})," mailbox, click ",e.jsx("strong",{children:"Connect Microsoft"})," above and approve",e.jsx("code",{children:" Mail.Read"})," + ",e.jsx("code",{children:"Calendars.Read"}),"."]})]}),o&&D&&e.jsxs(M,{variant:"destructive",className:"border-amber-300 bg-amber-50 text-amber-900 [&>svg]:text-amber-700",children:[e.jsx(I,{className:"size-4"}),e.jsx(R,{children:"Calendar sync error"}),e.jsx(z,{className:"text-xs",children:i==null?void 0:i.last_error})]}),e.jsx("nav",{className:"flex gap-1 border-b overflow-x-auto",children:ue.map(s=>{const l=s.icon;return e.jsxs(B,{to:s.to,end:s.end,className:({isActive:d})=>`inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium border-b-2 whitespace-nowrap transition-colors ${d?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(l,{className:"size-4"})," ",s.label]},s.to)})})]}),e.jsx(q,{},t.pathname),e.jsx(me,{open:u,onOpenChange:f})]})}
1export{Re 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.