Add active/archived/all filter tabs to the Raids page

Uses the bot's new ?status= query param on /api/raids. fetch_raids()
takes a status argument (whitelisted against active/archived/all,
falls back to active on anything else) and appends it to the request
URL. Archived raids get a dimmed card style and an "Archiviert" badge
using the new archived/archived_at fields. Verified all three filters
end-to-end against the live API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-18 12:59:01 +02:00
parent 620ef68015
commit 4df0149f8b
3 changed files with 71 additions and 7 deletions

View file

@ -389,6 +389,33 @@ input:focus, select:focus, textarea:focus {
.raid-group ul { margin: 0; padding-left: 1.1rem; }
.raid-group li { margin-bottom: 0.25rem; }
.panel-archived { opacity: 0.7; }
.filter-tabs {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 1rem;
}
.filter-tab {
padding: 0.4rem 0.9rem;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--bg-panel-alt);
color: var(--text-muted);
font-size: 0.85rem;
font-weight: 600;
}
.filter-tab:hover { color: var(--text); text-decoration: none; }
.filter-tab.active {
background: rgba(201, 162, 39, 0.15);
border-color: var(--gold);
color: var(--gold);
}
@media (max-width: 860px) {
.app-shell {
flex-direction: column;

View file

@ -1,12 +1,18 @@
<?php
declare(strict_types=1);
const RAID_STATUSES = ['active', 'archived', 'all'];
/**
* @return array<int, array<string, mixed>>
* @throws RuntimeException
*/
function fetch_raids(): array
function fetch_raids(string $status = 'active'): array
{
if (!in_array($status, RAID_STATUSES, true)) {
$status = 'active';
}
$configPath = __DIR__ . '/../config.php';
if (!file_exists($configPath)) {
throw new RuntimeException('Konfigurationsdatei fehlt.');
@ -24,7 +30,10 @@ function fetch_raids(): array
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
}
$ch = curl_init($apiUrl);
$separator = str_contains($apiUrl, '?') ? '&' : '?';
$requestUrl = $apiUrl . $separator . 'status=' . urlencode($status);
$ch = curl_init($requestUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . $apiKey],

View file

@ -3,21 +3,42 @@ require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_permission('raids.view');
$status = (string) ($_GET['status'] ?? 'active');
if (!in_array($status, RAID_STATUSES, true)) {
$status = 'active';
}
$raids = [];
$apiError = null;
try {
$raids = fetch_raids();
$raids = fetch_raids($status);
} catch (Throwable $e) {
$apiError = $e->getMessage();
}
$statusLabels = [
'active' => 'Aktiv',
'archived' => 'Archiviert',
'all' => 'Alle',
];
$emptyLabels = [
'active' => 'Aktuell sind keine aktiven Raids geplant.',
'archived' => 'Es sind keine archivierten Raids vorhanden.',
'all' => 'Aktuell sind keine Raids vorhanden.',
];
$pageTitle = 'Raids';
include __DIR__ . '/includes/header.php';
?>
<div class="panel">
<h1>Raids</h1>
<p class="text-muted">Anstehende Raid-Termine deiner Gilde.</p>
<p class="text-muted">Raid-Termine deiner Gilde.</p>
<div class="filter-tabs">
<?php foreach ($statusLabels as $value => $label): ?>
<a href="/raids.php?status=<?= e($value) ?>" class="filter-tab<?= $status === $value ? ' active' : '' ?>"><?= e($label) ?></a>
<?php endforeach; ?>
</div>
</div>
<?php if ($apiError): ?>
@ -26,7 +47,7 @@ include __DIR__ . '/includes/header.php';
</div>
<?php elseif (empty($raids)): ?>
<div class="panel">
<p class="text-muted">Aktuell sind keine Raids geplant.</p>
<p class="text-muted"><?= e($emptyLabels[$status]) ?></p>
</div>
<?php else: ?>
<?php foreach ($raids as $raid): ?>
@ -40,6 +61,8 @@ include __DIR__ . '/includes/header.php';
$gearscore = trim((string) ($raid['gearscore'] ?? ''));
$maxSlots = (int) ($raid['max_slots'] ?? 0);
$signups = is_array($raid['signups'] ?? null) ? $raid['signups'] : [];
$isArchived = !empty($raid['archived']) || !empty($raid['archived_at']);
$archivedAt = $raid['archived_at'] ?? null;
$groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? '')))));
@ -49,10 +72,15 @@ include __DIR__ . '/includes/header.php';
$signupsByGroup[$groupNumber][] = $signup;
}
?>
<div class="panel">
<div class="panel<?= $isArchived ? ' panel-archived' : '' ?>">
<div class="raid-header">
<h2><?= e($title) ?></h2>
<span class="badge"><?= count($signups) ?> / <?= $maxSlots ?> angemeldet</span>
<div class="badge-group">
<?php if ($isArchived): ?>
<span class="badge badge-disabled">Archiviert<?= $archivedAt ? ' (' . e((string) $archivedAt) . ')' : '' ?></span>
<?php endif; ?>
<span class="badge"><?= count($signups) ?> / <?= $maxSlots ?> angemeldet</span>
</div>
</div>
<p class="text-muted"><?= e($dateLabel) ?></p>
<?php if ($requirements !== ''): ?>