- Chat: add 'How to practice' guide card; render revealed persona as readable label:value grid instead of JSON. - AdminUsers: switch create form to username (matches username login), add step guide, role explanation (user=ฝึก, admin=ดูแลระบบ). - Analytics (admin overview) + MyBoard (personal): add plain-Thai explainer subtitle. - Rebuild dist. Verified user create with username -> 201.
2 lines
4.9 KiB
JavaScript
2 lines
4.9 KiB
JavaScript
import{_ as G,k as K,q as x,c as a,l as j,m as D,u as n,a as s,t,i as o,z as C,e as u,j as m,F as T,p as S,w as M,v as P,b as q,h as H,r as c,B as J,s as O,o as l}from"./index-BhdfH8-z.js";const R={class:"card guide"},U={style:{margin:"6px 0 0","line-height":"1.7"}},$={class:"row",style:{"align-items":"center","margin-bottom":"12px"}},Q={style:{margin:"0"}},W={key:0,class:"muted"},X=["disabled"],Y={key:0,class:"spinner",style:{"margin-right":"4px"}},Z={key:0,class:"card task"},ee={key:0},se={key:0,class:"bubble msg-customer muted"},te={key:2,class:"composer"},ae=["disabled","placeholder"],le=["disabled"],ne={key:3,class:"card debrief"},oe={key:0},ie={key:0,class:"reveal-grid"},re={class:"rk"},ue={class:"rv"},ce={class:"primary",style:{"margin-top":"12px"}},de={__name:"Chat",setup(ve){const B=H(),g=B.params.gid,f=B.params.pid,r=c(null),y=c(!1),_=c([]),p=c(""),d=c(!1),i=c(null),w=c(""),F=c(null);function L(){J(()=>{b.value&&(b.value.scrollTop=b.value.scrollHeight)})}const b=c(null);K(async()=>{r.value=(await x.getPersona(g,f)).persona;const e=await x.chatStart(g,f);F.value=e.session.id,e.session.task&&(w.value=e.session.task),_.value=e.session.messages||[],y.value=!0,_.value.length&&L()});async function N(){if(p.value.trim()){d.value=!0;try{const e=await x.chatSend(g,f,p.value.trim());_.value=e.messages,p.value="",L()}catch(e){alert(e.message)}finally{d.value=!1}}}async function I(){if(confirm(o.t("finish")+"?")){d.value=!0;try{const e=await x.chatFinish(g,f);i.value=e.debrief,_.value=e.session.messages}catch(e){alert(e.message)}finally{d.value=!1}}}const A={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 E(e){return A[e]||e}function z(e){return Array.isArray(e)?e.join(", "):e&&typeof e=="object"?JSON.stringify(e):String(e??"—")}return(e,k)=>{const V=O("router-link");return l(),a("div",null,[j(V,{to:`/groups/${n(g)}/personas`,class:"btn-back"},{default:D(()=>[m("← "+t(n(o).t("personas")),1)]),_:1},8,["to"]),s("div",R,[s("strong",null,"🎯 "+t(n(o).t("chatGuideTitle")),1),s("p",U,t(n(o).t("chatGuideText")),1)]),s("div",$,[s("h2",Q,t(r.value?r.value.name:"..."),1),s("span",{class:C(["badge",r.value&&r.value.channel])},t(r.value?r.value.channel:""),3),r.value?(l(),a("span",W,t(r.value.profession)+" · "+t(r.value.age_group),1)):u("",!0),s("button",{class:"danger",style:{"margin-left":"auto"},onClick:I,disabled:_.value.length===0||!!i.value},[d.value?(l(),a("span",Y)):u("",!0),m(t(n(o).t("finish")),1)],8,X)]),y.value?u("",!0):(l(),a("div",Z,[s("strong",null,"📣 "+t(n(o).t("sellerInitiated")),1),w.value?(l(),a("div",ee,t(w.value),1)):u("",!0)])),y.value?(l(),a("div",{key:1,class:"thread",ref_key:"thread",ref:b},[(l(!0),a(T,null,S(_.value,(v,h)=>(l(),a("div",{key:h,class:C(["bubble",v.role==="seller"?"msg-seller":"msg-customer"])},t(v.text),3))),128)),d.value?(l(),a("div",se,"...")):u("",!0)],512)):u("",!0),y.value&&!i.value?(l(),a("div",te,[M(s("input",{"onUpdate:modelValue":k[0]||(k[0]=v=>p.value=v),onKeyup:q(N,["enter"]),disabled:d.value,placeholder:n(o).t("send")},null,40,ae),[[P,p.value]]),s("button",{class:"primary",onClick:N,disabled:d.value||!p.value.trim()},t(n(o).t("send")),9,le)])):u("",!0),i.value?(l(),a("div",ne,[s("h3",null,t(n(o).t("debrief")),1),s("p",null,[s("span",{class:C(["badge",i.value.outcome])},t(i.value.outcome==="won"?n(o).t("won"):n(o).t("lost")),3),m(" — "+t(n(o).t("score"))+": ",1),s("strong",null,t(i.value.score),1)]),s("p",null,[s("strong",null,t(n(o).t("pain"))+":",1),m(" "+t(i.value.pain||"—"),1)]),s("p",null,[s("strong",null,t(n(o).t("why"))+":",1),m(" "+t(i.value.why),1)]),i.value.coaching&&i.value.coaching.length?(l(),a("div",oe,[k[1]||(k[1]=s("strong",null,"Coaching:",-1)),s("ul",null,[(l(!0),a(T,null,S(i.value.coaching,(v,h)=>(l(),a("li",{key:h},t(v),1))),128))])])):u("",!0),s("details",null,[s("summary",null,"🔎 "+t(n(o).t("reveal")),1),i.value.revealed_persona?(l(),a("div",ie,[(l(!0),a(T,null,S(i.value.revealed_persona,(v,h)=>(l(),a("div",{key:h,class:"rev"},[s("span",re,t(E(h)),1),s("span",ue,t(z(v)),1)]))),128))])):u("",!0)]),j(V,{to:"/"},{default:D(()=>[s("button",ce,t(n(o).t("dashboard")),1)]),_:1})])):u("",!0)])}}},pe=G(de,[["__scopeId","data-v-16c880f2"]]);export{pe as default};
|