PageSourceSearch

https://aidealer360.com/assets/EosAdmin-BYMOWkfp.js

js aidealer360.com collected 2026-09-24 12:37:48 UTC 16,988 bytes, 3 lines download raw bytes

1import{j as e}from"./ui-vendor-B12AOeKi.js";import{L as se,r as N}from"./react-vendor-DZt7wVAJ.js";import{B as j,ar as te,am as ae,a4 as Y,Q as V,an as I,i as w,s as y,q as M,v as O,w as H,x as $,y as B,g as Z,T as re,I as G,ab as ne,F as ee,P,ah as ie,a8 as W,D as oe,b as le,c as ce,d as de,h as me,K as ue}from"./index-CUOC2qQu.js";import{S as he}from"./switch-Doi0_Deq.js";import{T as xe,b as pe,c as K,a as Q}from"./tabs-Cesl5pOW.js";import{S as fe,a as ge,b as we,c as je,d as R}from"./select-B8RrBf7t.js";import{u as T}from"./useEosContext-DGewPK5l.js";import{C as J}from"./circle-play-Dggds_8V.js";import{C as ye}from"./circle-stop-DCiQbk0T.js";import{A as _e,a as ve}from"./arrow-up-CEEmskad.js";import{U as X}from"./upload-krIPvW5L.js";import"./charts-vendor-B6q1L48j.js";import"./supabase-vendor-dOy44Gxq.js";import"./animation-vendor-BAVy02gd.js";const Ne=[{name:"Segue",slug:"segue"},{name:"Scorecard",slug:"scorecard"},{name:"Headlines",slug:"headlines"},{name:"Rocks",slug:"rocks"},{name:"To-Dos",slug:"todos"},{name:"Issues (IDS)",slug:"issues"}];function be(){const{dealershipId:r,ready:_}=T(),a=Y(),[c,l]=N.useState(""),{data:d=[],isLoading:h}=V({queryKey:["eos-sections",r],queryFn:async()=>{const{data:t,error:n}=await y.from("eos_meeting_sections").select("*").eq("dealership_id",r).order("sort_order");if(n)throw n;return t},enabled:_}),p=I({mutationFn:async()=>{if(!r)return;const t=Ne.map((m,s)=>({...m,sort_order:s,is_enabled:!0,dealership_id:r})),{error:n}=await y.from("eos_meeting_sections").insert(t);if(n)throw n},onSuccess:()=>{a.invalidateQueries({queryKey:["eos-sections",r]}),w.success("Default sections added")},onError:t=>w.error(t.message)}),f=I({mutationFn:async()=>{if(!r)return;const t=c.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),n={name:c.trim(),slug:t,sort_order:d.length,is_enabled:!0,dealership_id:r},{error:m}=await y.from("eos_meeting_sections").insert(n);if(m)throw m},onSuccess:()=>{l(""),a.invalidateQueries({queryKey:["eos-sections",r]})},onError:t=>w.error(t.message)}),g=I({mutationFn:async({id:t,patch:n})=>{const{error:m}=await y.from("eos_meeting_sections").update(n).eq("id",t);if(m)throw m},onSuccess:()=>a.invalidateQueries({queryKey:["eos-sections",r]})}),b=(t,n)=>{const m=d.findIndex(i=>i.id===t),s=d[m+n];s&&(g.mutate({id:t,patch:{sort_order:s.sort_order}}),g.mutate({id:s.id,patch:{sort_order:d[m].sort_order}}))},L=I({mutationFn:async t=>{const{error:n}=await y.from("eos_meeting_sections").delete().eq("id",t);if(n)throw n},onSuccess:()=>a.invalidateQueries({queryKey:["eos-sections",r]})});return e.jsxs(M,{children:[e.jsxs(O,{children:[e.jsx(H,{className:"text-base",children:"Meeting Sections"}),e.jsx($,{children:"Reorder and toggle the sections shown during the Level 10 meeting for this dealership."})]}),e.jsxs(B,{className:"space-y-3",children:[h?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):d.length===0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No sections configured for this dealership yet."}),e.jsx(j,{onClick:()=>p.mutate(),children:"Add 6 default sections"})]}):e.jsx("div",{className:"space-y-2",children:d.map((t,n)=>e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 p-2 rounded border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(Z,{variant:"outline",className:"text-xs shrink-0",children:n+1}),e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsx("code",{className:"text-xs text-muted-foreground truncate",children:t.slug})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 self-end sm:self-auto",children:[e.jsx(he,{checked:t.is_enabled,onCheckedChange:m=>g.mutate({id:t.id,patch:{is_enabled:m}})}),e.jsx(j,{size:"icon",variant:"ghost",className:"h-9 w-9",onClick:()=>b(t.id,-1),disabled:n===0,children:e.jsx(_e,{className:"w-4 h-4"})}),e.jsx(j,{size:"icon",variant:"ghost",className:"h-9 w-9",onClick:()=>b(t.id,1),disabled:n===d.length-1,children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx(j,{size:"icon",variant:"ghost",className:"h-9 w-9",onClick:()=>L.mutate(t.id),children:e.jsx(re,{className:"w-4 h-4 text-destructive"})})]})]},t.id))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t",children:[e.jsx(G,{value:c,onChange:t=>l(t.target.value),placeholder:"Custom section name…"}),e.jsxs(j,{onClick:()=>f.mutate(),disabled:!c.trim(),className:"shrink-0",children:[e.jsx(ne,{className:"w-4 h-4 mr-1"})," Add"]})]})]})]})}function Se(){const{dealershipId:r,userId:_,ready:a}=T(),c=Y(),{data:l}=V({queryKey:["eos-active-session-admin",r],queryFn:async()=>{const{data:p}=await y.from("eos_meeting_sessions").select("id, status, started_at").eq("dealership_id",r).in("status",["in_progress","paused"]).order("created_at",{ascending:!1}).limit(1).maybeSingle();return p},enabled:a}),d=I({mutationFn:async()=>
1{if(!r||!_)return;const p={facilitator_user_id:_,status:"in_progress",started_at:new Date().toISOString(),dealership_id:r},{error:f}=await y.from("eos_meeting_sessions").insert(p);if(f)throw f},onSuccess:()=>{c.invalidateQueries({queryKey:["eos-active-session-admin",r]}),c.invalidateQueries({queryKey:["eos-active-session"]}),w.success("Meeting started")},onError:p=>w.error(p.message)}),h=I({mutationFn:async()=>{if(!(l!=null&&l.id))return;const{error:p}=await y.from("eos_meeting_sessions").update({status:"completed",ended_at:new Date().toISOString()}).eq("id",l.id);if(p)throw p},onSuccess:()=>{c.invalidateQueries({queryKey:["eos-active-session-admin",r]}),c.invalidateQueries({queryKey:["eos-active-session"]}),w.success("Meeting ended")},onError:p=>w.error(p.message)});return e.jsxs(M,{children:[e.jsxs(O,{children:[e.jsx(H,{className:"text-base",children:"Meeting Session"}),e.jsx($,{children:"Start or end a Level 10 meeting for this dealership."})]}),e.jsx(B,{className:"flex items-center gap-3 flex-wrap",children:l?e.jsxs(e.Fragment,{children:[e.jsxs(Z,{className:"gap-1",children:[e.jsx(J,{className:"w-3 h-3"})," ",l.status==="paused"?"Paused":"In progress"]}),e.jsxs(j,{variant:"destructive",onClick:()=>h.mutate(),children:[e.jsx(ye,{className:"w-4 h-4 mr-1"})," End meeting"]})]}):e.jsxs(j,{onClick:()=>d.mutate(),children:[e.jsx(J,{className:"w-4 h-4 mr-1"})," Start meeting"]})})]})}function Ce(){const{dealershipId:r,ready:_}=T(),[a,c]=N.useState(null),[l,d]=N.useState(null),[h,p]=N.useState(""),[f,g]=N.useState(null),{data:b=[]}=V({queryKey:["eos-completed-sessions",r],queryFn:async()=>{const{data:s,error:i}=await y.from("eos_meeting_sessions").select("id, started_at, ended_at").eq("dealership_id",r).eq("status","completed").order("ended_at",{ascending:!1}).limit(20);if(i)throw i;return s},enabled:_}),L=async s=>{g(s);try{const{data:i,error:u}=await y.functions.invoke("eos-meeting-recap",{body:{sessionId:s,action:"preview"}});if(u)throw u;if(i!=null&&i.error)throw new Error(i.error);d(s),c(i.html)}catch(i){w.error(i.message||"Failed to generate recap")}finally{g(null)}},t=(s,i,u)=>{const C=u?new Date(u).toISOString().slice(0,10):new Date().toISOString().slice(0,10),k=new Blob([s],{type:"text/html;charset=utf-8"}),v=URL.createObjectURL(k),q=document.createElement("a");q.href=v,q.download=`eos-meeting-recap-${C}-${i.slice(0,8)}.html`,document.body.appendChild(q),q.click(),document.body.removeChild(q),URL.revokeObjectURL(v),w.success("Recap downloaded")},n=async(s,i)=>{g(s);try{const{data:u,error:C}=await y.functions.invoke("eos-meeting-recap",{body:{sessionId:s,action:"preview"}});if(C)throw C;if(u!=null&&u.error)throw new Error(u.error);t(u.html,s,i)}catch(u){w.error(u.message||"Failed to generate recap")}finally{g(null)}},m=async()=>{if(!l)return;const s=h.split(/[,\s]+/).map(i=>i.trim()).filter(Boolean);if(!s.length)return w.error("Enter at least one recipient email");g(l);try{const{data:i,error:u}=await y.functions.invoke("eos-meeting-recap",{body:{sessionId:l,action:"send",recipients:s}});if(u)throw u;if(i!=null&&i.error)throw new Error(i.error);w.success(`Recap emailed to ${s.length} recipient${s.length>1?"s":""}`),p("")}catch(i){w.error(i.message||"Failed to send")}finally{g(null)}};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsxs(O,{children:[e.jsxs(H,{
1className:"text-base flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4"})," Meeting Recap Generator"]}),e.jsx($,{children:"Generate an AI-written HTML recap for any completed meeting and email it to attendees."})]}),e.jsx(B,{children:b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No completed meetings yet."}):e.jsx("ul",{className:"space-y-1 text-sm",children:b.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 p-2 rounded border bg-muted/30",children:[e.jsx("span",{className:"truncate",children:s.ended_at?new Date(s.ended_at).toLocaleString():"—"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>L(s.id),disabled:f===s.id,children:[f===s.id?e.jsx(P,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(ie,{className:"w-3 h-3 mr-1"}),"Generate"]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>n(s.id,s.ended_at),disabled:f===s.id,title:"Download HTML",children:[e.jsx(W,{className:"w-3 h-3 mr-1"})," HTML"]})]})]},s.id))})})]}),e.jsx(oe,{open:!!a,onOpenChange:s=>{s||(c(null),d(null))},children:e.jsxs(le,{className:"flex flex-col",children:[e.jsx(ce,{children:e.jsx(de,{children:"Recap Preview"})}),e.jsx("div",{className:"flex-1 overflow-auto border rounded",children:a&&e.jsx("iframe",{title:"Recap preview",srcDoc:a,className:"w-full h-[60vh] bg-white"})}),e.jsxs(me,{className:"gap-2 flex-col sm:flex-row",children:[e.jsx(G,{value:h,onChange:s=>p(s.target.value),placeholder:"[email protected], [email protected]",className:"flex-1"}),e.jsxs(j,{variant:"outline",onClick:()=>{var s;if(a&&l){const i=(s=b.find(u=>u.id===l))==null?void 0:s.ended_at;t(a,l,i)}},children:[e.jsx(W,{className:"w-4 h-4 mr-1"})," Download HTML"]}),e.jsxs(j,{onClick:m,disabled:f===l,children:[f===l?e.jsx(P,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(ue,{className:"w-4 h-4 mr-1"}),"Send email"]})]})]})})]})}const U={rocks:["title","description","owner_email","due_date","status","quarter"],todos:["title","owner_email","due_date","status"],issues:["title","description","owner_email","status","priority"],headlines:["kind","title","body"],measurables:["name","owner_email","goal","unit","frequency","direction"]};function ke(r){const _=[];let a=[],c="",l=!1;for(let d=0;d<r.length;d++){const h=r[d];l?h==='"'&&r[d+1]==='"'?(c+='"',d++):h==='"'?l=!1:c+=h:h==='"'?l=!0:h===","?(a.push(c),c=""):h===`
2`?(a.push(c),_.push(a),a=[],c=""):h==="\r"||(c+=h)}return(c.length||a.length)&&(a.push(c),_.push(a)),_.filter(d=>d.some(h=>h.trim()!==""))}function qe(){const{dealershipId:r,ready:_}=T(),[a,c]=N.useState("rocks"),[l,d]=N.useState(null),[h,p]=N.useState(!1),[f,g]=N.useState(null),b=()=>{const t=U[a].join(","),n=new Blob([t+`
3`],{type:"text/csv"}),m=URL.createObjectURL(n),s=document.createElement("a");s.href=m,s.download=`eos-${a}-template.csv`,s.click(),URL.revokeObjectURL(m)},L=async()=>{if(!(!l||!r)){p(!0),g(null);try{const t=await l.text(),n=ke(t);if(n.length<2)throw new Error("CSV is empty or has no data rows");const m=n[0].map(x=>x.trim().toLowerCase()),i=U[a].filter(x=>!m.includes(x));if(i.length)throw new Error(`Missing required columns: ${i.join(", ")}`);const u=m.indexOf("owner_email");let C={};if(u>=0){const x=Array.from(new Set(n.slice(1).map(S=>(S[u]||"").trim().toLowerCase()).filter(Boolean)));if(x.length){const{data:S}=await y.from("registration_users").select("id, email").in("email",x);(S??[]).forEach(o=>{C[o.email.toLowerCase()]=o.id})}}const k=[],v=[];for(let x=1;x<n.length;x++){const S=n[x],o=A=>(S[m.indexOf(A)]||"").trim(),F=o("owner_email").toLowerCase(),E=F?C[F]:null;if(F&&!E){k.push(`Row ${x+1}: unknown owner email "${F}"`);continue}try{a==="rocks"?v.push({title:o("title"),description:o("description")||null,owner_user_id:E,due_date:o("due_date")||null,status:o("status")||"on_track",quarter:o("quarter")||null,dealership_id:r,organization_id:""}):a==="todos"?v.push({title:o("title"),owner_user_id:E,due_date:o("due_date")||null,status:o("status")||"open",dealership_id:r,organization_id:""}):a==="issues"?v.push({title:o("title"),description:o("description")||null,owner_user_id:E,status:o("status")||"identify",priority:parseInt(o("priority")||"2",10),dealership_id:r,organization_id:""}):a==="headlines"?v.push({kind:o("kind")||"customer",title:o("title"),body:o("body")||null,posted_by_user_id:null,dealership_id:r,organization_id:""}):a==="measurables"&&v.push({name:o("name"),owner_user_id:E,goal:parseFloat(o("goal")||"0"),unit:o("unit")||null,frequency:o("frequency")||"weekly",direction:o("direction")||">=",dealership_id:r,organization_id:""})}catch(A){k.push(`Row ${x+1}: ${A.message}`)}}const q=`eos_${a==="measurables"?"scorecard_measurables":a}`;let D=0;const z=100;for(let x=0;x<v.length;x+=z){const S=v.slice(x,x+z),{error:o}=await y.from(q).insert(S);o?k.push(`Batch ${Math.floor(x/z)+1}: ${o.message}`):D+=S.length}g({inserted:D,failed:v.length-D+k.filter(x=>x.startsWith("Row")).length,errors:k}),D&&w.success(`Imported ${D} ${a}`)}catch(t){w.error(t.message)}finally{p(!1)}}};
3return e.jsxs(M,{children:[e.jsxs(O,{children:[e.jsxs(H,{className:"text-base flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4"})," Historical Data Import"]}),e.jsx($,{children:"Bulk import legacy TommyCar EOS data via CSV. Owner is matched by email against registration users."})]}),e.jsxs(B,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap gap-2 sm:items-end",children:[e.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Data type"}),e.jsxs(fe,{value:a,onValueChange:t=>{c(t),g(null),d(null)},children:[e.jsx(ge,{className:"w-full sm:w-48",children:e.jsx(we,{})}),e.jsxs(je,{children:[e.jsx(R,{value:"rocks",children:"Rocks"}),e.jsx(R,{value:"todos",children:"To-Dos"}),e.jsx(R,{value:"issues",children:"Issues"}),e.jsx(R,{value:"headlines",children:"Headlines"}),e.jsx(R,{value:"measurables",children:"Scorecard Measurables"})]})]})]}),e.jsxs(j,{variant:"outline",size:"sm",onClick:b,className:"h-9 shrink-0",children:[e.jsx(ee,{className:"w-4 h-4 mr-1"})," Download template"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground break-words",children:["Required columns: ",e.jsx("code",{className:"break-all",children:U[a].join(", ")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(G,{type:"file",accept:".csv",onChange:t=>{var n;d(((n=t.target.files)==null?void 0:n[0])??null),g(null)}}),e.jsxs(j,{onClick:L,disabled:!l||!_||h,className:"shrink-0",children:[h?e.jsx(P,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(X,{className:"w-4 h-4 mr-1"}),"Import"]})]}),f&&e.jsxs("div",{className:"p-3 rounded border bg-muted/30 text-sm space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:f.inserted})," rows imported"]}),f.errors.length>0&&e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-destructive",children:[f.errors.length," issue(s)"]}),e.jsxs("ul",{className:"mt-2 space-y-0.5 text-xs",children:[f.errors.slice(0,50).map((t,n)=>e.jsxs("li",{children:["• ",t]},n)),f.errors.length>50&&e.jsxs("li",{children:["… and ",f.errors.length-50," more"]})]})]})]})]})]})}function Ke(){const{ready:r}=T();return r?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs("header",{className:"border-b bg-card px-3 sm:px-4 py-3 flex items-center gap-2 sm:gap-3",children:[e.jsx(j,{asChild:!0,size:"icon",variant:"ghost",className:"h-10 w-10 shrink-0",children:e.jsx(se,{to:"/eos","aria-label":"Back to EOS",children:e.jsx(te,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ae,{className:"w-5 h-5 text-primary shrink-0"}),e.jsx("h1",{className:"text-base sm:text-lg font-semibold truncate",children:"EOS Admin"})]})]}),e.jsx("main",{className:"p-3 sm:p-4 md:p-6 max-w-5xl mx-auto",children:e.jsxs(xe,{defaultValue:"meeting",children:[e.jsx("div",{className:"-mx-3 sm:mx-0 overflow-x-auto",children:e.jsxs(pe,{className:"flex-nowrap w-max min-w-full sm:w-auto",children:[e.jsx(K,{value:"meeting",children:"Meeting Setup"}),e.jsx(K,{value:"recap",children:"Recap"}),e.jsx(K,{value:"import",children:"Import"})]})}),e.jsxs(Q,{value:"meeting",className:"mt-4 space-y-4",children:[e.jsx(Se,{}),e.jsx(be,{})]}),e.jsx(Q,{value:"recap",className:"mt-4",children:e.jsx(Ce,{})}),e.jsx(Q,{value:"import",className:"mt-4",children:e.jsx(qe,{})})]})})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})})}export{Ke 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.