2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{e as q,f as E,q as I,Q as O,g as Q,c as n,a as e,d as f,t as s,i as t,P as G,F as z,k as b,y as h,z as v,j as m,r as J,l as u,h as K,m as W,o as d}from"./BIbQr1Hg.js";import{u as X}from"./XheHpngv.js";import"./DXATb271.js";const Y={class:"mb-8"},Z={class:"text-2xl font-bold text-white"},ee={class:"text-slate-400 mt-1"},te={key:0,class:"flex items-center justify-center py-20"},se={class:"text-slate-400 flex items-center gap-3"},ae={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},oe={class:"text-rose-400"},ie={key:2,class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},le={class:"text-slate-400 text-center py-12"},re={class:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-8"},ne={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},de={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},ce={class:"text-2xl font-bold text-white"},ue={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},_e={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},me={class:"text-2xl font-bold text-indigo-400"},pe={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},xe={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},ge={class:"text-2xl font-bold text-emerald-400"},fe={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},be={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},he={class:"text-2xl font-bold text-cyan-400"},ve={class:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-8"},we={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},ke={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},ye={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},Ce={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},$e={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},je={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},Be={class:"text-2xl font-bold text-slate-300"},He={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},Me={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},Se={class:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-8"},Ve={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},ze={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},Fe={class:"text-2xl font-bold text-white"},Le={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},Ae={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},De={class:"text-2xl font-bold text-white"},Ne={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},Pe={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},Te={class:"text-2xl font-bold text-white"},Ue={class:"bg-slate-800 rounded-xl border border-slate-700 p-5"},Re={class:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-1"},qe={class:"text-2xl font-bold text-white"},Ee={class:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8"},Ie={class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},Oe={class:"text-lg font-semibold text-white mb-4 flex items-center gap-2"},Qe={class:"space-y-4"},Ge={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},Je={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},Ke=["placeholder"],We=["disabled"],Xe={key:0,class:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ye={key:0,class:"text-xs text-rose-400"},Ze={key:1,class:"text-xs text-emerald-400"},et={class:"bg-slate-800 rounded-xl border border-slate-700 p-6"},tt={class:"text-lg font-semibold text-white mb-4 flex items-center gap-2"},st={class:"space-y-4"},at={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},ot={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},it={class:"block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider"},lt=["placeholder"],rt=["disabled"],nt={key:0,class:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},dt={key:0,class:"text-xs text-rose-400"},ct={key:1,class:"text-xs text-emerald-400"},ut={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-8"},_t={class:"flex items-center justify-between mb-4"},mt={class:"text-lg font-semibold text-white"},pt={class:"text-xs text-slate-500"},xt={key:0,class:"flex items-center justify-center py-8"},gt={class:"text-slate-400 flex items-center gap-2"},ft={key:1,class:"text-sm text-slate-500 text-center py-8"},bt={key:2,class:"overflow-x-auto"},ht={class:"w-full"},vt={class:"border-b border-slate-700"},wt={class:"text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider"},kt={class:"text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider"},yt={class:"text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider"},Ct={class:"text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider"},$t={class:"text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider"},jt={class:"text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider"},Bt={class:"divide-y divide-slate-700/50"},Ht={class:"px-3 py-2.5 text-xs text-slate-400 whitespace-nowrap"},Mt={class:"px-3 py-2.5 text-sm text-slate-300"},St={class:"px-3 py-2.5 text-sm text-slate-300 max-w-xs truncate"},Vt={class:"px-3 py-2.5 text-xs text-slate-500"},zt={key:0,class:"inline-flex items-center px-2 py-0.5 rounded text-xs bg-slate-700 text-slate-400"},Ft={key:1},Pt=q({__name:"[id]",setup(Lt){const{t:a}=E(),{formatNumber:H,formatDate:F,formatDateTime:L}=X(),A=I(),D=O(),w=W(()=>Number(D.params.id)),M=u(!0),S=u(!1),r=u(null),p=u([]),V=u(!1),_=u({amount:0,reason:""}),x=u(!1),k=u(""),y=u(""),c=u({xp_amount:0,social_amount:0,reason:""}),g=u(!1),C=u(""),$=u("");function N(i){switch(i){case 1:return a("gamification.user_detail.restriction_mild");case 2:return a("gamification.user_detail.restriction_moderate");case 3:return a("gamification.user_detail.restriction_severe");default:return`${i}. ${a("gamification.user_detail.restriction_level")}`}}function P(){A.push("/gamification/users")}function j(){const o=K("access_token").value;return o?{Authorization:`Bearer ${o}`}:{}}async function B(){M.value=!0,S.value=!1;try{const i=j(),o=await $fetch(`/api/v1/admin/gamification/user-stats/${w.value}`,{headers:i});r.value=o,await T()}catch(i){console.error("Failed to load user stats:",i),S.value=!0}finally{M.value=!1}}async function T(){V.value=!0;try{const i=j(),o=await $fetch(`/api/v1/admin/gamification/points-ledger?user_id=${w.value}&limit=50`,{headers:i});p.value=o}catch(i){console.error("Failed to load ledger:",i),p.value=[]}finally{V.value=!1}}async function U(){if(!(!_.value.amount||!_.value.reason)){x.value=!0,k.value="",y.value="";try{const i=j();await $fetch(`/api/v1/admin/gamification/user-stats/${w.value}/penalty`,{method:"POST",headers:i,body:{amount:_.value.amount,reason:_.value.reason}}),y.value=a("gamification.user_detail.penalty_success",{amount:_.value.amount}),_.value={amount:0,reason:""},await B()}catch(i){k.value=i?.data?.detail||i?.message||a("gamification.user_detail.penalty_error")}finally{x.value=!1}}}async function R(){if(!(!c.value.xp_amount||!c.value.reason)){g.value=!0,C.value="",$.value="";try{const i=j();await $fetch(`/api/v1/admin/gamification/user-stats/${w.value}/reward`,{method:"POST",headers:i,body:{xp_amount:c.value.xp_amount,social_amount:c.value.social_amount||0,reason:c.value.reason}}),$.value=a("gamification.user_detail.reward_success",{xp:c.value.xp_amount,social:c.value.social_amount||0}),c.value={xp_amount:0,social_amount:0,reason:""},await B()}catch(i){C.value=i?.data?.detail||i?.message||a("gamification.user_detail.reward_error")}finally{g.value=!1}}}return Q(()=>{B()}),(i,o)=>(d(),n("div",null,[e("div",Y,[e("button",{onClick:P,class:"inline-flex items-center gap-1.5 text-sm text-slate-400 hover:text-white transition mb-4"},[o[5]||(o[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:"M15 19l-7-7 7-7"})],-1)),f(" "+s(t(a)("gamification.user_detail.back")),1)]),e("h1",Z,s(t(a)("gamification.user_detail.title")),1),e("p",ee,s(t(a)("gamification.user_detail.user_id"))+" #"+s((i._.provides[G]||i.$route).params.id),1)]),t(M)?(d(),n("div",te,[e("div",se,[o[6]||(o[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(a)("gamification.user_detail.loading")),1)])])):t(S)?(d(),n("div",ae,[e("p",oe,s(t(a)("gamification.user_detail.load_error")),1),e("button",{onClick:B,class:"mt-3 text-sm text-rose-300 hover:text-rose-200 underline"},s(t(a)("gamification.user_detail.retry")),1)])):t(r)?(d(),n(z,{key:3},[e("div",re,[e("div",ne,[e("h3",de,s(t(a)("gamification.user_detail.stat_total_xp")),1),e("p",ce,s(t(H)(t(r).total_xp)),1)]),e("div",ue,[e("h3",_e,s(t(a)("gamification.user_detail.stat_level")),1),e("p",me,s(t(r).current_level),1)]),e("div",pe,[e("h3",xe,s(t(a)("gamification.user_detail.stat_total_points")),1),e("p",ge,s(t(H)(t(r).total_points)),1)]),e("div",fe,[e("h3",be,s(t(a)("gamification.user_detail.stat_social_points")),1),e("p",he,s(t(H)(t(r).social_points)),1)])]),e("div",ve,[e("div",we,[e("h3",ke,s(t(a)("gamification.user_detail.stat_penalty_points")),1),e("p",{class:b(["text-2xl font-bold",t(r).penalty_points>0?"text-rose-400":"text-slate-400"])},s(t(r).penalty_points>0?`-${t(r).penalty_points}`:"0"),3)]),e("div",ye,[e("h3",Ce,s(t(a)("gamification.user_detail.stat_restriction")),1),e("p",{class:b(["text-2xl font-bold",t(r).restriction_level>0?"text-amber-400":"text-slate-400"])},s(t(r).restriction_level>0?N(t(r).restriction_level):t(a)("gamification.user_detail.none")),3)]),e("div",$e,[e("h3",je,s(t(a)("gamification.user_detail.stat_penalty_quota")),1),e("p",Be,s(t(r).penalty_quota_remaining),1)]),e("div",He,[e("h3",Me,s(t(a)("gamification.user_detail.stat_banned")),1),e("p",{class:b(["text-2xl font-bold",t(r).banned_until?"text-rose-400":"text-slate-400"])},s(t(r).banned_until?t(F)(t(r).banned_until):t(a)("gamification.user_detail.no")),3)])]),e("div",Se,[e("div",Ve,[e("h3",ze,s(t(a)("gamification.user_detail.stat_services")),1),e("p",Fe,s(t(r).services_submitted),1)]),e("div",Le,[e("h3",Ae,s(t(a)("gamification.user_detail.stat_discovered")),1),e("p",De,s(t(r).places_discovered),1)]),e("div",Ne,[e("h3",Pe,s(t(a)("gamification.user_detail.stat_validated")),1),e("p",Te,s(t(r).places_validated),1)]),e("div",Ue,[e("h3",Re,s(t(a)("gamification.user_detail.stat_providers")),1),e("p",qe,s(t(r).providers_added_count),1)])]),e("div",Ee,[e("div",Ie,[e("h2",Oe,[o[7]||(o[7]=e("svg",{class:"w-5 h-5 text-rose-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),f(" "+s(t(a)("gamification.user_detail.penalty_title")),1)]),e("div",Qe,[e("div",null,[e("label",Ge,s(t(a)("gamification.user_detail.penalty_points_label")),1),h(e("input",{"onUpdate:modelValue":o[0]||(o[0]=l=>t(_).amount=l),type:"number",min:"1",max:"10000",placeholder:"1–10000",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-rose-500 focus:border-transparent"},null,512),[[v,t(_).amount,void 0,{number:!0}]])]),e("div",null,[e("label",Je,s(t(a)("gamification.user_detail.penalty_reason_label")),1),h(e("textarea",{"onUpdate:modelValue":o[1]||(o[1]=l=>t(_).reason=l),rows:"2",placeholder:t(a)("gamification.user_detail.penalty_reason_placeholder"),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-rose-500 focus:border-transparent resize-none"},null,8,Ke),[[v,t(_).reason]])]),e("button",{onClick:U,disabled:t(x)||!t(_).amount||!t(_).reason,class:"w-full px-4 py-2.5 bg-rose-600 hover:bg-rose-500 disabled:bg-rose-600/50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition flex items-center justify-center gap-2"},[t(x)?(d(),n("svg",Xe,[...o[8]||(o[8]=[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"},null,-1)])])):m("",!0),f(" "+s(t(x)?t(a)("gamification.user_detail.penalty_submitting"):t(a)("gamification.user_detail.penalty_submit")),1)],8,We),t(k)?(d(),n("p",Ye,s(t(k)),1)):m("",!0),t(y)?(d(),n("p",Ze,s(t(y)),1)):m("",!0)])]),e("div",et,[e("h2",tt,[o[9]||(o[9]=e("svg",{class:"w-5 h-5 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("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)),f(" "+s(t(a)("gamification.user_detail.reward_title")),1)]),e("div",st,[e("div",null,[e("label",at,s(t(a)("gamification.user_detail.reward_xp_label")),1),h(e("input",{"onUpdate:modelValue":o[2]||(o[2]=l=>t(c).xp_amount=l),type:"number",min:"0",max:"100000",placeholder:"0–100000",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-emerald-500 focus:border-transparent"},null,512),[[v,t(c).xp_amount,void 0,{number:!0}]])]),e("div",null,[e("label",ot,s(t(a)("gamification.user_detail.reward_social_label")),1),h(e("input",{"onUpdate:modelValue":o[3]||(o[3]=l=>t(c).social_amount=l),type:"number",min:"0",max:"100000",placeholder:"0–100000",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-emerald-500 focus:border-transparent"},null,512),[[v,t(c).social_amount,void 0,{number:!0}]])]),e("div",null,[e("label",it,s(t(a)("gamification.user_detail.reward_reason_label")),1),h(e("textarea",{"onUpdate:modelValue":o[4]||(o[4]=l=>t(c).reason=l),rows:"2",placeholder:t(a)("gamification.user_detail.reward_reason_placeholder"),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-emerald-500 focus:border-transparent resize-none"},null,8,lt),[[v,t(c).reason]])]),e("button",{onClick:R,disabled:t(g)||!t(c).xp_amount||!t(c).reason,class:"w-full px-4 py-2.5 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition flex items-center justify-center gap-2"},[t(g)?(d(),n("svg",nt,[...o[10]||(o[10]=[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"},null,-1)])])):m("",!0),f(" "+s(t(g)?t(a)("gamification.user_detail.reward_submitting"):t(a)("gamification.user_detail.reward_submit")),1)],8,rt),t(C)?(d(),n("p",dt,s(t(C)),1)):m("",!0),t($)?(d(),n("p",ct,s(t($)),1)):m("",!0)])])]),e("div",ut,[e("div",_t,[e("h2",mt,s(t(a)("gamification.user_detail.ledger_title")),1),e("span",pt,s(t(a)("gamification.user_detail.ledger_count",{count:t(p).length})),1)]),t(V)?(d(),n("div",xt,[e("div",gt,[o[11]||(o[11]=e("svg",{class:"w-4 h-4 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(a)("gamification.user_detail.ledger_loading")),1)])])):t(p).length===0?(d(),n("div",ft,s(t(a)("gamification.user_detail.ledger_empty")),1)):(d(),n("div",bt,[e("table",ht,[e("thead",null,[e("tr",vt,[e("th",wt,s(t(a)("gamification.user_detail.ledger_col_date")),1),e("th",kt,s(t(a)("gamification.user_detail.ledger_col_points")),1),e("th",yt,s(t(a)("gamification.user_detail.ledger_col_penalty")),1),e("th",Ct,s(t(a)("gamification.user_detail.ledger_col_xp")),1),e("th",$t,s(t(a)("gamification.user_detail.ledger_col_reason")),1),e("th",jt,s(t(a)("gamification.user_detail.ledger_col_source")),1)])]),e("tbody",Bt,[(d(!0),n(z,null,J(t(p),l=>(d(),n("tr",{key:l.id,class:"hover:bg-slate-700/30 transition"},[e("td",Ht,s(t(L)(l.created_at)),1),e("td",{class:b(["px-3 py-2.5 text-sm font-medium",l.points>=0?"text-emerald-400":"text-rose-400"])},s(l.points>=0?"+":"")+s(l.points),3),e("td",{class:b(["px-3 py-2.5 text-sm",l.penalty_change?"text-rose-400":"text-slate-500"])},s(l.penalty_change?`-${l.penalty_change}`:"—"),3),e("td",Mt,s(l.xp??"—"),1),e("td",St,s(l.reason),1),e("td",Vt,[l.source_type?(d(),n("span",zt,s(l.source_type)+s(l.source_id?` #${l.source_id}`:""),1)):(d(),n("span",Ft,"—"))])]))),128))])])]))])],64)):(d(),n("div",ie,[e("p",le,s(t(a)("gamification.user_detail.not_found")),1)]))]))}});export{Pt as default};
|