Zum Inhalt

Benutzerverwaltung

User-Liste

Seite: app/users/page.tsx (98 Zeilen) API: app/api/users/route.ts (60 Zeilen) Pfad: /users

Features

  • Paginierte Benutzerliste (50 pro Seite)
  • Suche nach Wallet, Name, E-Mail
  • Klick auf Zeile → User-Detail

Tabellen-Spalten

Spalte Beschreibung
Wallet Adresse (gekürzt)
Name Vorname + Nachname
Email E-Mail-Adresse
Country Land
Tips Gesamte gekaufte Tipps
Spent Gesamtausgaben in USDT
Joined Registrierungsdatum

API-Query

SELECT u.wallet_address, u.first_name, u.last_name, u.email,
       u.address_country, u.created_at, u.last_login_at,
       COALESCE(t.total_tips, 0) as total_tips,
       COALESCE(t.total_spent, 0) as total_spent
FROM users u
LEFT JOIN LATERAL (
  SELECT SUM(tip_count) as total_tips,
         SUM(total_stake::bigint) as total_spent
  FROM tickets WHERE player = u.wallet_address
) t ON true
WHERE (LOWER(wallet_address) LIKE $search
   OR LOWER(email) LIKE $search
   OR LOWER(first_name) LIKE $search
   OR LOWER(last_name) LIKE $search)
ORDER BY u.created_at DESC
LIMIT $limit OFFSET $offset

User-Detail

Seite: app/users/[wallet]/page.tsx (243 Zeilen) API: app/api/users/[wallet]/route.ts (58 Zeilen) Pfad: /users/{wallet}

Aufbau

┌─────────────────────────────────────────────┐
│ ← Back to Users                             │
├─────────────────────────────────────────────┤
│ StatCards                                    │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐     │
│ │Total Tips│ │  Spent   │ │ Voucher  │     │
│ │   45     │ │ 123 USDT │ │  5 Tips  │     │
│ └──────────┘ └──────────┘ └──────────┘     │
├─────────────────────────────────────────────┤
│ Profile                                      │
│ Name, Email, Country, Language, DOB, KYC     │
│ Joined, Last Login                           │
├─────────────────────────────────────────────┤
│ Grant Bonus                                  │
│ [Amount: 1-100] [Type: dropdown] [Grant]     │
├─────────────────────────────────────────────┤
│ Referred By (falls vorhanden)                │
├─────────────────────────────────────────────┤
│ Recent Tickets (letzte 50)                   │
│ Ticket ID | Day | Pool | Tips | Stake | Date │
├─────────────────────────────────────────────┤
│ Voucher History (letzte 50)                  │
│ ID | Amount | Type | Status | Created        │
└─────────────────────────────────────────────┘

Bonus-Vergabe

Direkt auf der User-Detail-Seite können Boni vergeben werden:

// users/[wallet]/page.tsx:128-167
async function handleGrantBonus() {
  const res = await fetch("/api/vouchers", {
    method: "POST",
    body: JSON.stringify({
      buyer: wallet,
      amount: bonusAmount,
      type: bonusType,
      reason: `Admin grant for ${wallet}`
    })
  });
}

Bonus-Typen: - marketing_bonus - Marketing-Bonus (max 3 aktive pro Spieler, 30 Tage Ablauf) - instant_bonus - Sofort-Bonus - profile_bonus - Profil-Vervollständigung - compensation - Kompensation

API-Daten

Die API lädt parallel:

  1. User-Profil: Alle Felder aus users-Tabelle
  2. Tickets: Letzte 50 Tickets mit Pool, Tipps, Einsatz
  3. Vouchers: Letzte 50 Gutscheine mit Status
  4. Affiliate-Referrals: Vom User geworbene Spieler
  5. Referred By: Wer hat diesen User geworben?