Files
service-finder/frontend_admin/.nuxt/dist/client/_nuxt/DV_XBBqZ.js
2026-07-01 02:27:38 +00:00

2 lines
16 KiB
JavaScript

import{e as W,f as X,g as Y,c as d,a as e,t as l,i as a,F as L,d as D,r as Z,j as h,x,y as _,z as k,I as ee,l as p,J as te,h as ie,o as c,N as y,k as U,R as oe}from"./Duy9QquX.js";import{_ as se}from"./DlAUqK2U.js";const ne={class:"mb-8"},ae={class:"text-2xl font-bold text-white"},le={class:"text-slate-400 mt-1"},re={key:0,class:"flex items-center justify-center py-20"},de={class:"text-slate-400 flex items-center gap-3"},ce={key:1,class:"bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"},ue={class:"text-rose-400"},pe={class:"mb-6 flex justify-end"},me={class:"bg-slate-800 rounded-xl border border-slate-700 overflow-hidden"},fe={class:"w-full"},ve={class:"border-b border-slate-700"},xe={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},_e={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},ge={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},be={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},he={class:"text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},ke={class:"text-right px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider"},ye={class:"divide-y divide-slate-700/50"},we={class:"px-6 py-4 text-sm text-slate-400"},Ce={class:"px-6 py-4"},$e=["onKeyup","onBlur"],Be=["onClick"],je={class:"px-6 py-4"},Me=["onKeyup","onBlur"],Ve=["onClick"],Te={class:"px-6 py-4"},Re=["onKeyup","onBlur"],Ee=["onClick"],ze={class:"px-6 py-4"},He=["onClick"],Ue=["onClick"],Fe=["onClick"],Ie={class:"px-6 py-4 text-right"},Ke={class:"flex items-center justify-end gap-2"},Ne=["onClick","title"],De=["onClick","title"],Se={key:0},Ae={colspan:"6",class:"px-6 py-12 text-center text-sm text-slate-500"},Le={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-lg mx-4 shadow-2xl"},Pe={class:"text-lg font-semibold text-white mb-6"},qe={class:"block text-sm font-medium text-slate-300 mb-1"},Je=["placeholder"],Oe={class:"block text-sm font-medium text-slate-300 mb-1"},Ge={class:"block text-sm font-medium text-slate-300 mb-1"},Qe=["placeholder"],We={class:"flex items-center gap-3"},Xe={for:"is_active",class:"text-sm text-slate-300"},Ye={key:0,class:"bg-rose-500/10 border border-rose-500/30 rounded-lg p-3"},Ze={class:"text-sm text-rose-400"},et={class:"flex justify-end gap-3 pt-2"},tt=["disabled"],it={key:0,class:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},ot={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-md mx-4 shadow-2xl"},st={class:"text-lg font-semibold text-white mb-2"},nt={class:"text-sm text-slate-400 mb-6"},at={class:"flex justify-end gap-3"},lt=["disabled"],rt={key:5,class:"fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2 animate-slide-up"},dt=W({__name:"point-rules",setup(ct){const{t:i}=X(),F=p(!0),I=p(!1),K=p([]),M=p(!1),w=p(!1),g=p(null),C=p(null),m=p(!1),f=p(""),V=p(""),$=p(null),u=p(""),B=p(null),T=p(!1),r=te({action_key:"",points:0,description:"",is_active:!0});function j(){const t=ie("access_token").value;return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}function R(n){V.value=n,setTimeout(()=>{V.value=""},3e3)}function S(){r.action_key="",r.points=0,r.description="",r.is_active=!0,f.value=""}function P(){g.value=null,S(),M.value=!0}function q(n){g.value=n,r.action_key=n.action_key,r.points=n.points,r.description=n.description||"",r.is_active=n.is_active,f.value="",M.value=!0}function N(){M.value=!1,g.value=null,S()}function J(n){C.value=n,w.value=!0}async function E(){F.value=!0,I.value=!1;try{const n=await $fetch("/api/v1/admin/gamification/point-rules",{headers:j()});K.value=n}catch(n){console.error("Failed to fetch point rules:",n),I.value=!0}finally{F.value=!1}}async function O(){m.value=!0,f.value="";try{const n={action_key:r.action_key,points:r.points,description:r.description||null,is_active:r.is_active};g.value?(await $fetch(`/api/v1/admin/gamification/point-rules/${g.value.id}`,{method:"PUT",headers:j(),body:n}),R(i("gamification.point_rules.updated"))):(await $fetch("/api/v1/admin/gamification/point-rules",{method:"POST",headers:j(),body:n}),R(i("gamification.point_rules.created"))),N(),await E()}catch(n){n?.response?.status===409?f.value=i("gamification.point_rules.duplicate_key"):f.value=i("gamification.point_rules.save_error"),console.error("Failed to save point rule:",n)}finally{m.value=!1}}async function G(){if(C.value){m.value=!0;try{await $fetch(`/api/v1/admin/gamification/point-rules/${C.value.id}`,{method:"DELETE",headers:j()}),R(i("gamification.point_rules.deleted")),w.value=!1,C.value=null,await E()}catch(n){console.error("Failed to delete point rule:",n)}finally{m.value=!1}}}function z(n,t){return $.value?.id===n&&$.value?.field===t}async function H(n,t){T.value||($.value={id:n.id,field:t},t==="is_active"?u.value=n.is_active:t==="points"?u.value=n.points:t==="description"?u.value=n.description||"":u.value=n.action_key,await oe(),B.value&&B.value.focus())}function b(){$.value=null,u.value=""}async function v(n,t){if(!$.value||T.value)return;const o={};let s=u.value;if(t==="points"){if(s=Number(s),isNaN(s))return}else if(t==="is_active")s=!!s;else if(t==="description")s=s||null;else if(s=String(s).trim(),!s)return;const Q=n[t];if(s===Q){b();return}o[t]=s,T.value=!0;try{await $fetch(`/api/v1/admin/gamification/point-rules/${n.id}`,{method:"PUT",headers:j(),body:o}),n[t]=s,R(i("gamification.point_rules.updated")),b()}catch(A){console.error("Failed to save inline edit:",A),A?.response?.status===409&&(f.value=i("gamification.point_rules.duplicate_key"),setTimeout(()=>{f.value=""},3e3)),b()}finally{T.value=!1}}return Y(()=>{E()}),(n,t)=>(c(),d("div",null,[e("div",ne,[e("h1",ae,l(a(i)("gamification.point_rules.title")),1),e("p",le,l(a(i)("gamification.point_rules.subtitle")),1)]),F.value?(c(),d("div",re,[e("div",de,[t[16]||(t[16]=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,l(a(i)("gamification.point_rules.loading")),1)])])):I.value?(c(),d("div",ce,[e("p",ue,l(a(i)("gamification.point_rules.error")),1),e("button",{onClick:E,class:"mt-3 text-sm text-rose-300 hover:text-rose-200 underline"},l(a(i)("gamification.point_rules.retry")),1)])):(c(),d(L,{key:2},[e("div",pe,[e("button",{onClick:P,class:"px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white rounded-lg text-sm font-medium transition flex items-center gap-2"},[t[17]||(t[17]=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)),D(" "+l(a(i)("gamification.point_rules.create")),1)])]),e("div",me,[e("table",fe,[e("thead",null,[e("tr",ve,[e("th",xe,l(a(i)("gamification.point_rules.id")),1),e("th",_e,l(a(i)("gamification.point_rules.action_key")),1),e("th",ge,l(a(i)("gamification.point_rules.points")),1),e("th",be,l(a(i)("gamification.point_rules.description")),1),e("th",he,l(a(i)("gamification.point_rules.status")),1),e("th",ke,l(a(i)("gamification.point_rules.actions")),1)])]),e("tbody",ye,[(c(!0),d(L,null,Z(K.value,o=>(c(),d("tr",{key:o.id,class:"hover:bg-slate-700/30 transition"},[e("td",we,l(o.id),1),e("td",Ce,[z(o.id,"action_key")?_((c(),d("input",{key:0,ref_for:!0,ref_key:"inlineInputRef",ref:B,"onUpdate:modelValue":t[0]||(t[0]=s=>u.value=s),type:"text",maxlength:"100",class:"w-full px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50",onKeyup:[y(s=>v(o,"action_key"),["enter"]),t[1]||(t[1]=y(s=>b(),["escape"]))],onBlur:s=>v(o,"action_key"),onClick:t[2]||(t[2]=x(()=>{},["stop"]))},null,40,$e)),[[k,u.value]]):(c(),d("code",{key:1,class:"text-sm font-mono text-amber-300 bg-amber-500/10 px-2 py-0.5 rounded cursor-pointer hover:bg-amber-500/20 transition",onClick:s=>H(o,"action_key")},l(o.action_key),9,Be))]),e("td",je,[z(o.id,"points")?_((c(),d("input",{key:0,ref_for:!0,ref_key:"inlineInputRef",ref:B,"onUpdate:modelValue":t[3]||(t[3]=s=>u.value=s),type:"number",min:"-10000",max:"10000",class:"w-24 px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50",onKeyup:[y(s=>v(o,"points"),["enter"]),t[4]||(t[4]=y(s=>b(),["escape"]))],onBlur:s=>v(o,"points"),onClick:t[5]||(t[5]=x(()=>{},["stop"]))},null,40,Me)),[[k,u.value,void 0,{number:!0}]]):(c(),d("span",{key:1,class:U(["text-sm font-semibold cursor-pointer hover:opacity-80 transition",o.points>=0?"text-emerald-400":"text-rose-400"]),onClick:s=>H(o,"points")},l(o.points>=0?"+":"")+l(o.points),11,Ve))]),e("td",Te,[z(o.id,"description")?_((c(),d("input",{key:0,ref_for:!0,ref_key:"inlineInputRef",ref:B,"onUpdate:modelValue":t[6]||(t[6]=s=>u.value=s),type:"text",class:"w-full px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50",onKeyup:[y(s=>v(o,"description"),["enter"]),t[7]||(t[7]=y(s=>b(),["escape"]))],onBlur:s=>v(o,"description"),onClick:t[8]||(t[8]=x(()=>{},["stop"]))},null,40,Re)),[[k,u.value]]):(c(),d("span",{key:1,class:"text-sm text-slate-300 max-w-xs truncate block cursor-pointer hover:text-white transition",onClick:s=>H(o,"description")},l(o.description||"—"),9,Ee))]),e("td",ze,[z(o.id,"is_active")?(c(),d("div",{key:0,class:"flex items-center gap-2",onClick:t[9]||(t[9]=x(()=>{},["stop"]))},[e("button",{onClick:s=>{u.value=!0,v(o,"is_active")},class:U(["px-2 py-1 text-xs font-medium rounded transition",u.value?"bg-emerald-500/20 text-emerald-400 ring-1 ring-emerald-500/50":"bg-slate-700 text-slate-400 hover:bg-slate-600"])},l(a(i)("gamification.point_rules.active")),11,He),e("button",{onClick:s=>{u.value=!1,v(o,"is_active")},class:U(["px-2 py-1 text-xs font-medium rounded transition",u.value?"bg-slate-700 text-slate-400 hover:bg-slate-600":"bg-rose-500/20 text-rose-400 ring-1 ring-rose-500/50"])},l(a(i)("gamification.point_rules.inactive")),11,Ue)])):(c(),d("span",{key:1,class:U(["inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:ring-2 hover:ring-amber-500/50 transition",o.is_active?"bg-emerald-500/10 text-emerald-400":"bg-slate-500/10 text-slate-400"]),onClick:s=>H(o,"is_active")},l(o.is_active?a(i)("gamification.point_rules.active"):a(i)("gamification.point_rules.inactive")),11,Fe))]),e("td",Ie,[e("div",Ke,[e("button",{onClick:s=>q(o),class:"p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition",title:a(i)("gamification.point_rules.edit")},[...t[18]||(t[18]=[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 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)])],8,Ne),e("button",{onClick:s=>J(o),class:"p-1.5 rounded-lg text-slate-400 hover:text-rose-400 hover:bg-rose-500/10 transition",title:a(i)("gamification.point_rules.delete_title")},[...t[19]||(t[19]=[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:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,De)])])]))),128)),K.value.length===0?(c(),d("tr",Se,[e("td",Ae,l(a(i)("gamification.point_rules.no_items")),1)])):h("",!0)])])])],64)),M.value?(c(),d("div",{key:3,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:x(N,["self"])},[e("div",Le,[e("h2",Pe,l(g.value?a(i)("gamification.point_rules.edit_title"):a(i)("gamification.point_rules.create_title")),1),e("form",{onSubmit:x(O,["prevent"]),class:"space-y-4"},[e("div",null,[e("label",qe,l(a(i)("gamification.point_rules.action_key_label")),1),_(e("input",{"onUpdate:modelValue":t[10]||(t[10]=o=>r.action_key=o),type:"text",required:"",maxlength:"100",placeholder:a(i)("gamification.point_rules.action_key_placeholder"),class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm"},null,8,Je),[[k,r.action_key]])]),e("div",null,[e("label",Oe,l(a(i)("gamification.point_rules.points_label")),1),_(e("input",{"onUpdate:modelValue":t[11]||(t[11]=o=>r.points=o),type:"number",required:"",min:"-10000",max:"10000",placeholder:"0",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm"},null,512),[[k,r.points,void 0,{number:!0}]])]),e("div",null,[e("label",Ge,l(a(i)("gamification.point_rules.description_label")),1),_(e("textarea",{"onUpdate:modelValue":t[12]||(t[12]=o=>r.description=o),rows:"3",placeholder:a(i)("gamification.point_rules.description_placeholder"),class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm resize-none"},null,8,Qe),[[k,r.description]])]),e("div",We,[_(e("input",{"onUpdate:modelValue":t[13]||(t[13]=o=>r.is_active=o),type:"checkbox",id:"is_active",class:"w-4 h-4 rounded bg-slate-700 border-slate-600 text-amber-500 focus:ring-amber-500/50"},null,512),[[ee,r.is_active]]),e("label",Xe,l(a(i)("gamification.point_rules.is_active")),1)]),f.value?(c(),d("div",Ye,[e("p",Ze,l(f.value),1)])):h("",!0),e("div",et,[e("button",{type:"button",onClick:N,class:"px-4 py-2 text-sm text-slate-400 hover:text-white transition"},l(a(i)("gamification.point_rules.cancel")),1),e("button",{type:"submit",disabled:m.value,class:"px-4 py-2 bg-amber-600 hover:bg-amber-500 disabled:bg-amber-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2"},[m.value?(c(),d("svg",it,[...t[20]||(t[20]=[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)])])):h("",!0),D(" "+l(m.value?a(i)("gamification.point_rules.saving"):a(i)("gamification.point_rules.save")),1)],8,tt)])],32)])])):h("",!0),w.value?(c(),d("div",{key:4,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t[15]||(t[15]=x(o=>w.value=!1,["self"]))},[e("div",ot,[e("h2",st,l(a(i)("gamification.point_rules.delete_title")),1),e("p",nt,l(a(i)("gamification.point_rules.delete_confirm",{name:C.value?.action_key})),1),e("div",at,[e("button",{onClick:t[14]||(t[14]=o=>w.value=!1),class:"px-4 py-2 text-sm text-slate-400 hover:text-white transition"},l(a(i)("gamification.point_rules.cancel")),1),e("button",{onClick:G,disabled:m.value,class:"px-4 py-2 bg-rose-600 hover:bg-rose-500 disabled:bg-rose-600/50 text-white rounded-lg text-sm font-medium transition"},l(m.value?a(i)("gamification.point_rules.deleting"):a(i)("gamification.point_rules.delete")),9,lt)])])])):h("",!0),V.value?(c(),d("div",rt,[t[21]||(t[21]=e("svg",{class:"w-4 h-4 flex-shrink-0",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)),D(" "+l(V.value),1)])):h("",!0)]))}}),mt=se(dt,[["__scopeId","data-v-f21993c6"]]);export{mt as default};