- App.vue: top tab bar (Admin overview [admin], My dashboard, Training) + Settings icon - router: / = admin overview, /my/board, /training, /settings; non-admin '/' -> /my/board - New views: Training.vue (pick ready product group -> personas), MyBoard.vue (win/lose + sessions summary), Settings.vue (change email/password, language) - Backend: allow /api/me/board + /api/chat/sessions for any authenticated user (so the My dashboard tab works for admins too), not just 'user' role - i18n EN/TH keys; rebuilt frontend/dist Verified: build ok, /api/me/board + /api/chat/sessions + /api/groups all 200 for admin.
2 lines
3.6 KiB
JavaScript
2 lines
3.6 KiB
JavaScript
import{_ as M,k as q,l as k,c as t,m as B,n as D,u as l,a as s,t as e,s as C,e as i,j as m,i as n,F,p as I,w as z,v as A,b as E,h as H,r as c,A as J,q as L,o}from"./index-EpRXsI-R.js";const O={class:"row",style:{"align-items":"center","margin-bottom":"12px"}},P={style:{margin:"0"}},R={key:0,class:"muted"},U=["disabled"],$={key:0,class:"spinner",style:{"margin-right":"4px"}},G={key:0,class:"card task"},Q={key:0},W={key:0,class:"bubble msg-customer muted"},X={key:2,class:"composer"},Y=["disabled","placeholder"],Z=["disabled"],ee={key:3,class:"card debrief"},se={key:0},ae={class:"json"},te={class:"primary",style:{"margin-top":"12px"}},le={__name:"Chat",setup(ne){const N=H(),_=N.params.gid,g=N.params.pid,r=c(null),f=c(!1),v=c([]),p=c(""),d=c(!1),u=c(null),w=c(""),j=c(null);function T(){J(()=>{y.value&&(y.value.scrollTop=y.value.scrollHeight)})}const y=c(null);q(async()=>{r.value=(await k.getPersona(_,g)).persona;const a=await k.chatStart(_,g);j.value=a.session.id,a.session.task&&(w.value=a.session.task),v.value=a.session.messages||[],f.value=!0,v.value.length&&T()});async function V(){if(p.value.trim()){d.value=!0;try{const a=await k.chatSend(_,g,p.value.trim());v.value=a.messages,p.value="",T()}catch(a){alert(a.message)}finally{d.value=!1}}}async function K(){if(confirm(n.t("finish")+"?")){d.value=!0;try{const a=await k.chatFinish(_,g);u.value=a.debrief,v.value=a.session.messages}catch(a){alert(a.message)}finally{d.value=!1}}}return(a,b)=>{const S=L("router-link");return o(),t("div",null,[B(S,{to:`/groups/${l(_)}/personas`,class:"btn-back"},{default:D(()=>[m("← "+e(l(n).t("personas")),1)]),_:1},8,["to"]),s("div",O,[s("h2",P,e(r.value?r.value.name:"..."),1),s("span",{class:C(["badge",r.value&&r.value.channel])},e(r.value?r.value.channel:""),3),r.value?(o(),t("span",R,e(r.value.profession)+" · "+e(r.value.age_group),1)):i("",!0),s("button",{class:"danger",style:{"margin-left":"auto"},onClick:K,disabled:v.value.length===0||!!u.value},[d.value?(o(),t("span",$)):i("",!0),m(e(l(n).t("finish")),1)],8,U)]),f.value?i("",!0):(o(),t("div",G,[s("strong",null,"📣 "+e(l(n).t("sellerInitiated")),1),w.value?(o(),t("div",Q,e(w.value),1)):i("",!0)])),f.value?(o(),t("div",{key:1,class:"thread",ref_key:"thread",ref:y},[(o(!0),t(F,null,I(v.value,(h,x)=>(o(),t("div",{key:x,class:C(["bubble",h.role==="seller"?"msg-seller":"msg-customer"])},e(h.text),3))),128)),d.value?(o(),t("div",W,"...")):i("",!0)],512)):i("",!0),f.value&&!u.value?(o(),t("div",X,[z(s("input",{"onUpdate:modelValue":b[0]||(b[0]=h=>p.value=h),onKeyup:E(V,["enter"]),disabled:d.value,placeholder:l(n).t("send")},null,40,Y),[[A,p.value]]),s("button",{class:"primary",onClick:V,disabled:d.value||!p.value.trim()},e(l(n).t("send")),9,Z)])):i("",!0),u.value?(o(),t("div",ee,[s("h3",null,e(l(n).t("debrief")),1),s("p",null,[s("span",{class:C(["badge",u.value.outcome])},e(u.value.outcome==="won"?l(n).t("won"):l(n).t("lost")),3),m(" — "+e(l(n).t("score"))+": ",1),s("strong",null,e(u.value.score),1)]),s("p",null,[s("strong",null,e(l(n).t("pain"))+":",1),m(" "+e(u.value.pain||"—"),1)]),s("p",null,[s("strong",null,e(l(n).t("why"))+":",1),m(" "+e(u.value.why),1)]),u.value.coaching&&u.value.coaching.length?(o(),t("div",se,[b[1]||(b[1]=s("strong",null,"Coaching:",-1)),s("ul",null,[(o(!0),t(F,null,I(u.value.coaching,(h,x)=>(o(),t("li",{key:x},e(h),1))),128))])])):i("",!0),s("details",null,[s("summary",null,e(l(n).t("reveal")),1),s("pre",ae,e(JSON.stringify(u.value.revealed_persona,null,2)),1)]),B(S,{to:"/"},{default:D(()=>[s("button",te,e(l(n).t("dashboard")),1)]),_:1})])):i("",!0)])}}},ue=M(le,[["__scopeId","data-v-4f54526a"]]);export{ue as default};
|