Files
sales-trainer/frontend/dist/assets/Chat-fU4aRozx.js
Macky bd6a7ffa32 feat(chat): scenario-based training — choice of channel/Situation + realistic per-turn evaluation
Backend:
- Channel/initiation now driven by a SCENARIO chosen at chat start, not baked into the
  persona: social (customer opens), f2f_call (seller must open, proactive), recontact
  (customer re-contacts after 1-3 months).
- /chat/start accepts {scenario}; session stores scenario + internal{turns,score}.
- persona_reply takes scenario + adapts tone; system-role transcript entries are fed to
  the persona as hidden scene notes.
- JUDGE updated for realism: good response can WIN even in hard/tough-text scenarios;
  long/no-close chats (turns >~12) lose; pushy/ignoring-need loses. Efficiency rewarded.

Frontend:
- Scenario picker before chat (choose Social / Face-to-face-call / Re-contact).
- Chat thread renders role=system as a centered time-lapse/scene note.
- Choose-scenario i18n (EN+TH).
Rebuilt dist.
2026-08-08 11:27:05 +07:00

7 lines
7.3 KiB
JavaScript

import{k as P,_ as $,l as q,s as C,c as l,m as b,n as z,u as a,a as e,t as s,i,F as j,q as S,j as p,A as T,e as m,w as H,v as J,b as O,h as R,r as u,x as U,o as n,C as Q}from"./index-tI5UDFg-.js";import{T as W}from"./target-CylhW5SK.js";import{A as X}from"./arrow-left-C_e4n_39.js";/**
* @license lucide-vue-next v1.0.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y=P("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Z={key:0,class:"card"},ee={style:{"margin-top":"0"}},se=["onClick"],te={class:"row",style:{"align-items":"center"}},ae={key:0,class:"badge line"},le={key:1,class:"badge facebook"},ne={class:"muted",style:{"margin-top":"6px"}},oe=["disabled"],ie={key:1},re={class:"card guide"},ce={style:{margin:"6px 0 0","line-height":"1.7"}},ue={class:"row",style:{"align-items":"center","margin-bottom":"12px"}},de={style:{margin:"0"}},ve={key:0,class:"muted"},pe=["disabled"],me={key:0,class:"spinner",style:{"margin-right":"4px"}},_e={key:0,class:"bubble msg-customer muted"},he={key:0,class:"composer"},ge=["disabled","placeholder"],ye=["disabled"],fe={key:1,class:"card debrief"},be={key:0},ke={key:0,class:"reveal-grid"},xe={class:"rk"},we={class:"rv"},Ce={class:"primary",style:{"margin-top":"12px"}},je={__name:"Chat",setup(Se){const L=R(),f=L.params.gid,k=L.params.pid,c=u(null),_=u("pick"),h=u([]),g=u(""),d=u(!1),r=u(null),B=u(""),D=u(null),x=u("social"),F=[{id:"social",emoji:"💬",init:"customer",label:"Social Media (แชท)",desc:"ลูกค้าทักมาหาคุณก่อน — โทนสั้น ทักๆ ตามสไตล์แชท"},{id:"f2f_call",emoji:"📞",init:"seller",label:"พบหน้า / โทรศัพท์",desc:"คุณต้องเป็นฝ่ายเปิดการสนทนาเชิงรุกกับลีด (ผู้ฝึกทักก่อน)"},{id:"recontact",emoji:"⏳",init:"customer",label:"ลูกค้ากลับมาติดต่อ (1-3 เดือน)",desc:"เคยได้รับข้อมูลไปแล้ว ตอนนี้กลับมาติดต่อ พร้อมตัดสินใจมากขึ้น"}];function A(){Q(()=>{w.value&&(w.value.scrollTop=w.value.scrollHeight)})}const w=u(null);async function I(){_.value="chat";const t=await C.chatStart(f,k,{scenario:x.value});D.value=t.session.id,t.session.task&&(B.value=t.session.task),h.value=t.session.messages||[],h.value.length&&A()}q(async()=>{c.value=(await C.getPersona(f,k)).persona});async function N(){if(g.value.trim()){d.value=!0;try{const t=await C.chatSend(f,k,g.value.trim());h.value=t.messages,g.value="",A()}catch(t){alert(t.message)}finally{d.value=!1}}}async function E(){if(confirm(i.t("finish")+"?")){d.value=!0;try{const t=await C.chatFinish(f,k);r.value=t.debrief,h.value=t.session.messages,_.value="done"}catch(t){alert(t.message)}finally{d.value=!1}}}const M={name:"ชื่อ",tier:"ระดับ",difficulty:"ความยาก",profession:"อาชีพ",age_group:"ช่วงอายุ",location:"พื้นที่",income:"รายได้",budget:"งบประมาณ",lifestyle:"ไลฟ์สไตล์",background:"ภูมิหลัง",personality:"บุคลิก",communication_style:"สไตล์การสื่อสาร",goal:"เป้าหมาย",decision_timeline:"กรอบตัดสินใจ",pains:"ปัญหา (Pain)",objections:"ข้อโต้แย้ง",negotiation_levers:"สิ่งที่ใช้ต่อรอง",opener:"บทเปิดบทสนทนา",channel:"ช่องทาง",initiation_mode:"ใครเริ่มก่อน",product_context:"บริบทสินค้า"};function G(t){return M[t]||t}function K(t){return Array.isArray(t)?t.join(", "):t&&typeof t=="object"?JSON.stringify(t):String(t??"—")}return(t,y)=>{const V=U("router-link");return n(),l("div",null,[b(V,{to:`/groups/${a(f)}/personas`,class:"btn-back"},{default:z(()=>[b(a(X),{size:16,"stroke-width":2}),p(" "+s(a(i).t("personas")),1)]),_:1},8,["to"]),_.value==="pick"?(n(),l("div",Z,[e("h3",ee,"🎬 "+s(a(i).t("chooseScenario")),1),y[1]||(y[1]=e("p",{class:"muted",style:{"margin-top":"0"}},"เลือกสถานการณ์ที่อยากฝึกการขาย — แต่ละแบบกำหนดว่าใครทักก่อน และโทนการสนทนา",-1)),(n(),l(j,null,S(F,o=>e("div",{key:o.id,class:T(["scenario",{sel:x.value===o.id}]),onClick:v=>x.value=o.id},[e("div",te,[e("strong",null,s(o.emoji)+" "+s(o.label),1),o.init==="customer"?(n(),l("span",ae,"ลูกค้าทักก่อน")):(n(),l("span",le,"คุณต้องทักก่อน (เชิงรุก)"))]),e("div",ne,s(o.desc),1)],10,se)),64)),e("button",{class:"primary",style:{"margin-top":"16px",width:"100%"},disabled:!x.value,onClick:I}," ▶ "+s(a(i).t("start")),9,oe)])):(n(),l("div",ie,[e("div",re,[e("strong",null,[b(a(W),{size:17,"stroke-width":1.8,style:{"vertical-align":"-3px"}}),p(" "+s(a(i).t("chatGuideTitle")),1)]),e("p",ce,s(a(i).t("chatGuideText")),1)]),e("div",ue,[e("h2",de,s(c.value?c.value.name:"..."),1),e("span",{class:T(["badge",c.value&&c.value.channel])},s(c.value?c.value.channel:""),3),c.value?(n(),l("span",ve,s(c.value.profession)+" · "+s(c.value.age_group),1)):m("",!0),e("button",{class:"danger",style:{"margin-left":"auto"},onClick:E,disabled:h.value.length===0||_.value==="done"},[d.value?(n(),l("span",me)):m("",!0),p(s(a(i).t("finish")),1)],8,pe)]),e("div",{class:"thread",ref_key:"thread",ref:w},[(n(!0),l(j,null,S(h.value,(o,v)=>(n(),l("div",{key:v,class:T(["bubble",o.role==="seller"?"msg-seller":o.role==="system"?"msg-system":"msg-customer"])},s(o.text),3))),128)),d.value?(n(),l("div",_e,"...")):m("",!0)],512),_.value==="chat"?(n(),l("div",he,[H(e("input",{"onUpdate:modelValue":y[0]||(y[0]=o=>g.value=o),onKeyup:O(N,["enter"]),disabled:d.value,placeholder:a(i).t("send")},null,40,ge),[[J,g.value]]),e("button",{class:"primary",onClick:N,disabled:d.value||!g.value.trim()},s(a(i).t("send")),9,ye)])):m("",!0),_.value==="done"&&r.value?(n(),l("div",fe,[e("h3",null,s(a(i).t("debrief")),1),e("p",null,[e("span",{class:T(["badge",r.value.outcome])},s(r.value.outcome==="won"?a(i).t("won"):a(i).t("lost")),3),p(" — "+s(a(i).t("score"))+": ",1),e("strong",null,s(r.value.score),1)]),e("p",null,[e("strong",null,s(a(i).t("pain"))+":",1),p(" "+s(r.value.pain||"—"),1)]),e("p",null,[e("strong",null,s(a(i).t("why"))+":",1),p(" "+s(r.value.why),1)]),r.value.coaching&&r.value.coaching.length?(n(),l("div",be,[y[2]||(y[2]=e("strong",null,"Coaching:",-1)),e("ul",null,[(n(!0),l(j,null,S(r.value.coaching,(o,v)=>(n(),l("li",{key:v},s(o),1))),128))])])):m("",!0),e("details",null,[e("summary",null,[b(a(Y),{size:15,"stroke-width":1.8,style:{"vertical-align":"-2px"}}),p(" "+s(a(i).t("reveal")),1)]),r.value.revealed_persona?(n(),l("div",ke,[(n(!0),l(j,null,S(r.value.revealed_persona,(o,v)=>(n(),l("div",{key:v,class:"rev"},[e("span",xe,s(G(v)),1),e("span",we,s(K(o)),1)]))),128))])):m("",!0)]),b(V,{to:"/"},{default:z(()=>[e("button",Ce,s(a(i).t("dashboard")),1)]),_:1})])):m("",!0)]))])}}},Ne=$(je,[["__scopeId","data-v-310aef08"]]);export{Ne as default};