Files
service-finder/frontend_admin/.nuxt/dist/client/_nuxt/DR3iKRgS.js
2026-07-02 11:52:22 +00:00

2 lines
9.9 KiB
JavaScript

import{e as $,f as U,g as E,c as r,a as e,t as s,i as t,F as w,d as M,r as L,j as x,x as N,y as g,z as C,I as S,l as m,J as F,h as I,o as d,k as T,m as A}from"./BsgqXOrB.js";import{_ as D}from"./DlAUqK2U.js";const P={class:"mb-8"},J={class:"text-2xl font-bold text-white"},O={class:"text-slate-400 mt-1"},q={key:0,class:"flex items-center justify-center py-20"},G={class:"text-slate-400 flex items-center gap-3"},K={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},Q={class:"text-rose-400"},R={class:"mb-6 flex items-center justify-between"},W={class:"bg-slate-800 rounded-xl border border-slate-700 overflow-hidden mb-8"},X={class:"overflow-x-auto"},Y={class:"w-full"},Z={class:"border-b border-slate-700"},ee={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},te={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},se={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},oe={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},ne={class:"text-right px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},ie={class:"divide-y divide-slate-700/50"},le={class:"px-4 py-3"},ae={class:"inline-flex items-center justify-center w-8 h-8 rounded-lg bg-indigo-500/10 text-indigo-400 text-sm font-bold"},re={class:"px-4 py-3"},de={class:"text-sm font-medium text-white"},ce={class:"px-4 py-3 text-sm text-slate-300"},me={class:"px-4 py-3"},ue={key:0,class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-rose-500/10 text-rose-400 border border-rose-500/20"},_e={key:1,class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"},pe={class:"px-4 py-3 text-right"},fe=["onClick"],xe={key:0},ge={colspan:"5",class:"px-4 py-12 text-center text-slate-500 text-sm"},ve={class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},be={class:"text-lg font-semibold text-white mb-4"},he={key:0,class:"text-sm text-slate-500 text-center py-8"},ye={key:1,class:"flex flex-wrap gap-3"},ke={class:"text-xs text-slate-400"},we={key:0,class:"text-xs text-slate-500"},Ce={class:"bg-slate-800 rounded-xl border border-slate-700 w-full max-w-md mx-4 p-6"},je={class:"text-lg font-semibold text-white mb-6"},Me={class:"space-y-4"},Le={class:"block text-sm font-medium text-slate-300 mb-1"},Te={class:"block text-sm font-medium text-slate-300 mb-1"},Be={class:"block text-sm font-medium text-slate-300 mb-1"},Ve={class:"flex items-center gap-2"},ze={for:"is_penalty",class:"text-sm text-slate-300"},He={key:0,class:"mt-4 bg-rose-500/10 border border-rose-500/30 rounded-lg p-3"},$e={class:"text-sm text-rose-400"},Ue={class:"flex items-center justify-end gap-3 mt-6"},Ee=["disabled"],Ne=$({__name:"levels",setup(Se){const{t:o}=U(),v=m(!0),b=m(!1),p=m(!1),u=m([]),f=m(!1),_=m(null),c=m(""),l=F({level_number:1,rank_name:"",min_points:0,is_penalty:!1}),B=A(()=>[...u.value].sort((a,n)=>a.level_number-n.level_number));function h(){const n=I("access_token").value;return n?{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}function V(){_.value=null,l.level_number=u.value.length+1,l.rank_name="",l.min_points=0,l.is_penalty=!1,c.value="",f.value=!0}function z(a){_.value=a,l.level_number=a.level_number,l.rank_name=a.rank_name,l.min_points=a.min_points,l.is_penalty=a.is_penalty,c.value="",f.value=!0}function y(){f.value=!1,_.value=null}async function k(){v.value=!0,b.value=!1;try{const a=await $fetch("/api/v1/admin/gamification/level-configs",{headers:h()});u.value=a||[]}catch(a){console.error("Failed to fetch level configs:",a),b.value=!0}finally{v.value=!1}}async function H(){p.value=!0,c.value="";try{const a={level_number:l.level_number,rank_name:l.rank_name,min_points:l.min_points,is_penalty:l.is_penalty};_.value?(await $fetch(`/api/v1/admin/gamification/level-configs/${_.value.id}`,{method:"PUT",headers:h(),body:a}),j(o("gamification.levels.updated"))):(await $fetch("/api/v1/admin/gamification/level-configs",{method:"POST",headers:h(),body:a}),j(o("gamification.levels.created"))),y(),await k()}catch(a){a?.data?.detail?.includes("already exists")?c.value=o("gamification.levels.duplicate_error"):c.value=o("gamification.levels.save_error")}finally{p.value=!1}}function j(a){const n=document.createElement("div");n.className="fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm animate-slide-up",n.textContent=a,document.body.appendChild(n),setTimeout(()=>n.remove(),3e3)}return E(()=>{k()}),(a,n)=>(d(),r("div",null,[e("div",P,[e("h1",J,s(t(o)("gamification.levels.title")),1),e("p",O,s(t(o)("gamification.levels.subtitle")),1)]),t(v)?(d(),r("div",q,[e("div",G,[n[4]||(n[4]=e("svg",{class:"w-5 h-5 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1)),e("span",null,s(t(o)("gamification.levels.loading")),1)])])):t(b)?(d(),r("div",K,[e("p",Q,s(t(o)("gamification.levels.load_error")),1),e("button",{onClick:k,class:"mt-3 text-sm text-rose-300 hover:text-rose-200 underline"},s(t(o)("gamification.levels.retry")),1)])):(d(),r(w,{key:2},[e("div",R,[n[6]||(n[6]=e("div",null,null,-1)),e("button",{onClick:V,class:"px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg text-sm font-medium transition flex items-center gap-2"},[n[5]||(n[5]=e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1)),M(" "+s(t(o)("gamification.levels.create")),1)])]),e("div",W,[e("div",X,[e("table",Y,[e("thead",null,[e("tr",Z,[e("th",ee,s(t(o)("gamification.levels.col_level")),1),e("th",te,s(t(o)("gamification.levels.col_rank")),1),e("th",se,s(t(o)("gamification.levels.col_min_points")),1),e("th",oe,s(t(o)("gamification.levels.col_type")),1),e("th",ne,s(t(o)("gamification.levels.col_actions")),1)])]),e("tbody",ie,[(d(!0),r(w,null,L(t(u),i=>(d(),r("tr",{key:i.id,class:"hover:bg-slate-700/30 transition"},[e("td",le,[e("span",ae,s(i.level_number),1)]),e("td",re,[e("span",de,s(i.rank_name),1)]),e("td",ce,s(i.min_points.toLocaleString()),1),e("td",me,[i.is_penalty?(d(),r("span",ue,s(t(o)("gamification.levels.penalty")),1)):(d(),r("span",_e,s(t(o)("gamification.levels.normal")),1))]),e("td",pe,[e("button",{onClick:Fe=>z(i),class:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-indigo-600/10 hover:bg-indigo-600/20 text-indigo-400 text-xs font-medium rounded-lg transition"},[n[7]||(n[7]=e("svg",{class:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)),M(" "+s(t(o)("gamification.levels.edit")),1)],8,fe)])]))),128)),t(u).length===0?(d(),r("tr",xe,[e("td",ge,s(t(o)("gamification.levels.no_levels")),1)])):x("",!0)])])])]),e("div",ve,[e("h2",be,s(t(o)("gamification.levels.tree_diagram")),1),t(u).length===0?(d(),r("div",he,s(t(o)("gamification.levels.no_tree")),1)):(d(),r("div",ye,[(d(!0),r(w,null,L(t(B),i=>(d(),r("div",{key:i.id,class:T(["flex items-center gap-2 px-4 py-2 rounded-lg border transition",i.is_penalty?"bg-rose-500/5 border-rose-500/20":"bg-emerald-500/5 border-emerald-500/20"])},[e("span",{class:T(["text-sm font-bold",i.is_penalty?"text-rose-400":"text-emerald-400"])}," Lv."+s(i.level_number),3),e("span",ke,s(i.rank_name),1),i.is_penalty?x("",!0):(d(),r("span",we,"("+s(i.min_points.toLocaleString())+" pts)",1))],2))),128))]))])],64)),t(f)?(d(),r("div",{key:3,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:N(y,["self"])},[e("div",Ce,[e("h3",je,s(t(_)?t(o)("gamification.levels.edit_title"):t(o)("gamification.levels.create_title")),1),e("div",Me,[e("div",null,[e("label",Le,s(t(o)("gamification.levels.form_level_number")),1),g(e("input",{"onUpdate:modelValue":n[0]||(n[0]=i=>t(l).level_number=i),type:"number",min:"1",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"},null,512),[[C,t(l).level_number,void 0,{number:!0}]])]),e("div",null,[e("label",Te,s(t(o)("gamification.levels.form_rank_name")),1),g(e("input",{"onUpdate:modelValue":n[1]||(n[1]=i=>t(l).rank_name=i),type:"text",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"},null,512),[[C,t(l).rank_name]])]),e("div",null,[e("label",Be,s(t(o)("gamification.levels.form_min_points")),1),g(e("input",{"onUpdate:modelValue":n[2]||(n[2]=i=>t(l).min_points=i),type:"number",min:"0",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50"},null,512),[[C,t(l).min_points,void 0,{number:!0}]])]),e("div",Ve,[g(e("input",{"onUpdate:modelValue":n[3]||(n[3]=i=>t(l).is_penalty=i),type:"checkbox",id:"is_penalty",class:"rounded bg-slate-700 border-slate-600 text-indigo-600 focus:ring-indigo-500"},null,512),[[S,t(l).is_penalty]]),e("label",ze,s(t(o)("gamification.levels.form_is_penalty")),1)])]),t(c)?(d(),r("div",He,[e("p",$e,s(t(c)),1)])):x("",!0),e("div",Ue,[e("button",{onClick:y,class:"px-4 py-2 bg-slate-700 hover:bg-slate-600 text-slate-300 text-sm font-medium rounded-lg transition"},s(t(o)("gamification.levels.cancel")),1),e("button",{onClick:H,disabled:t(p),class:"px-4 py-2 bg-indigo-600 hover:bg-indigo-500 disabled:bg-indigo-600/50 text-white text-sm font-medium rounded-lg transition"},s(t(p)?t(o)("gamification.levels.saving"):t(o)("gamification.levels.save")),9,Ee)])])])):x("",!0)]))}}),De=D(Ne,[["__scopeId","data-v-5fa877fc"]]);export{De as default};