PageSourceSearch

https://guwebbackefull-production.up.railway.app/assets/AdminGameAccounts-Cvvj1JSU.js

js guwebbackefull-production.up.railway.app collected 2026-10-03 12:13:11 UTC 11,088 bytes, 1 lines download raw bytes

1import{$ as G,r as d,h as k,a2 as A,j as e,G as E,D as i,E as C}from"./index-Dps01Vg8.js";import{A as I}from"./AdminLayout-7GjjRQiS.js";import{S as P}from"./skeleton-CeP4q2fE.js";import{s as q,t as M,v as $,w as K,x as Q,y as L}from"./admin-CfqB4ps6.js";import{P as R}from"./plus-BQGcbQm2.js";import{K as U}from"./key-round-DuZpVX9J.js";import{S as _}from"./shield-check-3sx8lZd1.js";import{U as W}from"./users-CbGuScAv.js";import{E as O}from"./eye-off-DMFdbHZp.js";import{E as T}from"./eye-s8LFbrDj.js";import"./image-CHBfd7Em.js";function D(t){return t?new Date(t).toLocaleString():"—"}function F({initial:t,onSave:f,onCancel:o,saving:n}){const[c,u]=d.useState((t==null?void 0:t.gameId)??""),[h,N]=d.useState((t==null?void 0:t.username)??""),[m,w]=d.useState(""),[x,b]=d.useState(""),[p,y]=d.useState((t==null?void 0:t.maxDailyUses)??5),[g,v]=d.useState((t==null?void 0:t.status)??"active"),[j,S]=d.useState((t==null?void 0:t.notes)??""),[s,a]=d.useState(!1),l="w-full px-4 py-2.5 rounded-xl bg-background-soft border border-border text-sm focus:outline-none focus:ring-2 focus:ring-primary";return e.jsxs("div",{className:"panel-lg p-5 mb-5 space-y-4",children:[e.jsx("h3",{className:"font-display font-semibold text-base",children:t?"Edit account":"Add account"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Game ID *"}),e.jsx("input",{className:l,placeholder:"fc26",value:c,onChange:r=>u(r.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Username *"}),e.jsx("input",{className:l,placeholder:"account_login",value:h,onChange:r=>N(r.target.value)})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-muted-foreground mb-1 block",children:["Password ",t?"(leave blank to keep)":"*"]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:s?"text":"password",className:`${l} pr-10`,placeholder:t?"••••••••":"Password",value:m,onChange:r=>w(r.target.value)}),e.jsx("button",{type:"button",onClick:()=>a(!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s?e.jsx(O,{className:"h-4 w-4"}):e.jsx(T,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Max uses / 24h"}),e.jsx("input",{type:"number",min:1,max:100,className:l,value:p,onChange:r=>y(Number(r.target.value))})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-muted-foreground mb-1 block",children:[t?"Replace shared_secret":"shared_secret"," ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),t&&e.jsxs("div",{className:`chip mb-2 ${t.hasSharedSecret?"bg-success/15 text-success":"bg-muted text-muted-foreground"}`,children:[e.jsx(U,{className:"h-3 w-3"}),t.hasSharedSecret?"Configured":"Not set"]}),e.jsx("input",{className:l,placeholder:t?"Leave blank to keep the current secret":"base64 shared_secret from the maFile",value:x,onChange:r=>b(r.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Used to generate the live 2FA code returned with every session."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Status"}),e.jsxs("select",{className:l,value:g,onChange:r=>v(r.target.value),children:[e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"disabled",children:"Disabled"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Notes"}),e.jsx("input",{className:l,value:j,onChange:r=>S(r.target.value)})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 rounded-full bg-muted text-sm hover:bg-accent",children:"Cancel"}),e.jsx("button",{onClick:()=>f({gameId:c,username:h,password:m,sharedSecret:x,maxDailyUses:p,status:g,notes:j}),disabled:n||!c||!h||!t&&!m,className:"px-4 py-2 rounded-full bg-gradient-primary text-white text-sm font-semibold shadow-pill disabled:opacity-50",children:n?"Saving...":"Save"})]})]})}const ae=()=>{var j,S;
1const t=G(),[f,o]=d.useState(!1),[n,c]=d.useState(null),[u,h]=d.useState(""),N=k({queryKey:["admin","game-accounts",u],queryFn:()=>K(u.trim()||void 0)}),m=k({queryKey:["admin","game-accounts","stats"],queryFn:Q}),w=k({queryKey:["admin","game-accounts","sessions"],queryFn:L}),x=()=>t.invalidateQueries({queryKey:["admin","game-accounts"]}),b=A({mutationFn:s=>q({gameId:s.gameId,username:s.username,password:s.password,maxDailyUses:s.maxDailyUses,...s.sharedSecret.trim()?{sharedSecret:s.sharedSecret.trim()}:{},...s.notes.trim()?{notes:s.notes.trim()}:{}}),onSuccess:()=>{i.success("Account added"),o(!1),x()},onError:s=>i.error(C(s)||"Save failed")}),p=A({mutationFn:({id:s,v:a})=>M(s,{gameId:a.gameId,username:a.username,maxDailyUses:a.maxDailyUses,status:a.status,notes:a.notes,...a.password?{password:a.password}:{},...a.sharedSecret.trim()?{sharedSecret:a.sharedSecret.trim()}:{}}),onSuccess:()=>{i.success("Account updated"),c(null),x()},onError:s=>i.error(C(s)||"Update failed")}),y=A({mutationFn:$,onSuccess:()=>{i.success("Account deleted"),x()},onError:s=>i.error(C(s)||"Delete failed")}),g=((j=N.data)==null?void 0:j.items)??[],v=((S=w.data)==null?void 0:S.items)??[];return e.jsxs(I,{title:"Game Accounts",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-5",children:[{key:"total",label:"Total accounts"},{key:"active",label:"Active"},{key:"disabled",label:"Disabled"},{key:"sessions24h",label:"Sessions (24h)"}].map(({key:s,label:a})=>{var l;return e.jsxs("div",{className:"panel p-4 text-center",children:[e.jsx("div",{className:"font-display text-2xl font-bold",children:m.isLoading?"…":((l=m.data)==null?void 0:l[s])??0}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:a})]},s)})}),f&&e.jsx(F,{onSave:s=>b.mutate(s),onCancel:()=>o(!1),saving:b.isPending}),n&&e.jsx(F,{initial:n,onSave:s=>p.mutate({id:n.id,v:s}),onCancel:()=>c(null),saving:p.isPending}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsx("h2",{className:"font-display font-semibold text-lg",children:"Account pool"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:"px-4 py-2 rounded-full bg-background-soft border border-border text-sm focus:outline-none focus:ring-2 focus:ring-primary",placeholder:"Filter by game ID",value:u,onChange:s=>h(s.target.value)}),!f&&!n&&e.jsxs("button",{onClick:()=>o(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-gradient-primary text-white text-sm font-semibold shadow-pill",children:[e.jsx(R,{className:"h-4 w-4"})," Add account"]})]})]}),e.jsx("div",{className:"panel-lg overflow-hidden mb-6",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3",children:"Game"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Username"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Seats (24h)"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Next free slot"}),e.jsx("th",{className:"text-left px-4 py-3",children:"2FA"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Status"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:N.isLoading?[1,2,3].map(s=>e.jsxs("tr",{children:[[1,2,3,4,5,6].map(a=>e.jsx("td",{className:"px-4 py-3",children:e.jsx(P,{className:"h-4 w-24"})},a)),e.jsx("td",{})]},s)):g.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-10 text-center text-muted-foreground",children:'No accounts yet. Click "Add account" to get started.'})}):g.map(s=>e.jsxs("tr",{className:"hover:bg-muted/30 transition",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-primary/10 text-primary text-xs font-medium",children:[e.jsx(E,{className:"h-3 w-3"}),s.gameId]})}),e.jsx("td",{className:"px-4 py-3 font-medium",children:s.username}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("span",{className:`text-sm font-semibold ${s.remaining===0?"text-destructive":"text-primary"}`,children:[s.usedInWindow," / ",s.maxDailyUses]}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"used"})]}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground",children:D(s.nextFreeSlotAt)}
1),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`chip ${s.hasSharedSecret?"bg-success/15 text-success":"bg-muted text-muted-foreground"}`,children:[e.jsx(U,{className:"h-3 w-3"}),s.hasSharedSecret?"Configured":"None"]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`chip ${s.status==="active"?"bg-success/15 text-success":"bg-destructive/15 text-destructive"}`,children:[e.jsx(_,{className:"h-3 w-3"}),s.status]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{c(s),o(!1)},className:"px-3 py-1.5 rounded-full bg-muted hover:bg-accent text-xs font-medium",children:"Edit"}),e.jsx("button",{onClick:()=>{confirm(`Delete ${s.username}?`)&&y.mutate(s.id)},disabled:y.isPending,className:"px-3 py-1.5 rounded-full bg-destructive/10 text-destructive hover:bg-destructive hover:text-white text-xs font-medium transition",children:"Delete"})]})})]},s.id))})]})}),e.jsxs("h2",{className:"font-display font-semibold text-lg mb-3 inline-flex items-center gap-2",children:[e.jsx(W,{className:"h-4 w-4"})," Recent sessions"]}),e.jsx("div",{className:"panel-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3",children:"When"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Game"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Username"}),e.jsx("th",{className:"text-left px-4 py-3",children:"Client IP"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:v.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-muted-foreground",children:"No sessions yet."})}):v.map(s=>e.jsxs("tr",{className:"hover:bg-muted/30 transition",children:[e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground",children:D(s.createdAt)}),e.jsx("td",{className:"px-4 py-3",children:s.gameId}),e.jsx("td",{className:"px-4 py-3 font-medium",children:s.username}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:s.clientIp})]},s.id))})]})})]})};export{ae as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.