2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
import{_ as K}from"./C2l6xpLd.js";import{e as E,f as Q,g as q,c as d,a as e,t as s,i as t,y as g,z as B,N as G,C as M,F as j,r as S,A as V,d as U,k as f,l as m,h as J,o as c,b as W,w as X}from"./BIbQr1Hg.js";import{u as Y}from"./XheHpngv.js";import"./DXATb271.js";const Z={class:"mb-8"},ee={class:"text-2xl font-bold text-white"},te={class:"text-slate-400 mt-1"},se={class:"bg-slate-800 rounded-xl border border-slate-700 p-4 mb-6"},oe={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4"},ae={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},ie={class:"relative"},le=["placeholder"],re={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},ne={value:""},de=["value"],ce={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},ue={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},pe={value:"total_xp"},xe={value:"total_points"},me={value:"social_points"},_e={value:"current_level"},fe={class:"flex items-center gap-3 mt-4 pt-4 border-t border-slate-700/50"},be={class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},ge={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"},he={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4"},ve={class:"text-xs text-slate-500 ml-auto"},ke={key:0,class:"flex items-center justify-center py-20"},we={class:"text-slate-400 flex items-center gap-3"},ye={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},Ce={class:"text-rose-400"},Me={key:2,class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},Be={class:"text-slate-400 text-center py-12"},je={key:3,class:"bg-slate-800 rounded-xl border border-slate-700 overflow-hidden"},Se={class:"overflow-x-auto"},Ve={class:"w-full"},Ue={class:"border-b border-slate-700"},Fe={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},Le={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},Ne={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},Pe={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},$e={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},ze={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},Ae={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},Re={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},De={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"},Te={class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider"},He={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"},Ke={class:"px-4 py-3"},Ee={class:"px-4 py-3"},Qe={class:"flex items-center gap-2"},qe={class:"w-8 h-8 rounded-full bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-xs font-bold text-white flex-shrink-0"},Ge={class:"text-sm font-medium text-white"},Je={class:"px-4 py-3 text-sm text-slate-400 font-mono"},We={class:"px-4 py-3"},Xe={class:"flex items-center gap-1.5"},Ye={class:"text-sm font-semibold text-white"},Ze={class:"px-4 py-3"},et={class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-indigo-500/10 text-indigo-400 border border-indigo-500/20"},tt={class:"px-4 py-3 text-sm text-slate-300"},st={class:"px-4 py-3 text-sm text-slate-300"},ot={class:"px-4 py-3"},at={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"},it={key:1,class:"text-sm text-slate-500"},lt={class:"px-4 py-3"},rt={key:0,class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-400 border border-amber-500/20"},nt={key:1,class:"text-sm text-slate-500"},dt={class:"px-4 py-3 text-sm text-slate-300"},ct={class:"px-4 py-3 text-sm text-slate-300"},ut={class:"px-4 py-3 text-sm text-slate-500"},pt={class:"px-4 py-3 text-right"},xt={class:"flex items-center justify-between px-4 py-3 border-t border-slate-700"},mt={class:"flex items-center gap-2"},_t=["disabled"],ft=["disabled"],bt={class:"flex items-center gap-3"},gt={class:"text-sm text-slate-500"},ht={value:25},vt={value:50},kt={value:100},wt={value:250},yt={class:"flex items-center gap-2"},Ct=["disabled"],Mt=["disabled"],Ft=E({__name:"leaderboard",setup(Bt){const{t:o}=Q(),{formatNumber:h,formatDateTime:F}=Y(),v=m(!1),k=m(!1),w=m([]),p=m(0),r=m(0),u=m(50),b=m("total_xp"),_=m("desc"),n=m({search:"",level:"",min_xp:null});function L(l){switch(l){case 1:return o("gamification.leaderboard.restriction_mild");case 2:return o("gamification.leaderboard.restriction_moderate");case 3:return o("gamification.leaderboard.restriction_severe");default:return`${l}. ${o("gamification.leaderboard.restriction_level")}`}}function N(l){return l.split(" ").map(i=>i.charAt(0).toUpperCase()).slice(0,2).join("")}function P(l){return l===1?"bg-amber-500/20 text-amber-400 border border-amber-500/30":l===2?"bg-slate-300/10 text-slate-300 border border-slate-400/20":l===3?"bg-amber-700/20 text-amber-600 border border-amber-700/30":"bg-slate-700/50 text-slate-400 border border-slate-600/30"}function $(l){return l===1?"bg-amber-500/5":l===2?"bg-slate-300/5":l===3?"bg-amber-700/5":""}function z(){_.value=_.value==="desc"?"asc":"desc",y()}function A(){const l=new URLSearchParams;return l.set("limit",String(u.value)),l.set("offset",String(r.value)),l.set("sort_by",b.value),l.set("sort_order",_.value),n.value.level!==""&&l.set("level",String(n.value.level)),n.value.min_xp!==null&&n.value.min_xp>0&&l.set("min_xp",String(n.value.min_xp)),n.value.search&&n.value.search.length>=2&&l.set("search",n.value.search.trim()),l.toString()}async function x(){v.value=!0,k.value=!1;try{const i=J("access_token").value,C=i?{Authorization:`Bearer ${i}`}:{},a=await $fetch(`/api/v1/admin/gamification/leaderboard?${A()}`,{headers:C});w.value=a.entries||[],p.value=a.total||0}catch(l){console.error("Failed to load leaderboard:",l),k.value=!0}finally{v.value=!1}}function y(){r.value=0,x()}function R(){n.value={search:"",level:"",min_xp:null},b.value="total_xp",_.value="desc",r.value=0,x()}function D(){r.value=0,x()}function O(){r.value=0,x()}function T(){r.value>0&&(r.value=Math.max(0,r.value-u.value),x())}function H(){r.value+=u.value,x()}function I(){const l=Math.max(0,Math.floor((p.value-1)/u.value)*u.value);r.value=l,x()}return q(()=>{x()}),(l,i)=>{const C=K;return c(),d("div",null,[e("div",Z,[e("h1",ee,s(t(o)("gamification.leaderboard.title")),1),e("p",te,s(t(o)("gamification.leaderboard.subtitle")),1)]),e("div",se,[e("div",oe,[e("div",null,[e("label",ae,s(t(o)("gamification.leaderboard.search")),1),e("div",ie,[g(e("input",{"onUpdate:modelValue":i[0]||(i[0]=a=>t(n).search=a),type:"text",placeholder:t(o)("gamification.leaderboard.search_placeholder"),class:"w-full bg-slate-700 border border-slate-600 rounded-lg pl-9 pr-3 py-2 text-sm text-white placeholder-slate-500 focus:ring-2 focus:ring-indigo-500 focus:border-transparent",onKeyup:G(y,["enter"])},null,40,le),[[B,t(n).search]]),i[5]||(i[5]=e("svg",{class:"absolute left-2.5 top-2.5 w-4 h-4 text-slate-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1))])]),e("div",null,[e("label",re,s(t(o)("gamification.leaderboard.level")),1),g(e("select",{"onUpdate:modelValue":i[1]||(i[1]=a=>t(n).level=a),class:"w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"},[e("option",ne,s(t(o)("gamification.leaderboard.all_levels")),1),(c(),d(j,null,S(20,a=>e("option",{key:a,value:a},s(a)+". "+s(t(o)("gamification.leaderboard.level_suffix")),9,de)),64))],512),[[M,t(n).level]])]),e("div",null,[e("label",ce,s(t(o)("gamification.leaderboard.min_xp")),1),g(e("input",{"onUpdate:modelValue":i[2]||(i[2]=a=>t(n).min_xp=a),type:"number",min:"0",placeholder:"0",class:"w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"},null,512),[[B,t(n).min_xp,void 0,{number:!0}]])]),e("div",null,[e("label",ue,s(t(o)("gamification.leaderboard.sort_by")),1),g(e("select",{"onUpdate:modelValue":i[3]||(i[3]=a=>V(b)?b.value=a:null),class:"w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"},[e("option",pe,s(t(o)("gamification.leaderboard.sort_xp")),1),e("option",xe,s(t(o)("gamification.leaderboard.sort_points")),1),e("option",me,s(t(o)("gamification.leaderboard.sort_social")),1),e("option",_e,s(t(o)("gamification.leaderboard.sort_level")),1)],512),[[M,t(b)]])])]),e("div",fe,[e("button",{onClick:y,class:"px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition"},s(t(o)("gamification.leaderboard.filter")),1),e("button",{onClick:R,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.leaderboard.reset")),1),e("button",{onClick:z,class:"px-3 py-2 bg-slate-700 hover:bg-slate-600 text-slate-300 text-sm font-medium rounded-lg transition flex items-center gap-1.5"},[(c(),d("svg",be,[t(_)==="desc"?(c(),d("path",ge)):(c(),d("path",he))])),U(" "+s(t(_)==="desc"?t(o)("gamification.leaderboard.desc"):t(o)("gamification.leaderboard.asc")),1)]),e("span",ve,s(t(p))+" "+s(t(o)("gamification.leaderboard.users_count")),1)])]),t(v)?(c(),d("div",ke,[e("div",we,[i[6]||(i[6]=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.leaderboard.loading")),1)])])):t(k)?(c(),d("div",ye,[e("p",Ce,s(t(o)("gamification.leaderboard.load_error")),1),e("button",{onClick:x,class:"mt-3 text-sm text-rose-300 hover:text-rose-200 underline"},s(t(o)("gamification.leaderboard.retry")),1)])):t(w).length===0?(c(),d("div",Me,[e("p",Be,s(t(o)("gamification.leaderboard.empty")),1)])):(c(),d("div",je,[e("div",Se,[e("table",Ve,[e("thead",null,[e("tr",Ue,[i[7]||(i[7]=e("th",{class:"text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider w-16"},"#",-1)),e("th",Fe,s(t(o)("gamification.leaderboard.col_user")),1),e("th",Le,s(t(o)("gamification.leaderboard.col_email")),1),e("th",Ne,s(t(o)("gamification.leaderboard.col_xp")),1),e("th",Pe,s(t(o)("gamification.leaderboard.col_level")),1),e("th",$e,s(t(o)("gamification.leaderboard.col_points")),1),e("th",ze,s(t(o)("gamification.leaderboard.col_social")),1),e("th",Ae,s(t(o)("gamification.leaderboard.col_penalty")),1),e("th",Re,s(t(o)("gamification.leaderboard.col_restriction")),1),e("th",De,s(t(o)("gamification.leaderboard.col_discoveries")),1),e("th",Oe,s(t(o)("gamification.leaderboard.col_services")),1),e("th",Te,s(t(o)("gamification.leaderboard.col_updated")),1),e("th",He,s(t(o)("gamification.leaderboard.col_actions")),1)])]),e("tbody",Ie,[(c(!0),d(j,null,S(t(w),a=>(c(),d("tr",{key:a.user_id,class:f(["hover:bg-slate-700/30 transition",$(a.rank)])},[e("td",Ke,[e("span",{class:f(["inline-flex items-center justify-center w-8 h-8 rounded-full text-sm font-bold",P(a.rank)])},s(a.rank),3)]),e("td",Ee,[e("div",Qe,[e("div",qe,s(N(a.user_name)),1),e("span",Ge,s(a.user_name),1)])]),e("td",Je,s(a.user_email||"—"),1),e("td",We,[e("div",Xe,[i[8]||(i[8]=e("svg",{class:"w-4 h-4 text-amber-400",fill:"currentColor",viewBox:"0 0 20 20"},[e("path",{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)),e("span",Ye,s(t(h)(a.total_xp)),1)])]),e("td",Ze,[e("span",et,s(a.current_level),1)]),e("td",tt,s(t(h)(a.total_points)),1),e("td",st,s(t(h)(a.social_points)),1),e("td",ot,[a.penalty_points>0?(c(),d("span",at," -"+s(a.penalty_points),1)):(c(),d("span",it,"—"))]),e("td",lt,[a.restriction_level>0?(c(),d("span",rt,s(L(a.restriction_level)),1)):(c(),d("span",nt,"—"))]),e("td",dt,s(a.places_discovered),1),e("td",ct,s(a.services_submitted),1),e("td",ut,s(a.updated_at?t(F)(a.updated_at):"—"),1),e("td",pt,[W(C,{to:`/gamification/users/${a.user_id}`,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"},{default:X(()=>[U(s(t(o)("gamification.leaderboard.details"))+" ",1),i[9]||(i[9]=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:"M9 5l7 7-7 7"})],-1))]),_:1},8,["to"])])],2))),128))])])]),e("div",xt,[e("div",mt,[e("button",{onClick:O,disabled:t(r)===0,class:f(["px-2.5 py-1.5 text-sm rounded-lg transition",t(r)===0?"text-slate-600 cursor-not-allowed":"text-slate-300 hover:bg-slate-700"])},[...i[10]||(i[10]=[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:"M11 19l-7-7 7-7m8 14l-7-7 7-7"})],-1)])],10,_t),e("button",{onClick:T,disabled:t(r)===0,class:f(["px-3 py-1.5 text-sm rounded-lg transition",t(r)===0?"text-slate-600 cursor-not-allowed":"text-slate-300 hover:bg-slate-700"])},s(t(o)("gamification.leaderboard.prev")),11,ft)]),e("div",bt,[e("span",gt,s(t(r)+1)+"–"+s(Math.min(t(r)+t(u),t(p)))+" / "+s(t(p)),1),g(e("select",{"onUpdate:modelValue":i[4]||(i[4]=a=>V(u)?u.value=a:null),onChange:D,class:"bg-slate-700 border border-slate-600 rounded-lg px-2 py-1.5 text-xs text-slate-300 focus:ring-2 focus:ring-indigo-500 focus:border-transparent"},[e("option",ht,"25 / "+s(t(o)("gamification.leaderboard.page")),1),e("option",vt,"50 / "+s(t(o)("gamification.leaderboard.page")),1),e("option",kt,"100 / "+s(t(o)("gamification.leaderboard.page")),1),e("option",wt,"250 / "+s(t(o)("gamification.leaderboard.page")),1)],544),[[M,t(u),void 0,{number:!0}]])]),e("div",yt,[e("button",{onClick:H,disabled:t(r)+t(u)>=t(p),class:f(["px-3 py-1.5 text-sm rounded-lg transition",t(r)+t(u)>=t(p)?"text-slate-600 cursor-not-allowed":"text-slate-300 hover:bg-slate-700"])},s(t(o)("gamification.leaderboard.next")),11,Ct),e("button",{onClick:I,disabled:t(r)+t(u)>=t(p),class:f(["px-2.5 py-1.5 text-sm rounded-lg transition",t(r)+t(u)>=t(p)?"text-slate-600 cursor-not-allowed":"text-slate-300 hover:bg-slate-700"])},[...i[11]||(i[11]=[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:"M13 5l7 7-7 7M5 5l7 7-7 7"})],-1)])],10,Mt)])])]))])}}});export{Ft as default};
|