2 lines
9.7 KiB
JavaScript
2 lines
9.7 KiB
JavaScript
import{_ as C}from"./DRkNpQ1P.js";import{e as B,f as M,g as z,h as A,c as r,a as t,t as e,i as s,F as f,b as x,w as _,r as j,l as h,o as n,d as p,k as v}from"./CQHa_U7G.js";const V={class:"mb-8"},$={class:"text-2xl font-bold text-white"},D={class:"text-slate-400 mt-1"},L={key:0,class:"flex items-center justify-center py-20"},N={class:"text-slate-400 flex items-center gap-3"},F={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},H={class:"text-rose-400"},q={class:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-6 mb-8"},E={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 hover:border-amber-500/50 transition group"},I={class:"text-sm font-medium text-slate-400 uppercase tracking-wider"},P={class:"text-3xl font-bold text-white mt-2"},S={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 hover:border-emerald-500/50 transition group"},T={class:"text-sm font-medium text-slate-400 uppercase tracking-wider"},U={class:"text-3xl font-bold text-white mt-2"},G={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 hover:border-violet-500/50 transition group"},J={class:"text-sm font-medium text-slate-400 uppercase tracking-wider"},K={class:"text-3xl font-bold text-white mt-2"},O={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 hover:border-cyan-500/50 transition group"},Q={class:"text-sm font-medium text-slate-400 uppercase tracking-wider"},R={class:"text-3xl font-bold text-white mt-2"},W={class:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8"},X={class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},Y={class:"text-lg font-semibold text-white mb-4"},Z={class:"space-y-3"},tt={class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},et={class:"text-lg font-semibold text-white mb-4"},st={key:0,class:"text-sm text-slate-500 text-center py-8"},ot={key:1,class:"space-y-3"},at={class:"text-sm text-slate-300"},it={class:"text-xs text-slate-500"},rt={class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},nt={class:"flex items-center justify-between mb-4"},lt={class:"text-lg font-semibold text-white"},dt={key:0,class:"text-sm text-slate-500 text-center py-8"},ct={key:1,class:"space-y-2"},mt={class:"flex-1"},ht={class:"text-sm font-medium text-white"},xt={class:"text-xs text-slate-500"},_t={class:"text-sm font-semibold text-emerald-400"},ut=B({__name:"index",setup(pt){const{t:o}=M(),k=h(!0),w=h(!1),m=h({total_users:0,active_season:null,pending_contributions:0,today_xp:0}),b=h([]),g=h([]);return z(async()=>{try{const a=A("access_token").value,c=a?{Authorization:`Bearer ${a}`}:{},[i,l,y]=await Promise.all([$fetch("/api/v1/admin/gamification/dashboard-summary",{headers:c}).catch(()=>({total:0})),$fetch("/api/v1/admin/gamification/points-ledger?limit=5",{headers:c}).catch(()=>[]),$fetch("/api/v1/gamification/leaderboard?limit=5",{headers:c}).catch(()=>[])]);m.value={total_users:i.total??0,active_season:i.active_season??null,pending_contributions:i.pending_contributions??0,today_xp:i.today_xp??0},b.value=Array.isArray(l)?l.slice(0,5):[],g.value=Array.isArray(y)?y.slice(0,5).map(d=>({user_name:d.username||d.user_name||`User #${d.user_id}`,level:d.current_level||d.level||0,xp:d.total_xp||d.xp||0,total_points:d.total_points||d.total_xp||0})):[]}catch(u){console.error("Failed to load gamification dashboard:",u),w.value=!0}finally{k.value=!1}}),(u,a)=>{const c=C;return n(),r("div",null,[t("div",V,[t("h1",$,e(s(o)("gamification.dashboard.title")),1),t("p",D,e(s(o)("gamification.dashboard.subtitle")),1)]),s(k)?(n(),r("div",L,[t("div",N,[a[0]||(a[0]=t("svg",{class:"w-5 h-5 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("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)),t("span",null,e(s(o)("gamification.dashboard.loading")),1)])])):s(w)?(n(),r("div",F,[t("p",H,e(s(o)("gamification.dashboard.load_error")),1)])):(n(),r(f,{key:2},[t("div",q,[t("div",E,[a[1]||(a[1]=t("div",{class:"flex items-center justify-between mb-4"},[t("div",{class:"p-2 rounded-lg bg-amber-500/10 text-amber-400 group-hover:bg-amber-500/20 transition"},[t("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})])])],-1)),t("h3",I,e(s(o)("gamification.dashboard.total_users")),1),t("p",P,e(s(m).total_users),1)]),t("div",S,[a[2]||(a[2]=t("div",{class:"flex items-center justify-between mb-4"},[t("div",{class:"p-2 rounded-lg bg-emerald-500/10 text-emerald-400 group-hover:bg-emerald-500/20 transition"},[t("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})])])],-1)),t("h3",T,e(s(o)("gamification.dashboard.active_season")),1),t("p",U,e(s(m).active_season||s(o)("gamification.dashboard.none")),1)]),t("div",G,[a[3]||(a[3]=t("div",{class:"flex items-center justify-between mb-4"},[t("div",{class:"p-2 rounded-lg bg-violet-500/10 text-violet-400 group-hover:bg-violet-500/20 transition"},[t("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})])])],-1)),t("h3",J,e(s(o)("gamification.dashboard.pending_contributions")),1),t("p",K,e(s(m).pending_contributions),1)]),t("div",O,[a[4]||(a[4]=t("div",{class:"flex items-center justify-between mb-4"},[t("div",{class:"p-2 rounded-lg bg-cyan-500/10 text-cyan-400 group-hover:bg-cyan-500/20 transition"},[t("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})])])],-1)),t("h3",Q,e(s(o)("gamification.dashboard.today_xp")),1),t("p",R,e(s(m).today_xp),1)])]),t("div",W,[t("div",X,[t("h2",Y,e(s(o)("gamification.dashboard.quick_actions")),1),t("div",Z,[x(c,{to:"/gamification/point-rules",class:"flex items-center gap-3 px-4 py-3 bg-slate-700/50 hover:bg-slate-700 rounded-lg text-sm text-slate-300 hover:text-white transition"},{default:_(()=>[a[5]||(a[5]=t("svg",{class:"w-5 h-5 text-amber-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),p(" "+e(s(o)("gamification.dashboard.manage_point_rules")),1)]),_:1}),x(c,{to:"/gamification/badges",class:"flex items-center gap-3 px-4 py-3 bg-slate-700/50 hover:bg-slate-700 rounded-lg text-sm text-slate-300 hover:text-white transition"},{default:_(()=>[a[6]||(a[6]=t("svg",{class:"w-5 h-5 text-violet-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"})],-1)),p(" "+e(s(o)("gamification.dashboard.manage_badges")),1)]),_:1}),x(c,{to:"/gamification/seasons",class:"flex items-center gap-3 px-4 py-3 bg-slate-700/50 hover:bg-slate-700 rounded-lg text-sm text-slate-300 hover:text-white transition"},{default:_(()=>[a[7]||(a[7]=t("svg",{class:"w-5 h-5 text-emerald-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})],-1)),p(" "+e(s(o)("gamification.dashboard.manage_seasons")),1)]),_:1})])]),t("div",tt,[t("h2",et,e(s(o)("gamification.dashboard.recent_ledger")),1),s(b).length===0?(n(),r("div",st,e(s(o)("gamification.dashboard.no_ledger_entries")),1)):(n(),r("div",ot,[(n(!0),r(f,null,j(s(b),i=>(n(),r("div",{key:i.id,class:"flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0"},[t("div",null,[t("p",at,e(i.reason),1),t("p",it,e(i.created_at),1)]),t("span",{class:v(["text-sm font-semibold",i.points>=0?"text-emerald-400":"text-rose-400"])},e(i.points>=0?"+":"")+e(i.points),3)]))),128))]))])]),t("div",rt,[t("div",nt,[t("h2",lt,e(s(o)("gamification.dashboard.top_5_leaderboard")),1),x(c,{to:"/gamification/leaderboard",class:"text-sm text-indigo-400 hover:text-indigo-300 transition"},{default:_(()=>[p(e(s(o)("gamification.dashboard.full_leaderboard"))+" → ",1)]),_:1})]),s(g).length===0?(n(),r("div",dt,e(s(o)("gamification.dashboard.no_leaderboard_data")),1)):(n(),r("div",ct,[(n(!0),r(f,null,j(s(g),(i,l)=>(n(),r("div",{key:l,class:v(["flex items-center gap-4 px-4 py-3 rounded-lg",l<3?"bg-slate-700/50":""])},[t("span",{class:v(["w-8 text-center text-lg font-bold",l===0?"text-amber-400":l===1?"text-slate-300":l===2?"text-amber-700":"text-slate-500"])}," #"+e(l+1),3),t("div",mt,[t("p",ht,e(i.user_name),1),t("p",xt,e(s(o)("gamification.dashboard.level"))+" "+e(i.level)+" · "+e(i.xp)+" "+e(s(o)("gamification.dashboard.xp_abbr")),1)]),t("span",_t,e(i.total_points)+" "+e(s(o)("gamification.dashboard.points")),1)],2))),128))]))])],64))])}}});export{ut as default};
|