2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{e as Y,q as Z,c as l,a as e,t as o,F as L,k as C,v as F,s as H,r as T,i as b,j as ee,d as z,n as p,m as n,x as $,y as te,z as se,o as i,A as oe}from"./CHWHIiGB.js";const ae={class:"mb-8"},le={class:"text-2xl font-bold text-white"},ie={class:"text-slate-400 mt-1"},ne={key:0,class:"flex items-center justify-center py-20"},re={class:"flex flex-col items-center gap-3"},de={class:"text-slate-400 text-sm"},ce={key:1,class:"flex flex-col items-center justify-center py-20 text-center"},ue={class:"text-red-400 text-sm mb-2"},pe={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8"},ge={class:"bg-slate-800 rounded-xl border border-slate-700 p-4"},me={class:"flex items-center gap-3"},ve={class:"text-xs text-slate-400 uppercase tracking-wider"},xe={class:"text-2xl font-bold text-white"},fe={class:"bg-slate-800 rounded-xl border border-slate-700 p-4"},he={class:"flex items-center gap-3"},be={class:"text-xs text-slate-400 uppercase tracking-wider"},_e={class:"text-2xl font-bold text-emerald-400"},ye={class:"bg-slate-800 rounded-xl border border-slate-700 p-4"},ke={class:"flex items-center gap-3"},we={class:"text-xs text-slate-400 uppercase tracking-wider"},Ce={class:"text-2xl font-bold text-amber-400"},$e={class:"bg-slate-800 rounded-xl border border-slate-700 p-4"},Me={class:"flex items-center gap-3"},je={class:"text-xs text-slate-400 uppercase tracking-wider"},Be={class:"text-2xl font-bold text-purple-400"},Le={class:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6"},ze={class:"relative flex-1 max-w-md"},Se=["placeholder"],Ve={class:"flex items-center gap-2"},Ae={value:"all"},De={class:"bg-slate-800/50 border border-slate-700 rounded-xl overflow-hidden"},Fe={class:"overflow-x-auto"},He={class:"w-full text-sm"},Te={class:"border-b border-slate-700 bg-slate-800/80"},Ne={class:"text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400"},Ie={class:"text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400"},Ge={class:"text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400"},Ue={class:"text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400"},Ee={class:"text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400"},Pe={class:"py-3.5 px-4 text-slate-400 font-mono text-xs"},qe={class:"py-3.5 px-4"},Oe={class:"flex items-center gap-3"},Qe={class:"text-sm font-medium text-white"},Je={class:"text-xs text-slate-500"},Ke={class:"py-3.5 px-4"},Re={class:"py-3.5 px-4"},We={class:"py-3.5 px-4"},Xe={key:0,class:"text-slate-300 text-xs"},Ye={key:1,class:"text-slate-500 text-xs italic"},Ze={class:"py-3.5 px-4"},et={class:"flex items-center gap-2"},tt=["onClick","title"],st=["onClick"],ot=["onClick"],at={key:0,class:"flex flex-col items-center justify-center py-16 text-center"},lt={class:"text-slate-400 text-sm"},it={class:"bg-slate-800 border border-slate-700 rounded-2xl shadow-2xl w-full max-w-lg mx-4 overflow-hidden"},nt={class:"px-6 py-4 border-b border-slate-700 flex items-center justify-between"},rt={class:"text-lg font-semibold text-white"},dt={class:"text-sm text-slate-400 mt-0.5"},ct={class:"px-6 py-5 space-y-5"},ut={class:"bg-slate-900/50 rounded-xl p-4 border border-slate-700/50"},pt={class:"text-xs text-slate-500 uppercase tracking-wider mb-1"},gt={class:"text-sm font-medium text-white"},mt={key:0,class:"text-xs text-slate-400 mt-1"},vt={class:"block text-sm font-medium text-slate-300 mb-2"},xt={value:"",disabled:""},ft=["value"],ht={class:"block text-sm font-medium text-slate-300 mb-2"},bt={class:"text-xs text-slate-500 ml-1"},_t={class:"text-xs text-slate-500 mt-1.5"},yt={key:0,class:"bg-red-500/10 border border-red-500/20 rounded-lg px-4 py-3"},kt={class:"text-sm text-red-400"},wt={class:"px-6 py-4 border-t border-slate-700 flex items-center justify-end gap-3"},Ct=["disabled"],$t={key:0,class:"flex items-center gap-2"},Mt={key:1},Lt=Y({__name:"index",setup(jt){const _=n(!0),y=n(null),g=n([]),S=n([]),k=n(""),m=n("all"),M=n(!1),r=n(null),d=n(""),v=n(""),f=n(!1),x=n(null),h=n(null),N=$(()=>g.value.filter(t=>t.is_active).length),I=$(()=>g.value.filter(t=>{const s=t.subscription_tier_name.toLowerCase();return s.includes("premium")||s.includes("pro")}).length),G=$(()=>g.value.filter(t=>{const s=t.subscription_tier_name.toLowerCase();return s.includes("enterprise")||s.includes("vip")||s.includes("corp")}).length),V=$(()=>g.value.filter(t=>{if(k.value){const s=k.value.toLowerCase();if(!(c(t).toLowerCase().includes(s)||t.full_name.toLowerCase().includes(s)||t.name.toLowerCase().includes(s)||t.city&&t.city.toLowerCase().includes(s)))return!1}if(m.value!=="all"){const s=t.subscription_tier_name.toLowerCase();if(m.value==="free"&&!s.includes("free")&&!s.includes("fallback")||m.value==="premium"&&!s.includes("premium")&&!s.includes("pro")||m.value==="enterprise"&&!s.includes("enterprise")&&!s.includes("vip")&&!s.includes("corp"))return!1}return!0}));function j(){const s=se("access_token").value;return s?{Authorization:`Bearer ${s}`}:{}}async function B(){_.value=!0,y.value=null;try{const t=await $fetch("/api/v1/admin/organizations",{params:{limit:200},headers:j()});g.value=t.garages}catch(t){console.error("[Garages] Failed to fetch garages:",t),y.value=t?.data?.detail||t?.message||"Failed to load garages"}finally{_.value=!1}}async function U(){try{const t=await $fetch("/api/v1/admin/packages",{params:{include_hidden:!0,limit:100},headers:j()});S.value=t.tiers}catch(t){console.error("[Garages] Failed to fetch tiers:",t)}}function E(t){r.value=t,d.value=t.subscription?.tier_id||"",v.value="",x.value=null,M.value=!0}function w(){M.value=!1,r.value=null,d.value="",v.value="",x.value=null}async function P(){if(!(!r.value||!d.value)){f.value=!0,x.value=null;try{const t={tier_id:d.value};v.value&&(t.expires_at=new Date(v.value).toISOString()),await $fetch(`/api/v1/admin/organizations/${r.value.id}/subscription`,{method:"PATCH",headers:{...j(),"Content-Type":"application/json"},body:t}),D("success",`"${c(r.value)}" ${te().$i18n.t("garages.subscription_updated")}`),w(),await B()}catch(t){console.error("[Garages] Failed to save subscription:",t),x.value=t?.data?.detail||t?.message||"Failed to save subscription"}finally{f.value=!1}}}async function q(t){D("error",`Status toggle for "${c(t)}" not yet implemented via API`)}function c(t){return t.display_name||t.name||t.full_name}function O(t){oe(`/garages/${t.id}`)}function Q(t){return t.split(" ").map(s=>s.charAt(0)).join("").toUpperCase().slice(0,2)}function J(t){const s=["bg-amber-600","bg-purple-600","bg-slate-600","bg-indigo-600","bg-emerald-600","bg-rose-600","bg-cyan-600","bg-orange-600","bg-teal-600"];let a=0;for(let u=0;u<t.length;u++)a=t.charCodeAt(u)+((a<<5)-a);return s[Math.abs(a)%s.length]}function K(t){return t==="active"?"bg-emerald-500/10 text-emerald-400":t==="suspended"?"bg-red-500/10 text-red-400":t==="pending_verification"?"bg-amber-500/10 text-amber-400":"bg-slate-500/10 text-slate-400"}function R(t){return t==="active"?"bg-emerald-400":t==="suspended"?"bg-red-400":t==="pending_verification"?"bg-amber-400":"bg-slate-400"}function W(t){return t==="active"?"Aktív":t==="suspended"?"Felfüggesztve":t==="pending_verification"?"Függőben":"Inaktív"}function X(t){const s=t.toLowerCase();return s.includes("enterprise")||s.includes("vip")||s.includes("corp")?"bg-purple-500/20 text-purple-300":s.includes("premium")||s.includes("pro")?"bg-amber-500/20 text-amber-300":"bg-slate-500/20 text-slate-300"}function A(t){try{return new Date(t).toLocaleDateString("hu-HU",{year:"numeric",month:"short",day:"numeric"})}catch{return t}}function D(t,s){h.value={type:t,message:s},setTimeout(()=>{h.value=null},4e3)}return Z(()=>{B(),U()}),(t,s)=>(i(),l("div",null,[e("div",ae,[e("h1",le,o(t.$t("garages.title")),1),e("p",ie,o(t.$t("garages.subtitle")),1)]),_.value?(i(),l("div",ne,[e("div",re,[s[4]||(s[4]=e("svg",{class:"w-8 h-8 text-indigo-400 animate-spin",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1)),e("p",de,o(t.$t("garages.loading")),1)])])):y.value?(i(),l("div",ce,[s[5]||(s[5]=e("svg",{class:"w-12 h-12 text-red-500 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",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)),e("p",ue,o(y.value),1),e("button",{onClick:B,class:"px-4 py-2 text-sm bg-indigo-600/20 text-indigo-300 hover:bg-indigo-600/30 rounded-lg transition"},o(t.$t("garages.retry")),1)])):(i(),l(L,{key:2},[e("div",pe,[e("div",ge,[e("div",me,[s[6]||(s[6]=e("div",{class:"p-2 rounded-lg bg-indigo-500/10 text-indigo-400"},[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})])],-1)),e("div",null,[e("p",ve,o(t.$t("garages.total_garages")),1),e("p",xe,o(g.value.length),1)])])]),e("div",fe,[e("div",he,[s[7]||(s[7]=e("div",{class:"p-2 rounded-lg bg-emerald-500/10 text-emerald-400"},[e("svg",{class:"w-5 h-5",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)),e("div",null,[e("p",be,o(t.$t("garages.active_garages")),1),e("p",_e,o(N.value),1)])])]),e("div",ye,[e("div",ke,[s[8]||(s[8]=e("div",{class:"p-2 rounded-lg bg-amber-500/10 text-amber-400"},[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})])],-1)),e("div",null,[e("p",we,o(t.$t("garages.premium_garages")),1),e("p",Ce,o(I.value),1)])])]),e("div",$e,[e("div",Me,[s[9]||(s[9]=e("div",{class:"p-2 rounded-lg bg-purple-500/10 text-purple-400"},[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})])],-1)),e("div",null,[e("p",je,o(t.$t("garages.enterprise_garages")),1),e("p",Be,o(G.value),1)])])])]),e("div",Le,[e("div",ze,[s[10]||(s[10]=e("svg",{class:"absolute left-3 top-1/2 -translate-y-1/2 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)),C(e("input",{"onUpdate:modelValue":s[0]||(s[0]=a=>k.value=a),type:"text",placeholder:t.$t("garages.search_placeholder"),class:"w-full pl-10 pr-4 py-2.5 bg-slate-800 border border-slate-700 rounded-lg text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 transition"},null,8,Se),[[F,k.value]])]),e("div",Ve,[C(e("select",{"onUpdate:modelValue":s[1]||(s[1]=a=>m.value=a),class:"px-3 py-2.5 bg-slate-800 border border-slate-700 rounded-lg text-sm text-slate-300 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 transition"},[e("option",Ae,o(t.$t("garages.all_tiers")),1),s[11]||(s[11]=e("option",{value:"free"},"Free",-1)),s[12]||(s[12]=e("option",{value:"premium"},"Premium",-1)),s[13]||(s[13]=e("option",{value:"enterprise"},"Enterprise",-1))],512),[[H,m.value]])])]),e("div",De,[e("div",Fe,[e("table",He,[e("thead",null,[e("tr",Te,[s[14]||(s[14]=e("th",{class:"text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400"},"ID",-1)),e("th",Ne,o(t.$t("garages.company_name")),1),e("th",Ie,o(t.$t("garages.status")),1),e("th",Ge,o(t.$t("garages.current_package")),1),e("th",Ue,o(t.$t("garages.expiration_date")),1),e("th",Ee,o(t.$t("garages.actions")),1)])]),e("tbody",null,[(i(!0),l(L,null,T(V.value,a=>(i(),l("tr",{key:a.id,class:"border-b border-slate-700/50 hover:bg-slate-700/30 transition"},[e("td",Pe,o(a.id),1),e("td",qe,[e("div",Oe,[e("div",{class:p(["w-8 h-8 rounded-lg flex items-center justify-center text-sm font-bold text-white",J(c(a))])},o(Q(c(a))),3),e("div",null,[e("p",Qe,o(c(a)),1),e("p",Je,o(a.city||"—")+" · "+o(a.member_count)+" "+o(t.$t("garages.members")),1)])])]),e("td",Ke,[e("span",{class:p(["inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",K(a.status)])},[e("span",{class:p(["w-1.5 h-1.5 rounded-full mr-1.5",R(a.status)])},null,2),z(" "+o(W(a.status)),1)],2)]),e("td",Re,[e("span",{class:p(["px-2.5 py-0.5 rounded-full text-xs font-medium",X(a.subscription_tier_name)])},o(a.subscription_tier_name),3)]),e("td",We,[a.subscription_expires_at?(i(),l("span",Xe,o(A(a.subscription_expires_at)),1)):(i(),l("span",Ye,o(t.$t("garages.indefinite")),1))]),e("td",Ze,[e("div",et,[e("button",{onClick:u=>O(a),class:"px-3 py-1.5 text-xs font-medium bg-slate-600/20 text-slate-300 hover:bg-slate-600/30 rounded-lg transition",title:t.$t("garages.view_details")},o(t.$t("garages.view_details")),9,tt),e("button",{onClick:u=>E(a),class:"px-3 py-1.5 text-xs font-medium bg-indigo-600/20 text-indigo-300 hover:bg-indigo-600/30 rounded-lg transition"},o(t.$t("garages.manage_subscription")),9,st),e("button",{onClick:u=>q(a),class:p(["px-3 py-1.5 text-xs font-medium rounded-lg transition",a.is_active?"bg-red-500/10 text-red-300 hover:bg-red-500/20":"bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20"])},o(a.is_active?t.$t("garages.deactivate"):t.$t("garages.activate")),11,ot)])])]))),128))])])]),V.value.length===0&&!_.value?(i(),l("div",at,[s[15]||(s[15]=e("svg",{class:"w-12 h-12 text-slate-600 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})],-1)),e("p",lt,o(t.$t("garages.no_results")),1)])):b("",!0)])],64)),M.value?(i(),l("div",{key:3,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:ee(w,["self"])},[e("div",it,[e("div",nt,[e("div",null,[e("h3",rt,o(t.$t("garages.manage_subscription")),1),e("p",dt,o(r.value?c(r.value):""),1)]),e("button",{onClick:w,class:"p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition"},[...s[16]||(s[16]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),e("div",ct,[e("div",ut,[e("p",pt,o(t.$t("garages.current_package")),1),e("p",gt,o(r.value?.subscription_tier_name||t.$t("garages.free_fallback")),1),r.value?.subscription_expires_at?(i(),l("p",mt,o(t.$t("garages.expires"))+": "+o(A(r.value.subscription_expires_at)),1)):b("",!0)]),e("div",null,[e("label",vt,o(t.$t("garages.select_package")),1),C(e("select",{"onUpdate:modelValue":s[2]||(s[2]=a=>d.value=a),class:"w-full px-3 py-2.5 bg-slate-900 border border-slate-700 rounded-lg text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50 transition"},[e("option",xt,o(t.$t("garages.select_package_placeholder")),1),(i(!0),l(L,null,T(S.value,a=>(i(),l("option",{key:a.id,value:a.id},o(a.name)+" (Level "+o(a.tier_level)+") ",9,ft))),128))],512),[[H,d.value]])]),e("div",null,[e("label",ht,[z(o(t.$t("garages.custom_expiration"))+" ",1),e("span",bt,"("+o(t.$t("garages.optional"))+")",1)]),C(e("input",{"onUpdate:modelValue":s[3]||(s[3]=a=>v.value=a),type:"datetime-local",class:"w-full px-3 py-2.5 bg-slate-900 border border-slate-700 rounded-lg text-sm text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50 transition"},null,512),[[F,v.value]]),e("p",_t,o(t.$t("garages.custom_expiration_hint")),1)]),x.value?(i(),l("div",yt,[e("p",kt,o(x.value),1)])):b("",!0)]),e("div",wt,[e("button",{onClick:w,class:"px-4 py-2 text-sm font-medium text-slate-300 hover:text-white transition"},o(t.$t("garages.cancel")),1),e("button",{onClick:P,disabled:f.value||!d.value,class:p(["px-5 py-2 text-sm font-medium rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed",f.value?"bg-indigo-600/50 text-indigo-200 cursor-wait":"bg-indigo-600 text-white hover:bg-indigo-500"])},[f.value?(i(),l("span",$t,[s[17]||(s[17]=e("svg",{class:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1)),z(" "+o(t.$t("garages.saving")),1)])):(i(),l("span",Mt,o(t.$t("garages.save")),1))],10,Ct)])])])):b("",!0),h.value?(i(),l("div",{key:4,class:p(["fixed bottom-6 right-6 px-5 py-3 rounded-xl shadow-xl text-sm font-medium z-50",h.value.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"])},o(h.value.message),3)):b("",!0)]))}});export{Lt as default};
|