PageSourceSearch

https://www.qoreai.com/assets/AdminAssessmentDetail-DuZZ8m3d.js

js qoreai.com collected 2026-10-01 16:36:13 UTC 13,180 bytes, 15 lines download raw bytes

1import{r as d,j as e}from"./vendor-react-B5Wrj-9W.js";import{c as L,L as S}from"./vendor-router-B_GMu44Q.js";import{supabase as m}from"./client-BQvQemtZ.js";import{a as f,j as p}from"./index-BuKnDtE7.js";import{f as l}from"./blog-CXu9iSVy.js";import{O as D,y as P,al as H,o as A,au as I}from"./vendor-icons-BdvFhWbz.js";import"./vendor-supabase-DljY4R_6.js";import"./vendor-radix-DJaxbWLn.js";const Y=()=>{const{id:n}=L(),[r,$]=d.useState(null),[u,z]=d.useState([]),[j,E]=d.useState([]),[q,g]=d.useState(!0),[b,_]=d.useState(!1),[h,N]=d.useState(!1),[t,y]=d.useState(null),[v,k]=d.useState(null),w=async()=>{if(!n)return;g(!0);const{data:s}=await m.from("assessment_results").select("*").eq("id",n).maybeSingle();if(!s){g(!1);return}$(s),y(s.ai_talking_points??null),k(s.ai_analyzed_at??null);const[{data:a},{data:i}]=await Promise.all([m.from("assessment_results").select("id, token, email, first_name, dealership_name, role, rooftop_count, primary_dms, primary_crm, monthly_volume, monthly_ros, ai_tools_tried, percentage_score, pillar_scores, weakest_pillars, hubspot_sync_status, hubspot_contact_id, hubspot_sync_error, hubspot_synced_at, created_at").ilike("email",s.email).order("created_at",{ascending:!1}).limit(20),m.from("assessment_email_schedule").select("id, template_name, send_at, sent_at, status, error").eq("assessment_id",n).order("send_at",{ascending:!0})]);z(a??[]),E(i??[]),g(!1)};d.useEffect(()=>{w()},[n]);const C=async()=>{if(!n)return;_(!0);const{error:s}=await m.functions.invoke("sync-assessment-to-hubspot",{body:{assessment_id:n}});_(!1),s?p.error(s.message||"Sync failed"):p.success("HubSpot sync triggered"),await w()},R=async(s=!1)=>{if(!n)return;N(!0);const{data:a,error:i}=await m.functions.invoke("analyze-assessment",{body:{assessment_id:n,force:s}});if(N(!1),i){p.error(i.message||"Analysis failed");return}a?.talking_points&&(y(a.talking_points),k(a.analyzed_at),p.success(a.cached?"Loaded cached talking points":"Talking points generated"))},T=async()=>{if(!t)return;const s=[t.summary&&`READ:
2${t.summary}`,t.openers?.length&&`OPENERS:
3- ${t.openers.join(`
4- `)}`,t.discovery_questions?.length&&`DISCOVERY:
5- ${t.discovery_questions.join(`
6- `)}`,t.gaps_to_lead_with?.length&&`GAPS:
7${t.gaps_to_lead_with.map(a=>`- [${a.pillar}] ${a.gap}
8  Impact: ${a.impact}
9  Bridge: ${a.qorecloud_bridge}`).join(`
10`)}`,t.objections?.length&&`OBJECTIONS:
11${t.objections.map(a=>`- "${a.likely}" => ${a.response}`).join(`
12`)}`,t.next_step&&`NEXT STEP:
13${t.next_step}`].filter(Boolean).join(`
14
15`);await navigator.clipboard.writeText(s),p.success("Talk track copied")};if(q)return e.jsx("div",{className:"text-muted-foreground",children:"Loading..."});if(!r)return e.jsx("div",{className:"text-muted-foreground",children:"Assessment not found."});const c=u.find(s=>s.id!==r.id),o=c?r.percentage_score-c.percentage_score:null;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsxs(S,{to:"/admin/assessments",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground mb-3",children:[e.jsx(D,{size:12})," All assessments"]}),e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-display font-bold text-foreground tracking-tight",children:[r.first_name," · ",r.dealership_name]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[r.email," · ",l(r.created_at)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("a",{href:`/assessment/r/${r.token}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(P,{size:14})," Open scorecard"]}),e.jsxs(f,{size:"sm",variant:"outline",onClick:C,disabled:b,children:[e.jsx(H,{size:14,className:`mr-1.5 ${b?"animate-spin":""}`}),r.hubspot_contact_id?"Re-sync HubSpot":"Sync to HubSpot"]})]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-primary/30 bg-primary/5 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap mb-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-sm uppercase tracking-widest text-primary/80 flex items-center gap-2",children:[e.jsx(A,{size:14})," AI talk track"]}),v&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Generated ",l(v)
15]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsxs(f,{size:"sm",variant:"ghost",onClick:T,children:[e.jsx(I,{size:14,className:"mr-1.5"})," Copy"]}),e.jsxs(f,{size:"sm",onClick:()=>R(!!t),disabled:h,children:[e.jsx(A,{size:14,className:`mr-1.5 ${h?"animate-pulse":""}`}),h?"Analyzing...":t?"Regenerate":"Generate talking points"]})]})]}),!t&&!h&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate AI-powered openers, discovery questions, gap framing, and objection responses tailored to this dealer's score and stack."}),t&&e.jsxs("div",{className:"space-y-4 text-sm",children:[t.summary&&e.jsxs("div",{children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-1",children:"Read"}),e.jsx("p",{className:"text-foreground",children:t.summary})]}),t.openers&&t.openers.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-1",children:"Openers"}),e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-foreground/90",children:t.openers.map((s,a)=>e.jsx("li",{children:s},a))})]}),t.discovery_questions&&t.discovery_questions.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-1",children:"Discovery questions"}),e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-foreground/90",children:t.discovery_questions.map((s,a)=>e.jsx("li",{children:s},a))})]}),t.gaps_to_lead_with&&t.gaps_to_lead_with.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-2",children:"Gaps to lead with"}),e.jsx("div",{className:"space-y-2",children:t.gaps_to_lead_with.map((s,a)=>e.jsxs("div",{className:"rounded-lg border border-border/15 bg-card/20 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-3xs font-mono uppercase text-primary",children:s.pillar}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.gap})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"text-foreground/70",children:"Impact:"})," ",s.impact]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[e.jsx("span",{className:"text-foreground/70",children:"QoreCloud bridge:"})," ",s.qorecloud_bridge]})]},a))})]}),t.objections&&t.objections.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-2",children:"Likely objections"}),e.jsx("div",{className:"space-y-2",children:t.objections.map((s,a)=>e.jsxs("div",{className:"rounded-lg border border-border/15 bg-card/20 p-3",children:[e.jsxs("div",{className:"text-sm text-foreground/90 italic",children:['"',s.likely,'"']}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:s.response})]},a))})]}),t.next_step&&e.jsxs("div",{children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-1",children:"Next step"}),e.jsx("p",{className:"text-foreground",children:t.next_step})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-border/15 bg-card/10 p-5",children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-2",children:"Score"}),e.jsxs("div",{className:"text-4xl font-display font-bold text-foreground",children:[r.percentage_score,"%"]}),o!==null&&e.jsxs("div",{className:`text-xs mt-1 ${o>0?"text-emerald-300":o<0?"text-destructive":"text-muted-foreground"}`,children:[o>0?"+":"",o," pts vs last take (",c.percentage_score,"%, ",l(c.created_at),")"]})]}),e.jsxs("div",{className:"rounded-2xl border border-border/15 bg-card/10 p-5",children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-2",children:"Stack"}),e.jsxs("div",{className:"text-sm text-foreground",children:["DMS: ",r.primary_dms||"N/A"]}),e.jsxs("div",{className:"text-sm text-foreground",children:["CRM: ",r.primary_crm||"N/A"]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[r.rooftop_count||"?"," rooftops · ",r.monthly_volume||"?"," units/mo · ",r.monthly_ros||"?"," ROs/mo"]})]}
15),e.jsxs("div",{className:"rounded-2xl border border-border/15 bg-card/10 p-5",children:[e.jsx("div",{className:"text-3xs uppercase tracking-widest text-muted-foreground mb-2",children:"HubSpot"}),e.jsx("div",{className:"text-sm text-foreground capitalize",children:r.hubspot_sync_status||"not synced"}),r.hubspot_contact_id&&e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Contact: ",r.hubspot_contact_id]}),r.hubspot_synced_at&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:l(r.hubspot_synced_at)}),r.hubspot_sync_error&&e.jsx("div",{className:"text-xs text-destructive mt-2",children:r.hubspot_sync_error})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm uppercase tracking-widest text-muted-foreground mb-3",children:"Pillar scores"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:Object.entries(r.pillar_scores).map(([s,a])=>{const i=c?.pillar_scores?.[s],x=typeof i=="number"?a-i:null,O=r.weakest_pillars.includes(s);return e.jsxs("div",{className:`rounded-xl border p-3 ${O?"border-destructive/40 bg-destructive/5":"border-border/15 bg-card/10"}`,children:[e.jsx("div",{className:"text-3xs font-mono uppercase text-muted-foreground",children:s}),e.jsxs("div",{className:"text-2xl font-display font-bold text-foreground mt-1",children:[a,e.jsx("span",{className:"text-sm text-muted-foreground",children:"/20"})]}),x!==null&&e.jsxs("div",{className:`text-3xs mt-1 ${x>0?"text-emerald-300":x<0?"text-destructive":"text-muted-foreground"}`,children:[x>0?"+":"",x," vs last"]})]},s)})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm uppercase tracking-widest text-muted-foreground mb-3",children:"Email drip"}),e.jsx("div",{className:"rounded-2xl border border-border/15 bg-card/10 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-card/30 text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-2",children:"Template"}),e.jsx("th",{className:"text-left px-4 py-2",children:"Scheduled"}),e.jsx("th",{className:"text-left px-4 py-2",children:"Sent"}),e.jsx("th",{className:"text-left px-4 py-2",children:"Status"})]})}),e.jsxs("tbody",{children:[j.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-6 text-center text-muted-foreground",children:"No scheduled emails."})}),j.map(s=>e.jsxs("tr",{className:"border-t border-border/10",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:s.template_name}),e.jsx("td",{className:"px-4 py-2 text-muted-foreground",children:l(s.send_at)}),e.jsx("td",{className:"px-4 py-2 text-muted-foreground",children:s.sent_at?l(s.sent_at):"N/A"}),e.jsxs("td",{className:"px-4 py-2",children:[e.jsx("span",{className:"text-xs font-mono uppercase",children:s.status}),s.error&&e.jsx("div",{className:"text-xs text-destructive mt-0.5",children:s.error})]})]},s.id))]})]})})]}),u.length>1&&e.jsxs("div",{children:[e.jsxs("h2",{className:"text-sm uppercase tracking-widest text-muted-foreground mb-3",children:["History (",u.length," takes from this email)"]}),e.jsx("div",{className:"rounded-2xl border border-border/15 bg-card/10 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-card/30 text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-2",children:"When"}),e.jsx("th",{className:"text-left px-4 py-2",children:"Score"}),e.jsx("th",{className:"text-left px-4 py-2",children:"Weak pillars"}),e.jsx("th",{className:"text-left px-4 py-2",children:"Stack"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:u.map(s=>e.jsxs("tr",{className:`border-t border-border/10 ${s.id===r.id?"bg-primary/5":""}`,children:[e.jsx("td",{className:"px-4 py-2 text-muted-foreground",children:l(s.created_at)}),e.jsxs("td",{className:"px-4 py-2 font-display font-bold text-foreground",children:[s.percentage_score,"%"]}),e.jsx("td",{className:"px-4 py-2 text-xs font-mono text-muted-foreground",children:(s.weakest_pillars??[]).join(", ")}),e.jsxs("td",{className:"px-4 py-2 text-xs text-muted-foreground",children:[s.primary_dms||"N/A"," / ",s.primary_crm||"N/A"]}),e.jsx("td",{className:"px-4 py-2 text-right",children:s.id!==r.id&&e.jsx(S,{to:`/admin/assessments/${s.id}`,className:"text-xs text-primary hover:underline",children:"View"})})]},s.id))})]})})]})]})};export{Y 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.