Files
sales-trainer/frontend/dist/assets/GroupEdit-CL_6gtfe.js
Macky 15c60ae400 feat(i18n + export + guide): locale-aware scenarios/debrief; CSV export; how-to-use page
Backend:
- SCENARIOS localized (th/en): scenario preamble + persona tone adaptation follow the
  trainee's locale; start accepts {locale} and stores it on the session; send/auto-finish
  use it so debrief text (why/coaching/turning points) is in the active language.
- /api/analytics/export returns per-trainee finished-session CSV (admin).

Frontend:
- Scenario picker labels localize by i18n.locale.
- New /guide page (non-IT how-to), linked from Training.
- Analytics: date-filter bar uses line icon + 'Download CSV' button (fetch w/ auth).
Rebuilt dist.
2026-08-08 15:06:48 +07:00

10 lines
12 KiB
JavaScript

import{k as I,_ as F,G as M,o as m,c as f,a as e,t as i,w as o,v as u,E as N,e as _,H as O,r as k,l as q,m as A,n as D,u as c,j as y,i as B,B as J,F as P,q as S,I as H,h as R,s as j,x as K,A as T}from"./index-Dm2VwslH.js";import{U as Q}from"./users-ksNXFlzl.js";import{S as W}from"./sparkles-BXnC3-RA.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 X=I("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Y={class:"persona-form"},Z={class:"muted"},h={class:"sec"},ee={class:"row"},le={class:"f"},te={class:"f"},ne={class:"f"},se={class:"row"},oe={class:"f"},ie={class:"f"},ae={class:"f"},ue={class:"sec"},re={class:"row"},de={class:"f"},me={class:"f"},ve={class:"f"},fe={class:"sec"},ge={class:"sec"},ye={class:"row"},be={class:"f"},ke={class:"f"},ce={key:0,class:"muted"},xe={class:"row actions"},we=["disabled"],Ve={__name:"PersonaForm",props:{persona:{type:Object,required:!0}},emits:["save","cancel"],setup(V,{emit:E}){const x=V,p=E,n=O({name:"",difficulty:1,tier:"B",profession:"",age_group:"",location:"",income:"",budget:"",lifestyle:"",background:"",personality:"",communication_style:"",goal:"",decision_timeline:"",opener:"",channel:"line",initiation_mode:"customer",special:""}),d=k(""),b=k(""),v=k(""),w=k(!1);function U(t){return Array.isArray(t)?t.join(`
`):String(t||"")}function $(t){return t.split(`
`).map(l=>l.trim()).filter(Boolean)}M(()=>x.persona,t=>{Object.assign(n,{name:(t==null?void 0:t.name)||"",difficulty:(t==null?void 0:t.difficulty)??1,tier:(t==null?void 0:t.tier)||"B",profession:(t==null?void 0:t.profession)||"",age_group:(t==null?void 0:t.age_group)||"",location:(t==null?void 0:t.location)||"",income:(t==null?void 0:t.income)||"",budget:(t==null?void 0:t.budget)||"",lifestyle:(t==null?void 0:t.lifestyle)||"",background:(t==null?void 0:t.background)||"",personality:(t==null?void 0:t.personality)||"",communication_style:(t==null?void 0:t.communication_style)||"",goal:(t==null?void 0:t.goal)||"",decision_timeline:(t==null?void 0:t.decision_timeline)||"",opener:(t==null?void 0:t.opener)||"",channel:(t==null?void 0:t.channel)||"line",initiation_mode:(t==null?void 0:t.initiation_mode)||"customer",special:(t==null?void 0:t.special)||""}),d.value=U(t==null?void 0:t.pains),b.value=U(t==null?void 0:t.objections),v.value=U(t==null?void 0:t.negotiation_levers)},{immediate:!0});function z(){p("save",{...n,pains:$(d.value),objections:$(b.value),negotiation_levers:$(v.value)})}return(t,l)=>(m(),f("div",Y,[e("h3",null,i(V.persona.name||"New persona"),1),e("p",Z,i(V.persona.profession)+" · "+i(V.persona.personality),1),e("div",h,[l[28]||(l[28]=e("h4",null,"👤 ข้อมูลพื้นฐาน",-1)),e("div",ee,[e("div",le,[l[21]||(l[21]=e("label",null,"ชื่อ",-1)),o(e("input",{"onUpdate:modelValue":l[0]||(l[0]=s=>n.name=s)},null,512),[[u,n.name]])]),e("div",te,[l[22]||(l[22]=e("label",null,"ระดับความยาก (1-5)",-1)),o(e("input",{"onUpdate:modelValue":l[1]||(l[1]=s=>n.difficulty=s),type:"number",min:"1",max:"5"},null,512),[[u,n.difficulty,void 0,{number:!0}]])]),e("div",ne,[l[24]||(l[24]=e("label",null,"ระดับลูกค้า",-1)),o(e("select",{"onUpdate:modelValue":l[2]||(l[2]=s=>n.tier=s)},[...l[23]||(l[23]=[e("option",{value:"A"},"A — พร้อมตัดสินใจซื้อ",-1),e("option",{value:"B"},"B — ยังไม่แน่ใจ",-1),e("option",{value:"C"},"C — ไม่สนใจแต่มีปัญหา",-1)])],512),[[N,n.tier]])])]),e("div",se,[e("div",oe,[l[25]||(l[25]=e("label",null,"อาชีพ",-1)),o(e("input",{"onUpdate:modelValue":l[3]||(l[3]=s=>n.profession=s)},null,512),[[u,n.profession]])]),e("div",ie,[l[26]||(l[26]=e("label",null,"ช่วงอายุ",-1)),o(e("input",{"onUpdate:modelValue":l[4]||(l[4]=s=>n.age_group=s)},null,512),[[u,n.age_group]])]),e("div",ae,[l[27]||(l[27]=e("label",null,"พื้นที่",-1)),o(e("input",{"onUpdate:modelValue":l[5]||(l[5]=s=>n.location=s)},null,512),[[u,n.location]])])])]),e("div",ue,[l[32]||(l[32]=e("h4",null,"💼 ข้อมูลลูกค้า",-1)),e("div",re,[e("div",de,[l[29]||(l[29]=e("label",null,"รายได้/สถานะการเงิน",-1)),o(e("input",{"onUpdate:modelValue":l[6]||(l[6]=s=>n.income=s)},null,512),[[u,n.income]])]),e("div",me,[l[30]||(l[30]=e("label",null,"งบประมาณ",-1)),o(e("input",{"onUpdate:modelValue":l[7]||(l[7]=s=>n.budget=s)},null,512),[[u,n.budget]])]),e("div",ve,[l[31]||(l[31]=e("label",null,"ไลฟ์สไตล์",-1)),o(e("input",{"onUpdate:modelValue":l[8]||(l[8]=s=>n.lifestyle=s)},null,512),[[u,n.lifestyle]])])]),l[33]||(l[33]=e("label",null,"ภูมิหลัง",-1)),o(e("textarea",{"onUpdate:modelValue":l[9]||(l[9]=s=>n.background=s)},null,512),[[u,n.background]]),l[34]||(l[34]=e("label",null,"บุคลิก / วิธีพูดคุย",-1)),o(e("textarea",{"onUpdate:modelValue":l[10]||(l[10]=s=>n.personality=s)},null,512),[[u,n.personality]]),l[35]||(l[35]=e("label",null,"สไตล์การสื่อสาร",-1)),o(e("textarea",{"onUpdate:modelValue":l[11]||(l[11]=s=>n.communication_style=s)},null,512),[[u,n.communication_style]])]),e("div",fe,[l[36]||(l[36]=e("h4",null,"🎯 การขาย",-1)),l[37]||(l[37]=e("label",null,"เป้าหมาย",-1)),o(e("textarea",{"onUpdate:modelValue":l[12]||(l[12]=s=>n.goal=s)},null,512),[[u,n.goal]]),l[38]||(l[38]=e("label",null,"กรอบเวลาในการตัดสินใจ",-1)),o(e("input",{"onUpdate:modelValue":l[13]||(l[13]=s=>n.decision_timeline=s)},null,512),[[u,n.decision_timeline]]),l[39]||(l[39]=e("label",null,"Pain (ปัญหา) แบบ 1 ต่อบรรทัด",-1)),o(e("textarea",{"onUpdate:modelValue":l[14]||(l[14]=s=>d.value=s),placeholder:`เช่น ต้นทุนสูงเกินไป
ระบบล้าสมัย`},null,512),[[u,d.value]]),l[40]||(l[40]=e("label",null,"ข้อโต้แย้ง (Objections) 1 ต่อบรรทัด",-1)),o(e("textarea",{"onUpdate:modelValue":l[15]||(l[15]=s=>b.value=s)},null,512),[[u,b.value]]),l[41]||(l[41]=e("label",null,"สิ่งที่ใช้ต่อรอง (เช่น ส่วนลด, ฟรีติดตั้ง)",-1)),o(e("textarea",{"onUpdate:modelValue":l[16]||(l[16]=s=>v.value=s)},null,512),[[u,v.value]]),l[42]||(l[42]=e("label",null,"ช่องทางสำหรับลูกค้าเปิดบทสนทนา (opener)",-1)),o(e("textarea",{"onUpdate:modelValue":l[17]||(l[17]=s=>n.opener=s)},null,512),[[u,n.opener]])]),e("div",ge,[l[47]||(l[47]=e("h4",null,"📡 ช่องทาง & โหมด",-1)),e("div",ye,[e("div",be,[l[44]||(l[44]=e("label",null,"ช่องทาง",-1)),o(e("select",{"onUpdate:modelValue":l[18]||(l[18]=s=>n.channel=s)},[...l[43]||(l[43]=[e("option",{value:"line"},"LINE",-1),e("option",{value:"facebook"},"Facebook",-1)])],512),[[N,n.channel]])]),e("div",ke,[l[46]||(l[46]=e("label",null,"ใครเริ่มคุยก่อน",-1)),o(e("select",{"onUpdate:modelValue":l[19]||(l[19]=s=>n.initiation_mode=s)},[...l[45]||(l[45]=[e("option",{value:"customer"},"ลูกค้าทักก่อน",-1),e("option",{value:"seller"},"เราต้องเริ่มขาย (เชิงรุก)",-1)])],512),[[N,n.initiation_mode]])])]),n.special?(m(),f("label",ce,"พิเศษ: "+i(n.special),1)):_("",!0)]),e("div",xe,[e("button",{class:"primary",onClick:z,disabled:w.value},i(w.value?"กำลังบันทึก…":"💾 บันทึกบุคคลต้นแบบ"),9,we),e("button",{onClick:l[20]||(l[20]=s=>t.$emit("cancel"))},"ปิด")])]))}},pe=F(Ve,[["__scopeId","data-v-738758fc"]]),Ue={class:"row",style:{"align-items":"center","margin-bottom":"8px"}},$e={style:{margin:"0"}},Ce={class:"row",style:{"margin-left":"auto",gap:"10px"}},Be=["disabled"],_e={key:0,class:"spinner"},Ae={key:0,class:"muted"},je={key:1,class:"error",style:{margin:"12px 0"}},ze={key:2,class:"card empty-state"},Le={class:"grid"},Ne={class:"row",style:{"justify-content":"space-between","align-items":"center"}},Pe={class:"diff"},Se={class:"muted"},Ee={class:"muted"},Te=["onClick"],Fe={class:"modal"},Ge={__name:"GroupEdit",setup(V){const x=R().params.gid,p=k(null),n=k([]),d=k(!1),b=k(""),v=k(null);async function w(){const a=await j.getGroup(x);p.value=a.group,n.value=(await j.listPersonas(x)).personas}function U(a){return n.value.filter(r=>r.tier===a)}function $(a){return B.t(a==="A"?"tierA":a==="B"?"tierB":"tierC")}function z(a){return{A:"tier-a",B:"tier-b",C:"tier-c"}[a]||""}async function t(){d.value=!0,b.value="";try{const a=await j.analyzeGroup(x);n.value=a.personas,await w()}catch(a){b.value=a.message}finally{d.value=!1}}function l(a){v.value=JSON.parse(JSON.stringify(a))}async function s(a){d.value=!0;try{await j.updatePersona(x,v.value.id,a),v.value=null,await w()}catch(r){b.value=r.message}finally{d.value=!1}}return q(w),(a,r)=>{const G=K("router-link");return m(),f("div",null,[A(G,{to:"/training",class:"btn-back"},{default:D(()=>[y("← "+i(c(B).t("training")),1)]),_:1}),e("div",Ue,[e("h2",$e,[A(c(Q),{size:22,"stroke-width":1.8,style:{"vertical-align":"-4px"}}),y(" "+i(c(B).t("managePersonas")),1)]),e("div",Ce,[e("button",{onClick:t,disabled:d.value,class:"primary"},[d.value?(m(),f("span",_e)):(m(),J(c(W),{key:1,size:18,"stroke-width":1.8})),y(" "+i(d.value?"กำลังสร้าง…":c(B).t("analyze")),1)],8,Be)])]),p.value?(m(),f("p",Ae,[r[2]||(r[2]=y("สินค้า: ",-1)),e("strong",null,i(p.value.title),1)])):_("",!0),b.value?(m(),f("div",je,i(b.value),1)):_("",!0),r[4]||(r[4]=e("div",{class:"card guide"},[e("strong",null,"วิธีใช้หน้านี้"),e("ol",{style:{margin:"8px 0 0","padding-left":"20px","line-height":"1.8"}},[e("li",null,[y("กดปุ่ม "),e("strong",null,"✨ สร้าง/วิเคราะห์บุคคลต้นแบบ"),y(" เพื่อให้ระบบสร้างลูกค้าจำลอง 15 คน (ระดับ A/B/C)")]),e("li",null,[y("แต่ละการ์ดคือลูกค้าจำลอง 1 คน — กด "),e("strong",null,"✏️ แก้ไข"),y(" เพื่อปรับรายละเอียดให้ตรงใจ")]),e("li",null,[y("เมื่อพร้อมให้ผู้ใช้ฝึก กด "),e("strong",null,"เปิดใช้งาน"),y(" (ยังทำในขั้นถัดไป)")])])],-1)),n.value.length===0&&!d.value?(m(),f("div",ze,[...r[3]||(r[3]=[e("strong",null,"ยังไม่มีบุคคลต้นแบบ",-1),e("span",null,'กด "✨ สร้าง/วิเคราะห์บุคคลต้นแบบ" เพื่อให้ระบบสร้างลูกค้าจำลองให้',-1)])])):_("",!0),(m(),f(P,null,S(["A","B","C"],C=>e("div",{key:C,style:{"margin-bottom":"20px"}},[e("h4",null,i($(C)),1),e("div",Le,[(m(!0),f(P,null,S(U(C),g=>(m(),f("div",{key:g.id,class:"card pcard"},[e("div",Ne,[e("strong",null,i(g.name),1),e("span",{class:T(["badge",z(g.tier)])},i(g.tier),3)]),e("div",Pe,[(m(),f(P,null,S(5,L=>e("span",{key:L,class:T(["star",{on:L<=(g.difficulty||1)}])},"★",2)),64))]),e("div",Se,i(g.profession)+" · "+i(g.age_group)+" · "+i(g.location),1),e("div",Ee,i(g.channel)+" · "+i(g.initiation_mode==="seller"?"เริ่มขายเอง":"ลูกค้าทักก่อน"),1),e("button",{class:"edit-btn",onClick:L=>l(g)},[A(c(X),{size:15,"stroke-width":1.8}),y(" "+i(c(B).t("edit")),1)],8,Te)]))),128))])])),64)),v.value?(m(),f("div",{key:3,class:"modal-backdrop",onClick:r[1]||(r[1]=H(C=>v.value=null,["self"]))},[e("div",Fe,[A(pe,{persona:v.value,onSave:s,onCancel:r[0]||(r[0]=C=>v.value=null)},null,8,["persona"])])])):_("",!0)])}}},qe=F(Ge,[["__scopeId","data-v-c682ddb6"]]);export{qe as default};