355 lines
14 KiB
Vue
355 lines
14 KiB
Vue
<script setup lang="ts">
|
||
import { Head, router } from '@inertiajs/vue3';
|
||
import { ref, computed } from 'vue';
|
||
import CasinoAdminLayout from '@/layouts/admin/CasinoAdminLayout.vue';
|
||
import {
|
||
Search, Flag, Clock, CheckCircle2, XCircle, ChevronRight,
|
||
MessageSquareText, Eye, EyeOff
|
||
} from 'lucide-vue-next';
|
||
|
||
interface Reporter {
|
||
id: number;
|
||
username: string;
|
||
email: string;
|
||
avatar: string | null;
|
||
avatar_url: string | null;
|
||
}
|
||
|
||
interface Report {
|
||
id: number;
|
||
reporter: Reporter;
|
||
message_id: string;
|
||
message_text: string;
|
||
sender_id: number | null;
|
||
sender_username: string | null;
|
||
reason: string | null;
|
||
status: 'pending' | 'reviewed' | 'dismissed';
|
||
admin_note: string | null;
|
||
created_at: string;
|
||
}
|
||
|
||
const props = defineProps<{
|
||
reports: { data: Report[]; links: any[]; meta: any };
|
||
filters: { status?: string; search?: string };
|
||
stats: { total: number; pending: number; reviewed: number; dismissed: number };
|
||
}>();
|
||
|
||
const filterStatus = ref(props.filters.status ?? 'pending');
|
||
const searchInput = ref(props.filters.search ?? '');
|
||
let searchTimer: ReturnType<typeof setTimeout> | null = null;
|
||
|
||
function applyFilter() {
|
||
router.get('/admin/reports/chat', {
|
||
status: filterStatus.value || undefined,
|
||
search: searchInput.value || undefined,
|
||
}, { preserveScroll: true });
|
||
}
|
||
|
||
function onSearchInput() {
|
||
if (searchTimer) clearTimeout(searchTimer);
|
||
searchTimer = setTimeout(applyFilter, 400);
|
||
}
|
||
|
||
function setStatus(s: string) {
|
||
filterStatus.value = s;
|
||
applyFilter();
|
||
}
|
||
|
||
function openCase(id: number) {
|
||
router.visit(`/admin/reports/chat/${id}`);
|
||
}
|
||
|
||
function fmt(d: string) {
|
||
return new Date(d).toLocaleString('de-DE', { day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute: '2-digit' });
|
||
}
|
||
|
||
const reasonLabels: Record<string, string> = {
|
||
spam: 'Spam', beleidigung: 'Beleidigung', belaestigung: 'Belästigung',
|
||
betrug: 'Betrug', sonstiges: 'Sonstiges', harassment: 'Belästigung',
|
||
offensive: 'Beleidigung', scam: 'Betrug', other: 'Sonstiges',
|
||
};
|
||
function rl(r: string | null) { return r ? (reasonLabels[r] ?? r) : '–'; }
|
||
|
||
const statusMeta: Record<string, { color: string; bg: string; border: string; label: string }> = {
|
||
pending: { color: '#f59e0b', bg: 'rgba(245,158,11,0.12)', border: 'rgba(245,158,11,0.3)', label: 'Pending' },
|
||
reviewed: { color: '#22c55e', bg: 'rgba(34,197,94,0.12)', border: 'rgba(34,197,94,0.3)', label: 'Reviewed' },
|
||
dismissed: { color: '#6b7280', bg: 'rgba(107,114,128,0.1)', border: 'rgba(107,114,128,0.25)', label: 'Dismissed' },
|
||
};
|
||
|
||
const showingLabel = computed(() => {
|
||
if (!filterStatus.value || filterStatus.value === 'all') return 'Alle';
|
||
return statusMeta[filterStatus.value]?.label ?? filterStatus.value;
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<CasinoAdminLayout>
|
||
<Head title="Admin – Chat Reports" />
|
||
<template #title>Chat Reports</template>
|
||
|
||
<!-- ── Stats row ── -->
|
||
<div class="stats-row">
|
||
<button class="stat-card" :class="{ active: !filterStatus || filterStatus === 'all' }" @click="setStatus('all')">
|
||
<MessageSquareText :size="16" class="sc-icon all" />
|
||
<div class="sc-body">
|
||
<span class="sc-val">{{ stats.total }}</span>
|
||
<span class="sc-label">Gesamt</span>
|
||
</div>
|
||
</button>
|
||
<button class="stat-card" :class="{ active: filterStatus === 'pending' }" @click="setStatus('pending')">
|
||
<Clock :size="16" class="sc-icon pending" />
|
||
<div class="sc-body">
|
||
<span class="sc-val pending">{{ stats.pending }}</span>
|
||
<span class="sc-label">Offen</span>
|
||
</div>
|
||
<span v-if="stats.pending > 0" class="sc-dot"></span>
|
||
</button>
|
||
<button class="stat-card" :class="{ active: filterStatus === 'reviewed' }" @click="setStatus('reviewed')">
|
||
<CheckCircle2 :size="16" class="sc-icon reviewed" />
|
||
<div class="sc-body">
|
||
<span class="sc-val reviewed">{{ stats.reviewed }}</span>
|
||
<span class="sc-label">Erledigt</span>
|
||
</div>
|
||
</button>
|
||
<button class="stat-card" :class="{ active: filterStatus === 'dismissed' }" @click="setStatus('dismissed')">
|
||
<XCircle :size="16" class="sc-icon dismissed" />
|
||
<div class="sc-body">
|
||
<span class="sc-val dismissed">{{ stats.dismissed }}</span>
|
||
<span class="sc-label">Abgelehnt</span>
|
||
</div>
|
||
</button>
|
||
</div>
|
||
|
||
<!-- ── Toolbar ── -->
|
||
<div class="toolbar">
|
||
<div class="search-wrap">
|
||
<Search :size="14" class="search-icon" />
|
||
<input
|
||
v-model="searchInput"
|
||
@input="onSearchInput"
|
||
type="text"
|
||
placeholder="Case-Nr. oder Username suchen…"
|
||
class="search-input"
|
||
/>
|
||
</div>
|
||
<div class="showing-pill">
|
||
<Eye :size="12" />
|
||
{{ showingLabel }}
|
||
<span class="showing-count">{{ reports.meta?.total ?? reports.data.length }}</span>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- ── Table ── -->
|
||
<div class="table-wrap">
|
||
<div v-if="!reports.data.length" class="empty-state">
|
||
<Flag :size="28" class="empty-icon" />
|
||
<div class="empty-text">Keine Reports gefunden</div>
|
||
<div class="empty-sub" v-if="searchInput">Für „{{ searchInput }}" wurden keine Ergebnisse gefunden.</div>
|
||
</div>
|
||
|
||
<table v-else class="reports-table">
|
||
<thead>
|
||
<tr>
|
||
<th style="width:70px">Case</th>
|
||
<th style="width:150px">Von</th>
|
||
<th style="width:150px">Gemeldet</th>
|
||
<th style="width:110px">Grund</th>
|
||
<th>Nachricht</th>
|
||
<th style="width:105px">Status</th>
|
||
<th style="width:120px">Datum</th>
|
||
<th style="width:28px"></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr
|
||
v-for="r in reports.data"
|
||
:key="r.id"
|
||
class="report-row"
|
||
:class="`status-${r.status}`"
|
||
@click="openCase(r.id)"
|
||
>
|
||
<td class="td-case">
|
||
<span class="case-badge">#{{ r.id }}</span>
|
||
</td>
|
||
<td>
|
||
<div class="user-cell">
|
||
<div class="dot reporter"></div>
|
||
<span class="uname">@{{ r.reporter?.username || '–' }}</span>
|
||
</div>
|
||
</td>
|
||
<td>
|
||
<div class="user-cell">
|
||
<div class="dot sender"></div>
|
||
<span class="uname">@{{ r.sender_username || '–' }}</span>
|
||
</div>
|
||
</td>
|
||
<td>
|
||
<span class="reason-chip">{{ rl(r.reason) }}</span>
|
||
</td>
|
||
<td class="td-msg">
|
||
<span class="msg-snip">{{ r.message_text }}</span>
|
||
</td>
|
||
<td>
|
||
<span class="status-chip"
|
||
:style="{ color: statusMeta[r.status].color, background: statusMeta[r.status].bg, borderColor: statusMeta[r.status].border }"
|
||
>{{ statusMeta[r.status].label }}</span>
|
||
</td>
|
||
<td class="td-date">{{ fmt(r.created_at) }}</td>
|
||
<td class="td-arrow"><ChevronRight :size="14" /></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<!-- ── Pagination ── -->
|
||
<div class="pagination" v-if="reports.links && reports.links.length > 3">
|
||
<template v-for="link in reports.links" :key="link.label">
|
||
<button
|
||
class="page-btn"
|
||
:class="{ active: link.active, disabled: !link.url }"
|
||
:disabled="!link.url"
|
||
@click="link.url && router.visit(link.url)"
|
||
v-html="link.label"
|
||
></button>
|
||
</template>
|
||
</div>
|
||
</CasinoAdminLayout>
|
||
</template>
|
||
|
||
<style scoped>
|
||
/* ── Stats ── */
|
||
.stats-row {
|
||
display: grid;
|
||
grid-template-columns: repeat(4, 1fr);
|
||
gap: 10px;
|
||
margin-bottom: 18px;
|
||
}
|
||
.stat-card {
|
||
display: flex; align-items: center; gap: 12px;
|
||
background: #111113; border: 1px solid #1e1e21; border-radius: 12px;
|
||
padding: 14px 16px; cursor: pointer; transition: .15s; position: relative;
|
||
text-align: left;
|
||
}
|
||
.stat-card:hover { border-color: #2a2a2f; background: #141416; }
|
||
.stat-card.active { border-color: #333; background: #161618; }
|
||
.sc-icon { flex-shrink: 0; }
|
||
.sc-icon.all { color: #888; }
|
||
.sc-icon.pending { color: #f59e0b; }
|
||
.sc-icon.reviewed { color: #22c55e; }
|
||
.sc-icon.dismissed { color: #6b7280; }
|
||
.sc-body { display: flex; flex-direction: column; gap: 1px; }
|
||
.sc-val { font-size: 22px; font-weight: 900; color: #fff; line-height: 1; }
|
||
.sc-val.pending { color: #f59e0b; }
|
||
.sc-val.reviewed { color: #22c55e; }
|
||
.sc-val.dismissed { color: #6b7280; }
|
||
.sc-label { font-size: 10px; color: #555; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
|
||
.sc-dot {
|
||
position: absolute; top: 10px; right: 10px;
|
||
width: 7px; height: 7px; border-radius: 50%; background: #f59e0b;
|
||
box-shadow: 0 0 6px rgba(245,158,11,.6);
|
||
animation: pulse-dot 1.5s ease-in-out infinite;
|
||
}
|
||
@keyframes pulse-dot {
|
||
0%, 100% { opacity: 1; transform: scale(1); }
|
||
50% { opacity: .5; transform: scale(.7); }
|
||
}
|
||
|
||
/* ── Toolbar ── */
|
||
.toolbar {
|
||
display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
|
||
}
|
||
.search-wrap {
|
||
flex: 1; position: relative; max-width: 380px;
|
||
}
|
||
.search-icon {
|
||
position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #444; pointer-events: none;
|
||
}
|
||
.search-input {
|
||
width: 100%; background: #111113; border: 1px solid #1e1e21; border-radius: 9px;
|
||
color: #ccc; font-size: 13px; padding: 9px 12px 9px 34px; outline: none; transition: .15s;
|
||
}
|
||
.search-input::placeholder { color: #3a3a3f; }
|
||
.search-input:focus { border-color: #333; }
|
||
|
||
.showing-pill {
|
||
display: flex; align-items: center; gap: 6px;
|
||
background: #111113; border: 1px solid #1e1e21; border-radius: 20px;
|
||
padding: 6px 12px; font-size: 12px; color: #555; margin-left: auto;
|
||
}
|
||
.showing-count {
|
||
background: #1a1a1c; border: 1px solid #252528; border-radius: 10px;
|
||
padding: 1px 7px; color: #888; font-size: 11px; font-weight: 700;
|
||
}
|
||
|
||
/* ── Table ── */
|
||
.table-wrap {
|
||
background: #111113; border: 1px solid #1e1e21; border-radius: 14px; overflow: hidden;
|
||
}
|
||
.empty-state { padding: 60px 20px; text-align: center; }
|
||
.empty-icon { color: #2a2a2f; margin: 0 auto 12px; }
|
||
.empty-text { color: #555; font-size: 14px; font-weight: 700; }
|
||
.empty-sub { color: #3a3a3f; font-size: 12px; margin-top: 4px; }
|
||
|
||
.reports-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
||
.reports-table thead tr { border-bottom: 1px solid #1e1e21; }
|
||
.reports-table th {
|
||
padding: 10px 14px; font-size: 10px; font-weight: 700;
|
||
text-transform: uppercase; letter-spacing: .6px; color: #3a3a3f; text-align: left;
|
||
}
|
||
.reports-table td { padding: 11px 14px; font-size: 13px; vertical-align: middle; }
|
||
|
||
.report-row { border-bottom: 1px solid #161618; cursor: pointer; transition: background .12s; }
|
||
.report-row:last-child { border-bottom: none; }
|
||
.report-row:hover { background: rgba(255,255,255,.025); }
|
||
.report-row.status-pending { border-left: 2px solid #f59e0b; }
|
||
.report-row.status-reviewed { border-left: 2px solid #22c55e; opacity: .65; }
|
||
.report-row.status-dismissed { border-left: 2px solid #252528; opacity: .45; }
|
||
|
||
.td-case { width: 70px; }
|
||
.case-badge {
|
||
font-size: 11px; font-weight: 800; color: #888;
|
||
background: #161618; border: 1px solid #252528;
|
||
padding: 3px 9px; border-radius: 6px;
|
||
}
|
||
|
||
.user-cell { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; }
|
||
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
|
||
.dot.reporter { background: #3b82f6; }
|
||
.dot.sender { background: #df006a; }
|
||
.uname { font-size: 13px; color: #ddd; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
|
||
|
||
.reason-chip {
|
||
font-size: 10px; font-weight: 700; color: #aaa;
|
||
background: #161618; border: 1px solid #252528;
|
||
padding: 3px 8px; border-radius: 6px; white-space: nowrap;
|
||
}
|
||
|
||
.td-msg { max-width: 0; }
|
||
.msg-snip {
|
||
color: #555; font-size: 12px; display: block;
|
||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||
}
|
||
|
||
.status-chip {
|
||
font-size: 10px; font-weight: 800; padding: 3px 9px;
|
||
border-radius: 20px; border: 1px solid;
|
||
text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
|
||
}
|
||
|
||
.td-date { color: #444; font-size: 11px; white-space: nowrap; }
|
||
.td-arrow { color: #333; text-align: center; }
|
||
|
||
/* ── Pagination ── */
|
||
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; justify-content: center; }
|
||
.page-btn {
|
||
background: #111; border: 1px solid #222; color: #ccc;
|
||
padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: .2s;
|
||
}
|
||
.page-btn.active { background: #df006a; border-color: #df006a; color: #fff; }
|
||
.page-btn.disabled { opacity: .4; cursor: default; }
|
||
|
||
@media (max-width: 900px) {
|
||
.stats-row { grid-template-columns: 1fr 1fr; }
|
||
}
|
||
</style>
|