feat(admin): Inhalts-Seiten im neuen Design (Etappe 3, Paket 2)

- Beiträge: Suche + Spaltenwahl beschriftet, „Kommentare“ plus Menü „…“
  mit beschrifteten Aktionen statt sechs Symbolen und Hilfe-Popover,
  Pfoten/Kommentare/Meldungen als Symbole statt Emojis, komplett deutsch;
  Spaltenzahl per useSyncExternalStore (behebt Lint-Fehler setState im Effect)
- Tiere: Seitenkopf, „Halter“ statt „Owner“; Detailfenster zeigt Name und
  E-Mail des Halters (Clerk) und deutsche Tierart/Rasse
- Werbung, Musik: Seitenkopf mit Aktion, Statusabzeichen, deutsche Texte

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-05 08:48:49 +02:00
1 parent cc9db2ea05
commit c474e66106
8 files changed
+221 -228

No files matched your search

+24 -20
View File
@@ -3,6 +3,8 @@
import { useState, useRef, useCallback } from "react";
import { useQuery, useQueries, useMutation, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { AdminPageHeader } from "@/components/admin/AdminSection";
import { StatusBadge } from "@/components/admin/StatusBadge";
import { getMediaUrl } from "@/lib/media-url";
import { Plus, Pencil, Trash2, Loader2, Check, X, ImagePlus, ImageOff, Eye, PawPrint, MessageCircle, Repeat2 } from "lucide-react";
import { Button } from "@/components/ui/button";
@@ -10,7 +12,6 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
import { Switch } from "@/components/ui/switch";
import { Badge } from "@/components/ui/badge";
import { toast } from "sonner";
type AdForm = {
@@ -171,8 +172,8 @@ export default function AdminAdsPage() {
await new Promise<void>((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onload = () =>
xhr.status >= 200 && xhr.status < 300 ? resolve() : reject(new Error(`Upload failed: ${xhr.status}`));
xhr.onerror = () => reject(new Error("Network error"));
xhr.status >= 200 && xhr.status < 300 ? resolve() : reject(new Error(`Hochladen fehlgeschlagen (${xhr.status})`));
xhr.onerror = () => reject(new Error("Netzwerkfehler"));
xhr.open("PUT", presignedUrl);
xhr.setRequestHeader("Content-Type", file.type);
xhr.send(file);
@@ -201,21 +202,24 @@ export default function AdminAdsPage() {
const isPending = createAd.isPending || updateAd.isPending;
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<h1 className="text-2xl font-bold text-foreground">Werbung</h1>
<Button size="sm" onClick={openCreate} className="bg-orange-500 hover:bg-orange-600 text-white">
<Plus className="h-4 w-4 mr-1.5" />
New ad
</Button>
</div>
<div className="mx-auto max-w-6xl space-y-6">
<AdminPageHeader
title="Werbung"
description="Anzeigen im Feed – mit Zeitraum und optional nur für bestimmte Tierarten."
actions={
<Button size="sm" onClick={openCreate}>
<Plus className="h-4 w-4 mr-1.5" />
Neue Anzeige
</Button>
}
/>
{isLoading ? (
<div className="flex justify-center py-12">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
) : ads.length === 0 ? (
<p className="text-sm text-muted-foreground text-center py-12">Noch keine Ads — oben erstellen</p>
<p className="text-sm text-muted-foreground text-center py-12">Noch keine Anzeigen – oben rechts „Neue Anzeige“ wählen.</p>
) : (
<div className="space-y-2">
{ads.map((ad) => (
@@ -241,17 +245,17 @@ export default function AdminAdsPage() {
<div className="flex items-center gap-2">
<p className="text-sm font-medium text-foreground truncate">{ad.title}</p>
{ad.isActive ? (
<Badge className="bg-green-700 text-green-100 text-[10px]">Aktiv</Badge>
<StatusBadge tone="success">Aktiv</StatusBadge>
) : (
<Badge variant="secondary" className="text-[10px]">Inaktiv</Badge>
<StatusBadge tone="neutral">Inaktiv</StatusBadge>
)}
{ad.species.length > 0 && (
<Badge variant="outline" className="text-[10px] text-muted-foreground border-border">
<StatusBadge tone="info">
{ad.species
.map((id) => speciesList?.find((s) => s.id === id)?.name ?? "?")
.join(", ")}
{ad.breeds.length > 0 && ` · ${ad.breeds.length} Rasse${ad.breeds.length !== 1 ? "n" : ""}`}
</Badge>
</StatusBadge>
)}
</div>
{ad.caption && (
@@ -299,7 +303,7 @@ export default function AdminAdsPage() {
<Dialog open={dialogOpen} onOpenChange={(o) => { if (!o) closeDialog(); }}>
<DialogContent className="bg-card border-border text-foreground max-w-md">
<DialogHeader>
<DialogTitle>{editingId ? "Ad bearbeiten" : "Ad erstellen"}</DialogTitle>
<DialogTitle>{editingId ? "Anzeige bearbeiten" : "Anzeige erstellen"}</DialogTitle>
</DialogHeader>
<div className="space-y-3">
@@ -317,7 +321,7 @@ export default function AdminAdsPage() {
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={imagePreview}
alt="Ad preview"
alt="Vorschau der Anzeige"
className="w-full h-40 object-cover"
/>
<div className="absolute inset-0 flex flex-col items-center justify-center gap-1 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity">
@@ -369,7 +373,7 @@ export default function AdminAdsPage() {
className="bg-muted border-border text-foreground placeholder:text-muted-foreground"
/>
<Textarea
placeholder="Caption"
placeholder="Bildtext"
value={form.caption}
onChange={(e) => setForm({ ...form, caption: e.target.value })}
className="bg-muted border-border text-foreground placeholder:text-muted-foreground resize-none"
@@ -464,7 +468,7 @@ export default function AdminAdsPage() {
<Button
onClick={submitForm}
disabled={isPending || imageUploading || !form.title.trim()}
className="bg-orange-500 hover:bg-orange-600 text-white"
>
{isPending ? (
<Loader2 className="h-4 w-4 animate-spin mr-2" />
+22 -18
View File
@@ -3,6 +3,8 @@
import { useState, useRef, useCallback } from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { AdminPageHeader } from "@/components/admin/AdminSection";
import { StatusBadge } from "@/components/admin/StatusBadge";
import { getMusicUrl } from "@/lib/music-url";
import { MAX_MUSIC_FILE_SIZE, MUSIC_EXTENSION_CONTENT_TYPES, type MusicContentType } from "@/lib/music-content-types";
import { Plus, Pencil, Trash2, Loader2, Check, X, Music, Play, Pause } from "lucide-react";
@@ -11,7 +13,6 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
import { Switch } from "@/components/ui/switch";
import { Badge } from "@/components/ui/badge";
import { toast } from "sonner";
type TrackForm = {
@@ -64,7 +65,7 @@ function readAudioDuration(file: File): Promise<number> {
});
audio.addEventListener("error", () => {
URL.revokeObjectURL(url);
reject(new Error("Could not read audio duration"));
reject(new Error("Die Länge der Audiodatei ließ sich nicht lesen"));
});
audio.src = url;
});
@@ -159,15 +160,15 @@ export default function AdminMusicPage() {
await new Promise<void>((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onload = () =>
xhr.status >= 200 && xhr.status < 300 ? resolve() : reject(new Error(`Upload failed: ${xhr.status}`));
xhr.onerror = () => reject(new Error("Network error"));
xhr.status >= 200 && xhr.status < 300 ? resolve() : reject(new Error(`Hochladen fehlgeschlagen (${xhr.status})`));
xhr.onerror = () => reject(new Error("Netzwerkfehler"));
xhr.open("PUT", presignedUrl);
xhr.setRequestHeader("Content-Type", contentType);
xhr.send(file);
});
setForm((f) => ({ ...f, storageKey: key, durationSecs }));
toast.success("Track hochgeladen");
toast.success("Titel hochgeladen");
} catch {
toast.error("Upload fehlgeschlagen — bitte erneut versuchen");
} finally {
@@ -200,21 +201,24 @@ export default function AdminMusicPage() {
const isPending = createTrack.isPending || updateTrack.isPending;
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<h1 className="text-2xl font-bold text-foreground">Musik-Katalog</h1>
<Button size="sm" onClick={openCreate} className="bg-orange-500 hover:bg-orange-600 text-white">
<Plus className="h-4 w-4 mr-1.5" />
Neuer Track
</Button>
</div>
<div className="mx-auto max-w-6xl space-y-6">
<AdminPageHeader
title="Musik-Katalog"
description="Lizenzierte Musik, die Halter unter ihre Storys legen können."
actions={
<Button size="sm" onClick={openCreate}>
<Plus className="h-4 w-4 mr-1.5" />
Neuer Titel
</Button>
}
/>
{isLoading ? (
<div className="flex justify-center py-12">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
) : tracks.length === 0 ? (
<p className="text-sm text-muted-foreground text-center py-12">Noch keine Tracks — oben hochladen</p>
<p className="text-sm text-muted-foreground text-center py-12">Noch keine Titel – oben rechts „Neuer Titel“ wählen.</p>
) : (
<div className="space-y-2">
{tracks.map((track) => (
@@ -235,9 +239,9 @@ export default function AdminMusicPage() {
<div className="flex items-center gap-2">
<p className="text-sm font-medium text-foreground truncate">{track.title}</p>
{track.active ? (
<Badge className="bg-green-700 text-green-100 text-[10px]">Aktiv</Badge>
<StatusBadge tone="success">Aktiv</StatusBadge>
) : (
<Badge variant="secondary" className="text-[10px]">Inaktiv</Badge>
<StatusBadge tone="neutral">Inaktiv</StatusBadge>
)}
</div>
<p className="text-xs text-muted-foreground truncate mt-0.5">
@@ -263,7 +267,7 @@ export default function AdminMusicPage() {
<Dialog open={dialogOpen} onOpenChange={(o) => { if (!o) closeDialog(); }}>
<DialogContent className="bg-card border-border text-foreground max-w-md">
<DialogHeader>
<DialogTitle>{editingId ? "Track bearbeiten" : "Track hochladen"}</DialogTitle>
<DialogTitle>{editingId ? "Titel bearbeiten" : "Titel hochladen"}</DialogTitle>
</DialogHeader>
<div className="space-y-3">
@@ -354,7 +358,7 @@ export default function AdminMusicPage() {
!form.licenseNote.trim() ||
(!editingId && !form.storageKey)
}
className="bg-orange-500 hover:bg-orange-600 text-white"
>
{isPending ? (
<Loader2 className="h-4 w-4 animate-spin mr-2" />
+5 -7
View File
@@ -5,6 +5,7 @@ import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
import { useSearchParams } from "next/navigation";
import { BadgeCheck, Loader2, Search, Sprout } from "lucide-react";
import { useTRPC } from "@/trpc/client";
import { AdminPageHeader } from "@/components/admin/AdminSection";
import { useDebounce } from "@/hooks/use-debounce";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
@@ -21,7 +22,7 @@ const FILTERS: { value: Filter; label: string }[] = [
{ value: "verified", label: "Verifiziert" },
{ value: "founding", label: "Gründungsmitglied" },
{ value: "ranked", label: "Mit Empfehlungsrang" },
{ value: "bannedOwner", label: "Owner gesperrt" },
{ value: "bannedOwner", label: "Halter gesperrt" },
];
const SORTS: { value: Sort; label: string }[] = [
{ value: "newest", label: "Neueste zuerst" },
@@ -62,11 +63,8 @@ export default function AdminPetsPage() {
const pets = data?.pages.flatMap((page) => page.pets) ?? [];
return (
<div className="space-y-6">
<div>
<h1 className="text-2xl font-semibold">Tiere</h1>
<p className="text-sm text-muted-foreground">Jedes Tier einzeln verwalten: Abzeichen, Ränge des Owners, Inhalte, Löschen.</p>
</div>
<div className="mx-auto max-w-[1400px] space-y-6">
<AdminPageHeader title="Tiere" description="Jedes Tier einzeln verwalten: Abzeichen, Empfehlungsränge des Halters, Inhalte, Löschen." />
<div className="flex flex-wrap items-center gap-2">
<div className="relative min-w-[220px] flex-1">
@@ -150,7 +148,7 @@ export default function AdminPetsPage() {
<td className="px-3 py-2 text-right tabular-nums">{pet._count.posts}</td>
<td className="px-3 py-2 text-right tabular-nums">{pet._count.followers}</td>
<td className="px-3 py-2 text-muted-foreground tabular-nums">{new Date(pet.createdAt).toLocaleDateString("de-DE")}</td>
<td className="px-3 py-2">{isOwnerBanned && <Badge variant="destructive">Owner gesperrt</Badge>}</td>
<td className="px-3 py-2">{isOwnerBanned && <Badge variant="destructive">Halter gesperrt</Badge>}</td>
</tr>
);
})}
+134 -165
View File
@@ -1,13 +1,14 @@
"use client";
import { useEffect, useState } from "react";
import { useState, useSyncExternalStore } from "react";
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { Trash2, MessageSquare, Loader2, ChevronDown, Play, ImageOff, PawPrint, EyeOff, Eye, Sparkles, Pin, PinOff, Hash, HelpCircle } from "lucide-react";
import { Trash2, MessageSquare, Loader2, ChevronDown, Play, ImageOff, PawPrint, EyeOff, Eye, Sparkles, Pin, PinOff, Hash, MoreHorizontal, Flag, Search, Repeat2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { AdminPageHeader } from "@/components/admin/AdminSection";
import { getMediaUrl } from "@/lib/media-url";
import { BlurImage } from "@/components/ui/blur-image";
import { MILESTONE_META } from "@/lib/milestone-meta";
@@ -27,35 +28,38 @@ const GRID_COLS_CLASS: Record<GridSize, string> = {
const GRID_SIZE_STORAGE_KEY = "pawfeed-admin-posts-grid-size";
const POST_ACTION_LEGEND: { icon: React.ElementType; label: string; tone?: string }[] = [
{ icon: MessageSquare, label: "View comments" },
{ icon: EyeOff, label: "Hide post" },
{ icon: Eye, label: "Unhide post" },
{ icon: Pin, label: "Pin post" },
{ icon: PinOff, label: "Unpin post" },
{ icon: Sparkles, label: "Correct AI-content disclosure" },
{ icon: Trash2, label: "Delete post", tone: "text-destructive" },
];
const DEFAULT_GRID_SIZE: GridSize = 3;
const GRID_SIZE_EVENT = "pawfeed-admin-grid-size";
/** Spaltenzahl aus localStorage — als externer Store gelesen (kein setState im Effect, kein SSR-Zugriff). */
function useGridSize(): [GridSize, (size: GridSize) => void] {
const size = useSyncExternalStore(
(onChange) => {
window.addEventListener(GRID_SIZE_EVENT, onChange);
window.addEventListener("storage", onChange);
return () => {
window.removeEventListener(GRID_SIZE_EVENT, onChange);
window.removeEventListener("storage", onChange);
};
},
() => {
const stored = Number(window.localStorage.getItem(GRID_SIZE_STORAGE_KEY));
return GRID_SIZES.includes(stored as GridSize) ? (stored as GridSize) : DEFAULT_GRID_SIZE;
},
() => DEFAULT_GRID_SIZE
);
const setSize = (next: GridSize) => {
window.localStorage.setItem(GRID_SIZE_STORAGE_KEY, String(next));
window.dispatchEvent(new Event(GRID_SIZE_EVENT));
};
return [size, setSize];
}
export default function AdminPostsPage() {
const trpc = useTRPC();
const qc = useQueryClient();
const [search, setSearch] = useState("");
const [gridSize, setGridSize] = useState<GridSize>(3);
// Reads the persisted choice after mount (SSR has no localStorage access —
// same pattern as ActivePetContext, a brief default-then-update on first paint).
useEffect(() => {
const stored = Number(window.localStorage.getItem(GRID_SIZE_STORAGE_KEY));
if (GRID_SIZES.includes(stored as GridSize)) {
setGridSize(stored as GridSize);
}
}, []);
function handleGridSizeChange(size: GridSize) {
setGridSize(size);
window.localStorage.setItem(GRID_SIZE_STORAGE_KEY, String(size));
}
const [gridSize, handleGridSizeChange] = useGridSize();
const [commentsPostId, setCommentsPostId] = useState<string | null>(null);
const [deleteTarget, setDeleteTarget] = useState<{ id: string; type: "post" | "comment" } | null>(null);
const [hideTargetId, setHideTargetId] = useState<string | null>(null);
@@ -169,32 +173,23 @@ export default function AdminPostsPage() {
}
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<h1 className="text-2xl font-bold text-foreground">Beiträge</h1>
<Popover>
<PopoverTrigger
aria-label="What do the buttons do?"
className="flex h-6 w-6 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
>
<HelpCircle className="h-4 w-4" />
</PopoverTrigger>
<PopoverContent align="start" className="w-64">
<p className="text-xs font-semibold text-muted-foreground mb-1">Post actions</p>
<ul className="space-y-2">
{POST_ACTION_LEGEND.map(({ icon: Icon, label, tone }) => (
<li key={label} className="flex items-center gap-2.5 text-xs text-foreground">
<Icon className={cn("h-3.5 w-3.5 shrink-0", tone ?? "text-muted-foreground")} aria-hidden="true" />
{label}
</li>
))}
</ul>
</PopoverContent>
</Popover>
<div className="mx-auto max-w-[1400px] space-y-6">
<AdminPageHeader title="Beiträge" description="Alle Beiträge der Plattform – ausblenden, anpinnen, KI-Kennzeichnung korrigieren oder löschen." />
<div className="flex flex-col gap-2 sm:flex-row sm:items-center">
<div className="relative flex-1">
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
<input
type="search"
placeholder="Bildtext oder Tiername suchen …"
aria-label="Beiträge suchen"
value={search}
onChange={(e) => setSearch(e.target.value)}
className="h-9 w-full rounded-lg border border-input bg-card pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/30"
/>
</div>
<div className="flex items-center gap-3">
<div className="flex items-center gap-0.5 rounded-lg border border-border p-0.5">
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">Spalten</span>
<div className="flex items-center gap-0.5 rounded-lg border border-border bg-card p-0.5" role="group" aria-label="Spalten im Raster">
{GRID_SIZES.map((size) => (
<button
key={size}
@@ -202,30 +197,22 @@ export default function AdminPostsPage() {
onClick={() => handleGridSizeChange(size)}
aria-pressed={gridSize === size}
className={cn(
"rounded-md px-2.5 py-1 text-xs font-medium transition-colors",
gridSize === size
? "bg-secondary text-foreground"
: "text-muted-foreground hover:text-foreground"
"cursor-pointer rounded-md px-2.5 py-1 text-xs font-medium transition-colors",
gridSize === size ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground"
)}
>
{size}
</button>
))}
</div>
<Input
placeholder="Search caption or pet name…"
value={search}
onChange={(e) => setSearch(e.target.value)}
className="w-64 bg-card border-border text-foreground placeholder:text-muted-foreground"
/>
</div>
</div>
{trending && trending.hashtags.length > 0 && (
<div className="flex flex-wrap items-center gap-2 rounded-xl border border-border bg-card px-4 py-3">
<div className="flex flex-wrap items-center gap-2 rounded-2xl border border-border bg-card px-4 py-3">
<span className="flex items-center gap-1.5 text-xs font-medium text-muted-foreground">
<Hash className="h-3.5 w-3.5" aria-hidden="true" />
Trending (7d):
Trends (7 Tage):
</span>
{trending.hashtags.map((h) => (
<span
@@ -267,14 +254,14 @@ export default function AdminPostsPage() {
return (
<div
key={post.id}
className="flex flex-col rounded-xl border border-border bg-card overflow-hidden"
className="flex flex-col overflow-hidden rounded-2xl border border-border bg-card"
>
<div className="relative aspect-square overflow-hidden bg-muted shrink-0">
{mediaUrl ? (
<BlurImage
src={mediaUrl}
blurhash={thumb?.blurhash}
alt={displayCaption ?? "Post"}
alt={displayCaption ?? "Beitrag"}
className="h-full w-full object-cover"
/>
) : milestoneMeta && MilestoneIcon ? (
@@ -296,13 +283,13 @@ export default function AdminPostsPage() {
<div className="absolute inset-0 flex items-center justify-center bg-black/60">
<span className="flex items-center gap-1.5 rounded-full bg-card/90 px-2.5 py-1 text-xs font-medium text-foreground">
<EyeOff className="h-3.5 w-3.5" aria-hidden="true" />
Hidden
Ausgeblendet
</span>
</div>
)}
{post.pinnedAt && (
<div className="absolute top-2 left-2 rounded-full bg-orange-500/90 p-1">
<Pin className="h-3.5 w-3.5 text-white fill-white" aria-hidden="true" />
<div className="absolute top-2 left-2 rounded-full bg-primary p-1" title="Angepinnt">
<Pin className="h-3.5 w-3.5 fill-current text-primary-foreground" aria-label="Angepinnt" />
</div>
)}
<AiDisclosureBadge value={post.aiDisclosure} />
@@ -311,91 +298,73 @@ export default function AdminPostsPage() {
<div className="flex flex-1 flex-col gap-2 p-3">
{post.type === "REPOST" && originalPost && (
<p className="flex items-center gap-1.5 text-xs text-primary">
<PawPrint className="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
Repost of {originalPost.pet.name}
<Repeat2 className="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
Geteilt von {originalPost.pet.name}
</p>
)}
<p className="text-sm text-foreground line-clamp-2 min-h-[2.5rem]">
{displayCaption ?? <em className="text-muted-foreground">No caption</em>}
{displayCaption ?? <em className="text-muted-foreground">Ohne Bildtext</em>}
</p>
<p className="text-xs text-muted-foreground">
{post.pet.name} · {post.reactionCount} 🐾 · {post.commentCount} 💬
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
<span className="font-medium text-foreground">{post.pet.name}</span>
<span className="inline-flex items-center gap-0.5" title="Pfoten">
<PawPrint className="h-3 w-3" aria-hidden /> {post.reactionCount}
</span>
<span className="inline-flex items-center gap-0.5" title="Kommentare">
<MessageSquare className="h-3 w-3" aria-hidden /> {post.commentCount}
</span>
{post.reportCount > 0 && (
<span className="ml-2 text-warning">
⚑ {post.reportCount} report{post.reportCount !== 1 ? "s" : ""}
<span className="inline-flex items-center gap-0.5 font-semibold text-warning">
<Flag className="h-3 w-3" aria-hidden /> {post.reportCount} {post.reportCount === 1 ? "Meldung" : "Meldungen"}
</span>
)}
</p>
<div className="mt-auto flex justify-end gap-2 pt-1">
<Button
size="sm"
variant="ghost"
className="text-muted-foreground hover:text-foreground"
onClick={() => setCommentsPostId(post.id)}
>
<MessageSquare className="h-4 w-4" />
<div className="mt-auto flex items-center justify-between gap-2 pt-1">
<Button size="sm" variant="outline" onClick={() => setCommentsPostId(post.id)}>
<MessageSquare className="mr-1.5 h-4 w-4" aria-hidden />
Kommentare
</Button>
{post.hiddenAt ? (
<Button
size="sm"
variant="ghost"
className="text-muted-foreground hover:text-foreground"
disabled={unhidePost.isPending}
onClick={() => unhidePost.mutate({ postId: post.id })}
<DropdownMenu>
<DropdownMenuTrigger
aria-label={`Aktionen für den Beitrag von ${post.pet.name}`}
className="grid h-8 w-8 cursor-pointer place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
>
<Eye className="h-4 w-4" />
</Button>
) : (
<Button
size="sm"
variant="ghost"
className="text-muted-foreground hover:text-foreground"
onClick={() => setHideTargetId(post.id)}
>
<EyeOff className="h-4 w-4" />
</Button>
)}
{post.pinnedAt ? (
<Button
size="sm"
variant="ghost"
className="text-primary hover:opacity-80"
disabled={unpinPost.isPending}
onClick={() => unpinPost.mutate({ postId: post.id })}
>
<PinOff className="h-4 w-4" />
</Button>
) : (
<Button
size="sm"
variant="ghost"
className="text-muted-foreground hover:text-foreground"
disabled={pinPost.isPending}
onClick={() => pinPost.mutate({ postId: post.id })}
>
<Pin className="h-4 w-4" />
</Button>
)}
<Button
size="sm"
variant="ghost"
className="text-muted-foreground hover:text-foreground"
onClick={() => {
setAiTargetId(post.id);
setAiValue(post.aiDisclosure ?? "NONE");
setAiReason("");
}}
>
<Sparkles className="h-4 w-4" />
</Button>
<Button
size="sm"
variant="ghost"
className="text-destructive hover:opacity-80"
onClick={() => setDeleteTarget({ id: post.id, type: "post" })}
>
<Trash2 className="h-4 w-4" />
</Button>
<MoreHorizontal className="h-4 w-4" aria-hidden />
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-60">
{post.hiddenAt ? (
<DropdownMenuItem disabled={unhidePost.isPending} onClick={() => unhidePost.mutate({ postId: post.id })}>
<Eye aria-hidden /> Wieder einblenden
</DropdownMenuItem>
) : (
<DropdownMenuItem onClick={() => setHideTargetId(post.id)}>
<EyeOff aria-hidden /> Ausblenden …
</DropdownMenuItem>
)}
{post.pinnedAt ? (
<DropdownMenuItem disabled={unpinPost.isPending} onClick={() => unpinPost.mutate({ postId: post.id })}>
<PinOff aria-hidden /> Nicht mehr anpinnen
</DropdownMenuItem>
) : (
<DropdownMenuItem disabled={pinPost.isPending} onClick={() => pinPost.mutate({ postId: post.id })}>
<Pin aria-hidden /> Anpinnen
</DropdownMenuItem>
)}
<DropdownMenuItem
onClick={() => {
setAiTargetId(post.id);
setAiValue(post.aiDisclosure ?? "NONE");
setAiReason("");
}}
>
<Sparkles aria-hidden /> KI-Kennzeichnung korrigieren …
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive" onClick={() => setDeleteTarget({ id: post.id, type: "post" })}>
<Trash2 aria-hidden /> Beitrag löschen …
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>
@@ -410,14 +379,13 @@ export default function AdminPostsPage() {
size="sm"
onClick={() => void fetchNextPage()}
disabled={isFetchingNextPage}
className="bg-card border-border text-foreground hover:bg-muted hover:text-foreground"
>
{isFetchingNextPage ? (
<Loader2 className="h-4 w-4 animate-spin mr-2" />
) : (
<ChevronDown className="h-4 w-4 mr-2" />
)}
Load more
Weitere laden
</Button>
</div>
)}
@@ -431,11 +399,11 @@ export default function AdminPostsPage() {
>
<DialogContent className="bg-card border-border text-foreground max-w-lg">
<DialogHeader>
<DialogTitle>Comments</DialogTitle>
<DialogTitle>Kommentare</DialogTitle>
</DialogHeader>
<div className="space-y-2 max-h-72 overflow-y-auto pr-1">
{(comments ?? []).length === 0 && (
<p className="text-sm text-muted-foreground text-center py-4">No comments</p>
<p className="text-sm text-muted-foreground text-center py-4">Keine Kommentare</p>
)}
{(comments ?? []).map((c) => (
<div
@@ -451,6 +419,7 @@ export default function AdminPostsPage() {
variant="ghost"
className="text-destructive hover:opacity-80 shrink-0"
onClick={() => setDeleteTarget({ id: c.id, type: "comment" })}
aria-label={`Kommentar von ${c.pet.name} löschen`}
>
<Trash2 className="h-4 w-4" />
</Button>
@@ -467,20 +436,20 @@ export default function AdminPostsPage() {
>
<DialogContent className="bg-card border-border text-foreground max-w-sm">
<DialogHeader>
<DialogTitle>Confirm deletion</DialogTitle>
<DialogTitle>{deleteTarget?.type === "comment" ? "Kommentar löschen" : "Beitrag löschen"}</DialogTitle>
</DialogHeader>
<p className="text-sm text-muted-foreground">
Delete this {deleteTarget?.type}? This action cannot be undone.
{deleteTarget?.type === "comment" ? "Diesen Kommentar" : "Diesen Beitrag"} endgültig löschen? Das lässt sich nicht rückgängig machen.
</p>
<Input
placeholder="Reason (optional)"
placeholder="Grund (optional, fürs Protokoll)"
value={reason}
onChange={(e) => setReason(e.target.value)}
className="bg-muted border-border text-foreground placeholder:text-muted-foreground"
/>
<DialogFooter className="gap-2">
<Button variant="ghost" className="text-muted-foreground" onClick={() => setDeleteTarget(null)}>
Cancel
Abbrechen
</Button>
<Button
variant="destructive"
@@ -490,7 +459,7 @@ export default function AdminPostsPage() {
{(deletePost.isPending || deleteComment.isPending) && (
<Loader2 className="h-4 w-4 animate-spin mr-2" />
)}
Delete
Löschen
</Button>
</DialogFooter>
</DialogContent>
@@ -503,28 +472,28 @@ export default function AdminPostsPage() {
>
<DialogContent className="bg-card border-border text-foreground max-w-sm">
<DialogHeader>
<DialogTitle>Hide post</DialogTitle>
<DialogTitle>Beitrag ausblenden</DialogTitle>
</DialogHeader>
<p className="text-sm text-muted-foreground">
Hides the post everywhere (feed, explore, profile, search, hashtags) without
deleting it — reversible via the eye icon.
Blendet den Beitrag überall aus (Feed, Explore, Profil, Suche, Hashtags), ohne ihn zu
löschen – über „Wieder einblenden“ rückgängig zu machen.
</p>
<Input
placeholder="Reason (required)"
placeholder="Grund (Pflicht)"
value={hideReason}
onChange={(e) => setHideReason(e.target.value)}
className="bg-muted border-border text-foreground placeholder:text-muted-foreground"
/>
<DialogFooter className="gap-2">
<Button variant="ghost" className="text-muted-foreground" onClick={() => setHideTargetId(null)}>
Cancel
Abbrechen
</Button>
<Button
onClick={confirmHide}
disabled={hidePost.isPending || !hideReason.trim()}
>
{hidePost.isPending && <Loader2 className="h-4 w-4 animate-spin mr-2" />}
Hide
Ausblenden
</Button>
</DialogFooter>
</DialogContent>
@@ -537,29 +506,29 @@ export default function AdminPostsPage() {
>
<DialogContent className="bg-card border-border text-foreground max-w-sm">
<DialogHeader>
<DialogTitle>Correct AI-content disclosure</DialogTitle>
<DialogTitle>KI-Kennzeichnung korrigieren</DialogTitle>
</DialogHeader>
<p className="text-sm text-muted-foreground">
Owners cannot change this after posting — use this only to correct a forgotten
or incorrect disclosure. Requires a reason for the audit log.
Halter können das nach dem Posten nicht mehr ändern – nur nutzen, um eine vergessene
oder falsche Kennzeichnung zu korrigieren. Der Grund landet im Protokoll.
</p>
<AiDisclosureSelect value={aiValue} onChange={setAiValue} />
<Input
placeholder="Reason (required)"
placeholder="Grund (Pflicht)"
value={aiReason}
onChange={(e) => setAiReason(e.target.value)}
className="bg-muted border-border text-foreground placeholder:text-muted-foreground"
/>
<DialogFooter className="gap-2">
<Button variant="ghost" className="text-muted-foreground" onClick={() => setAiTargetId(null)}>
Cancel
Abbrechen
</Button>
<Button
onClick={confirmAiDisclosure}
disabled={setAiDisclosure.isPending || !aiReason.trim()}
>
{setAiDisclosure.isPending && <Loader2 className="h-4 w-4 animate-spin mr-2" />}
Save
Speichern
</Button>
</DialogFooter>
</DialogContent>
+7 -5
View File
@@ -47,7 +47,7 @@ export function PetDetailSheet({ petId, onClose }: { petId: string | null; onClo
</SheetTitle>
<p className="text-xs text-muted-foreground">
{pet.species.name}
{pet.breed && ` · ${pet.breed.name}`} · seit {new Date(pet.createdAt).toLocaleDateString("de-DE")}
{pet.breed && ` · ${pet.breed.name}`} · dabei seit {new Date(pet.createdAt).toLocaleDateString("de-DE")}
</p>
</div>
<Link href={`/pets/${pet.id}`} target="_blank" className="ml-auto text-muted-foreground hover:text-foreground" aria-label="Öffentliches Profil öffnen">
@@ -71,11 +71,13 @@ export function PetDetailSheet({ petId, onClose }: { petId: string | null; onClo
</dl>
<section className="space-y-1 text-sm">
<h3 className="font-semibold">Owner</h3>
<p className="font-mono text-xs break-all text-muted-foreground">{pet.owner.id}</p>
<h3 className="font-semibold">Halter</h3>
<p className="font-medium">{data.ownerContact.name ?? data.ownerContact.email ?? "Unbekannt"}</p>
{data.ownerContact.name && data.ownerContact.email && <p className="text-xs text-muted-foreground">{data.ownerContact.email}</p>}
<p className="text-xs text-muted-foreground">
Empfehlungscode {pet.owner.referralCode ?? "–"} · {pet.owner._count.pets} Tier(e)
Empfehlungscode {pet.owner.referralCode ?? "–"} · {pet.owner._count.pets === 1 ? "1 Tier" : `${pet.owner._count.pets} Tiere`}
</p>
<p className="break-all font-mono text-[11px] text-muted-foreground/80">{pet.owner.id}</p>
{pet.owner.ban && <Badge variant="destructive">Gesperrt: {pet.owner.ban.reason ?? "ohne Grund"}</Badge>}
{pet.owner.shadowban && <Badge variant="secondary">Shadowban</Badge>}
</section>
@@ -102,7 +104,7 @@ export function PetDetailSheet({ petId, onClose }: { petId: string | null; onClo
) : (
<span className="flex h-full items-center justify-center p-1 text-center text-muted-foreground">{post.type}</span>
)}
{post.hiddenAt && <span className="absolute left-1 top-1 rounded bg-black/70 px-1 text-white">versteckt</span>}
{post.hiddenAt && <span className="absolute left-1 top-1 rounded bg-black/70 px-1 text-white">ausgeblendet</span>}
</div>
);
})}
@@ -22,11 +22,11 @@ const FIELDS = [
{ key: "avatar", label: "Profilbild" },
{ key: "bio", label: "Bio" },
{ key: "adoptionStory", label: "Adoptionsgeschichte" },
{ key: "nickname", label: "Spitzname" },
{ key: "nickname", label: "Rufname" },
] as const;
type FieldKey = (typeof FIELDS)[number]["key"];
const NOTIFIED_LABEL = { dm: "Owner per Direktnachricht informiert.", email: "Owner per E-Mail informiert.", none: "Owner nicht benachrichtigt." };
const NOTIFIED_LABEL = { dm: "Halter per Direktnachricht informiert.", email: "Halter per E-Mail informiert.", none: "Halter nicht benachrichtigt." };
type Props = { petId: string; petName: string; onChanged: () => void; onDeleted: () => void };
@@ -80,12 +80,12 @@ export function PetModerationSection({ petId, petName, onChanged, onDeleted }: P
onChange={(e) => setReason(e.target.value)}
maxLength={500}
rows={2}
placeholder="Begründung (Pflicht) — geht an den Owner, wenn benachrichtigt wird"
placeholder="Begründung (Pflicht) – geht an den Halter, wenn benachrichtigt wird"
aria-label="Begründung für die Moderation"
/>
<label className="flex items-center gap-2 text-sm">
<input type="checkbox" checked={notifyOwner} onChange={(e) => setNotifyOwner(e.target.checked)} className="accent-orange-500" />
Owner mit Begründung benachrichtigen (Direktnachricht vom „PawFeed Team“)
<input type="checkbox" checked={notifyOwner} onChange={(e) => setNotifyOwner(e.target.checked)} className="accent-[var(--primary)]" />
Halter mit Begründung benachrichtigen (Direktnachricht vom „PawFeed Team“)
</label>
<div className="space-y-2 rounded-lg border p-3">
@@ -93,7 +93,7 @@ export function PetModerationSection({ petId, petName, onChanged, onDeleted }: P
<div className="flex flex-wrap gap-3">
{FIELDS.map((field) => (
<label key={field.key} className="flex items-center gap-1.5 text-sm">
<input type="checkbox" checked={fields.has(field.key)} onChange={() => toggle(field.key)} className="accent-orange-500" />
<input type="checkbox" checked={fields.has(field.key)} onChange={() => toggle(field.key)} className="accent-[var(--primary)]" />
{field.label}
</label>
))}
@@ -111,7 +111,7 @@ export function PetModerationSection({ petId, petName, onChanged, onDeleted }: P
<div className="space-y-2 rounded-lg border border-destructive/40 p-3">
<p className="text-sm font-medium text-destructive">Tier endgültig löschen</p>
<p className="text-xs text-muted-foreground">
Löscht Beiträge, Storys, Follows, Pfoten, Kommentare und Nachrichten des Tiers samt Bildern und Videos. Der Owner-Account bleibt.
Löscht Beiträge, Storys, Follows, Pfoten, Kommentare und Nachrichten des Tiers samt Bildern und Videos. Das Konto des Halters bleibt bestehen.
War es sein einziges Tier, geht die Begründung per E-Mail an ihn.
</p>
<Button size="sm" variant="destructive" disabled={!trimmed || remove.isPending} onClick={() => setConfirmDelete(true)}>
+1 -1
View File
@@ -54,7 +54,7 @@ export function PetRankSection({ ownerId, ownerPetCount, qualifiedCount, ranks,
<div>
<h3 className="font-semibold">Empfehlungsrang</h3>
<p className="text-xs text-amber-700 dark:text-warning">
Gilt für den Owner, also für {ownerPetCount === 1 ? "sein einziges Tier" : `alle ${ownerPetCount} Tiere`}. {qualifiedCount} gezählte
Gilt für den Halter, also für {ownerPetCount === 1 ? "das einzige Tier" : `alle ${ownerPetCount} Tiere`}. {qualifiedCount} gezählte
Einladungen.
</p>
</div>
+21 -5
View File
@@ -10,6 +10,7 @@ import { deleteFiles } from "@/lib/supabase-storage";
import { ensureTeamPet, sendTeamMessage } from "@/lib/team-pet";
import { sendMail } from "@/lib/mail";
import { buildGreeting, renderBrandedMailHtml } from "@/lib/mail-template";
import { germanNameSelect, withGermanName } from "@/lib/admin/taxonomy-name";
/**
* Admin-Seite „Tiere“ (/p/[secret]/pets): Liste aller Tiere mit Suche/Filter,
@@ -89,7 +90,7 @@ export const petAdminRouter = router({
isFoundingMember: true,
createdAt: true,
ownerId: true,
species: { select: { name: true } },
species: { select: germanNameSelect },
owner: {
select: {
referralRankId: true,
@@ -108,7 +109,7 @@ export const petAdminRouter = router({
},
});
const hasNext = pets.length > PAGE_SIZE;
const items = hasNext ? pets.slice(0, PAGE_SIZE) : pets;
const items = (hasNext ? pets.slice(0, PAGE_SIZE) : pets).map((p) => ({ ...p, species: withGermanName(p.species) }));
return { pets: items, nextCursor: hasNext ? items[items.length - 1]!.id : null };
}),
@@ -126,8 +127,8 @@ export const petAdminRouter = router({
isVerified: true,
isFoundingMember: true,
createdAt: true,
species: { select: { name: true } },
breed: { select: { name: true } },
species: { select: germanNameSelect },
breed: { select: germanNameSelect },
_count: { select: { posts: true, followers: true, following: true, stories: true } },
posts: {
orderBy: { createdAt: "desc" },
@@ -170,7 +171,22 @@ export const petAdminRouter = router({
orderBy: { threshold: "asc" },
select: { id: true, nameDe: true, threshold: true, icon: true, color: true, isActive: true },
});
return { pet, ranks };
// Halter mit Name/E-Mail statt nur Clerk-ID; Clerk nicht erreichbar → Felder bleiben leer.
let ownerContact: { name: string | null; email: string | null } = { name: null, email: null };
try {
const user = await (await clerkClient()).users.getUser(pet.owner.id);
ownerContact = {
name: [user.firstName, user.lastName].filter(Boolean).join(" ") || null,
email: user.emailAddresses.find((e) => e.id === user.primaryEmailAddressId)?.emailAddress ?? null,
};
} catch {
// Detailansicht soll auch ohne Clerk funktionieren.
}
return {
pet: { ...pet, species: withGermanName(pet.species), breed: pet.breed ? withGermanName(pet.breed) : null },
ranks,
ownerContact,
};
}),
/**