i18n events/polls detail pages, forms, and empty sections.

Align detail headers with admin chrome, translate stats/forms/breadcrumbs, and use admin-empty for prizes, winners, registrations, and questions.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-18 21:46:52 +02:00
1 parent dd9c5e70c2
commit a25008deb5
12 files changed
+325 -91

No files matched your search

+5 -5
View File
@@ -1,6 +1,7 @@
"use client"; "use client";
import { Plus, Trash2 } from "lucide-react"; import { Plus, Trash2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { useState } from "react"; import { useState } from "react";
import { addEventPrize, deleteEventPrize } from "@/actions/events"; import { addEventPrize, deleteEventPrize } from "@/actions/events";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
@@ -38,6 +39,7 @@ interface Props {
} }
export function EventPrizesManager({ eventId, prizes }: Props) { export function EventPrizesManager({ eventId, prizes }: Props) {
const t = useTranslations("pages.admin.events");
const { run, isPending } = useServerAction(); const { run, isPending } = useServerAction();
const [showForm, setShowForm] = useState(false); const [showForm, setShowForm] = useState(false);
const [form, setForm] = useState<EventPrizeInput>({ const [form, setForm] = useState<EventPrizeInput>({
@@ -70,9 +72,9 @@ export function EventPrizesManager({ eventId, prizes }: Props) {
return ( return (
<Card> <Card>
<CardHeader className="flex flex-row items-center justify-between"> <CardHeader className="flex flex-row items-center justify-between">
<CardTitle>Prizes</CardTitle> <CardTitle>{t("statPrizes")}</CardTitle>
<Button size="sm" onClick={() => setShowForm(!showForm)}> <Button size="sm" onClick={() => setShowForm(!showForm)}>
<Plus className="h-4 w-4 mr-1" /> Add Prize <Plus className="h-4 w-4 mr-1" /> {t("addPrize")}
</Button> </Button>
</CardHeader> </CardHeader>
<CardContent className="space-y-4"> <CardContent className="space-y-4">
@@ -159,9 +161,7 @@ export function EventPrizesManager({ eventId, prizes }: Props) {
)} )}
{prizes.length === 0 && !showForm && ( {prizes.length === 0 && !showForm && (
<p className="text-sm text-muted-foreground text-center py-4"> <div className="admin-empty">{t("noPrizes")}</div>
No prizes configured yet.
</p>
)} )}
{prizes.map((prize) => ( {prizes.map((prize) => (
@@ -1,5 +1,6 @@
"use client"; "use client";
import { useTranslations } from "next-intl";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
interface Registration { interface Registration {
@@ -14,16 +15,18 @@ interface Props {
} }
export function EventRegistrations({ registrations }: Props) { export function EventRegistrations({ registrations }: Props) {
const t = useTranslations("pages.admin.events");
return ( return (
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>Registrations ({registrations.length})</CardTitle> <CardTitle>
{t("registrationsTitle", { count: registrations.length })}
</CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
{registrations.length === 0 ? ( {registrations.length === 0 ? (
<p className="text-sm text-muted-foreground text-center py-4"> <div className="admin-empty">{t("noRegistrations")}</div>
No registrations yet.
</p>
) : ( ) : (
<div className="divide-y max-h-[400px] overflow-y-auto"> <div className="divide-y max-h-[400px] overflow-y-auto">
{registrations.map((r) => ( {registrations.map((r) => (
+5 -5
View File
@@ -1,6 +1,7 @@
"use client"; "use client";
import { Plus } from "lucide-react"; import { Plus } from "lucide-react";
import { useTranslations } from "next-intl";
import { useState } from "react"; import { useState } from "react";
import { addEventWinner } from "@/actions/events"; import { addEventWinner } from "@/actions/events";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
@@ -23,6 +24,7 @@ interface Props {
} }
export function EventWinnersManager({ eventId, winners }: Props) { export function EventWinnersManager({ eventId, winners }: Props) {
const t = useTranslations("pages.admin.events");
const { run, isPending } = useServerAction(); const { run, isPending } = useServerAction();
const [showForm, setShowForm] = useState(false); const [showForm, setShowForm] = useState(false);
const [userId, setUserId] = useState(""); const [userId, setUserId] = useState("");
@@ -43,9 +45,9 @@ export function EventWinnersManager({ eventId, winners }: Props) {
return ( return (
<Card> <Card>
<CardHeader className="flex flex-row items-center justify-between"> <CardHeader className="flex flex-row items-center justify-between">
<CardTitle>Winners</CardTitle> <CardTitle>{t("statWinners")}</CardTitle>
<Button size="sm" onClick={() => setShowForm(!showForm)}> <Button size="sm" onClick={() => setShowForm(!showForm)}>
<Plus className="h-4 w-4 mr-1" /> Add Winner <Plus className="h-4 w-4 mr-1" /> {t("addWinner")}
</Button> </Button>
</CardHeader> </CardHeader>
<CardContent className="space-y-3"> <CardContent className="space-y-3">
@@ -80,9 +82,7 @@ export function EventWinnersManager({ eventId, winners }: Props) {
)} )}
{winners.length === 0 && !showForm && ( {winners.length === 0 && !showForm && (
<p className="text-sm text-muted-foreground text-center py-4"> <div className="admin-empty">{t("noWinners")}</div>
No winners yet.
</p>
)} )}
<div className="divide-y"> <div className="divide-y">
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+27 -7
View File
@@ -1,3 +1,4 @@
import { getTranslations } from "next-intl/server";
import { notFound, redirect } from "next/navigation"; import { notFound, redirect } from "next/navigation";
import { AdminBreadcrumb } from "@/components/admin/admin-breadcrumb"; import { AdminBreadcrumb } from "@/components/admin/admin-breadcrumb";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
@@ -22,6 +23,9 @@ export default async function PollDetailPage({
const pollId = parseInt(id, 10); const pollId = parseInt(id, 10);
if (Number.isNaN(pollId)) notFound(); if (Number.isNaN(pollId)) notFound();
const t = await getTranslations("pages.admin.polls");
const tHubs = await getTranslations("pages.admin.hubs");
const poll = await prisma.websitePoll.findUnique({ const poll = await prisma.websitePoll.findUnique({
where: { id: pollId }, where: { id: pollId },
include: { include: {
@@ -40,17 +44,25 @@ export default async function PollDetailPage({
poll.questions.flatMap((q) => q.votes.map((v) => v.userId)), poll.questions.flatMap((q) => q.votes.map((v) => v.userId)),
).size; ).size;
const statusLabel: Record<string, string> = {
active: t("statusActive"),
draft: t("statusDraft"),
closed: t("statusClosed"),
};
return ( return (
<div className="space-y-6"> <div className="space-y-6">
<div> <div>
<AdminBreadcrumb <AdminBreadcrumb
items={[ items={[
{ label: "Polls", href: "/admin/polls" }, { label: tHubs("tabs.polls"), href: "/admin/polls" },
{ label: poll.title }, { label: poll.title },
]} ]}
/> />
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<h1 className="text-3xl font-bold tracking-tight">{poll.title}</h1> <h1 className="m-0 text-2xl font-extrabold text-[var(--admin-text)]">
{poll.title}
</h1>
<Badge <Badge
variant={ variant={
poll.status === "active" poll.status === "active"
@@ -60,11 +72,13 @@ export default async function PollDetailPage({
: "secondary" : "secondary"
} }
> >
{poll.status} {statusLabel[poll.status] ?? poll.status}
</Badge> </Badge>
</div> </div>
{poll.description && ( {poll.description && (
<p className="text-muted-foreground">{poll.description}</p> <p className="m-0 mt-1 text-sm text-[var(--admin-text-muted)]">
{poll.description}
</p>
)} )}
</div> </div>
@@ -72,7 +86,9 @@ export default async function PollDetailPage({
<div className="grid gap-4 md:grid-cols-3"> <div className="grid gap-4 md:grid-cols-3">
<Card> <Card>
<CardHeader className="pb-2"> <CardHeader className="pb-2">
<CardTitle className="text-sm font-medium">Total Voters</CardTitle> <CardTitle className="text-sm font-medium">
{t("statVoters")}
</CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold">{totalVoters}</div> <div className="text-2xl font-bold">{totalVoters}</div>
@@ -80,7 +96,9 @@ export default async function PollDetailPage({
</Card> </Card>
<Card> <Card>
<CardHeader className="pb-2"> <CardHeader className="pb-2">
<CardTitle className="text-sm font-medium">Questions</CardTitle> <CardTitle className="text-sm font-medium">
{t("statQuestions")}
</CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold">{poll.questions.length}</div> <div className="text-2xl font-bold">{poll.questions.length}</div>
@@ -88,7 +106,9 @@ export default async function PollDetailPage({
</Card> </Card>
<Card> <Card>
<CardHeader className="pb-2"> <CardHeader className="pb-2">
<CardTitle className="text-sm font-medium">Total Votes</CardTitle> <CardTitle className="text-sm font-medium">
{t("statVotes")}
</CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold"> <div className="text-2xl font-bold">
+7 -5
View File
@@ -1,6 +1,7 @@
"use client"; "use client";
import { GripVertical, Pencil, Plus, Trash2 } from "lucide-react"; import { GripVertical, Pencil, Plus, Trash2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { useState } from "react"; import { useState } from "react";
import { import {
addPollQuestion, addPollQuestion,
@@ -37,6 +38,7 @@ interface Props {
type PollQuestionUpdateInput = PollQuestionInput & { id: number }; type PollQuestionUpdateInput = PollQuestionInput & { id: number };
export function PollQuestionsManager({ pollId, questions }: Props) { export function PollQuestionsManager({ pollId, questions }: Props) {
const t = useTranslations("pages.admin.polls");
const { run, isPending } = useServerAction(); const { run, isPending } = useServerAction();
const [showForm, setShowForm] = useState(false); const [showForm, setShowForm] = useState(false);
const [editingId, setEditingId] = useState<number | null>(null); const [editingId, setEditingId] = useState<number | null>(null);
@@ -96,7 +98,9 @@ export function PollQuestionsManager({ pollId, questions }: Props) {
return ( return (
<Card> <Card>
<CardHeader className="flex flex-row items-center justify-between"> <CardHeader className="flex flex-row items-center justify-between">
<CardTitle>Questions ({questions.length})</CardTitle> <CardTitle>
{t("questionsTitle", { count: questions.length })}
</CardTitle>
<Button <Button
size="sm" size="sm"
onClick={() => { onClick={() => {
@@ -104,7 +108,7 @@ export function PollQuestionsManager({ pollId, questions }: Props) {
setShowForm(!showForm); setShowForm(!showForm);
}} }}
> >
<Plus className="h-4 w-4 mr-1" /> Add Question <Plus className="h-4 w-4 mr-1" /> {t("addQuestion")}
</Button> </Button>
</CardHeader> </CardHeader>
<CardContent className="space-y-4"> <CardContent className="space-y-4">
@@ -177,9 +181,7 @@ export function PollQuestionsManager({ pollId, questions }: Props) {
)} )}
{questions.length === 0 && !showForm && ( {questions.length === 0 && !showForm && (
<p className="text-sm text-muted-foreground text-center py-4"> <div className="admin-empty">{t("noQuestions")}</div>
No questions yet. Add your first question above.
</p>
)} )}
<div className="space-y-2"> <div className="space-y-2">
+4 -1
View File
@@ -1,5 +1,6 @@
"use client"; "use client";
import { useTranslations } from "next-intl";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
interface QuestionResult { interface QuestionResult {
@@ -14,10 +15,12 @@ interface Props {
} }
export function PollResultsView({ questions }: Props) { export function PollResultsView({ questions }: Props) {
const t = useTranslations("pages.admin.polls");
return ( return (
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>Results</CardTitle> <CardTitle>{t("resultsTitle")}</CardTitle>
</CardHeader> </CardHeader>
<CardContent className="space-y-6"> <CardContent className="space-y-6">
{questions.map((q) => { {questions.map((q) => {
File diff suppressed because it is too large. Load diff
+59 -2
View File
@@ -849,7 +849,42 @@
"statusPublished": "Published", "statusPublished": "Published",
"statusDraft": "Draft", "statusDraft": "Draft",
"statusCancelled": "Cancelled", "statusCancelled": "Cancelled",
"statusCompleted": "Completed" "statusCompleted": "Completed",
"statRegistrations": "Registrations",
"statPrizes": "Prizes",
"statWinners": "Winners",
"statTime": "Time",
"maxPlayers": "Max: {count}",
"timeUpcoming": "Upcoming",
"timePast": "Past",
"endsAt": "Ends: {date}",
"userFallback": "User #{id}",
"registrationsTitle": "Registrations ({count})",
"noRegistrations": "No registrations yet.",
"noPrizes": "No prizes configured yet.",
"noWinners": "No winners yet.",
"addPrize": "Add prize",
"addWinner": "Add winner",
"formEditTitle": "Edit event",
"formDetailsTitle": "Event details",
"formTitle": "Title",
"formEventType": "Event type",
"formSelectType": "Select type",
"formDescription": "Description",
"formStartsAt": "Starts at",
"formEndsAt": "Ends at",
"formSelectStart": "Select start date",
"formSelectEnd": "Select end date",
"formMaxPlayers": "Max players",
"formUnlimited": "Unlimited",
"formRoomId": "Room ID",
"formOptional": "Optional",
"formImageUrl": "Image URL",
"formSaving": "Saving…",
"formUpdate": "Update event",
"formCreate": "Create event",
"toastUpdated": "Event updated!",
"toastCreated": "Event created!"
}, },
"polls": { "polls": {
"newPoll": "+ New poll", "newPoll": "+ New poll",
@@ -866,7 +901,29 @@
"statusDraft": "Draft", "statusDraft": "Draft",
"statusClosed": "Closed", "statusClosed": "Closed",
"typeMultiple": "Multiple choice", "typeMultiple": "Multiple choice",
"typeSingle": "Single choice" "typeSingle": "Single choice",
"statVoters": "Total voters",
"statQuestions": "Questions",
"statVotes": "Total votes",
"questionsTitle": "Questions ({count})",
"addQuestion": "Add question",
"noQuestions": "No questions yet. Add your first question above.",
"resultsTitle": "Results",
"formEditTitle": "Edit poll",
"formDetailsTitle": "Poll details",
"formTitle": "Title",
"formDescription": "Description",
"formStartsAt": "Starts at",
"formEndsAt": "Ends at",
"formSelectStart": "Select start date",
"formSelectEnd": "Select end date",
"formShowResults": "Show results to voters",
"formAllowMultiple": "Allow multiple answers",
"formSaving": "Saving…",
"formUpdate": "Update poll",
"formCreate": "Create poll",
"toastUpdated": "Poll updated!",
"toastCreated": "Poll created!"
}, },
"multiAccounts": { "multiAccounts": {
"minAccounts": "Min accounts per cluster", "minAccounts": "Min accounts per cluster",
+59 -2
View File
@@ -813,7 +813,42 @@
"statusPublished": "Pubblicato", "statusPublished": "Pubblicato",
"statusDraft": "Bozza", "statusDraft": "Bozza",
"statusCancelled": "Annullato", "statusCancelled": "Annullato",
"statusCompleted": "Completato" "statusCompleted": "Completato",
"statRegistrations": "Iscrizioni",
"statPrizes": "Premi",
"statWinners": "Vincitori",
"statTime": "Orario",
"maxPlayers": "Max: {count}",
"timeUpcoming": "In arrivo",
"timePast": "Passato",
"endsAt": "Fine: {date}",
"userFallback": "Utente #{id}",
"registrationsTitle": "Iscrizioni ({count})",
"noRegistrations": "Nessuna iscrizione ancora.",
"noPrizes": "Nessun premio configurato.",
"noWinners": "Nessun vincitore ancora.",
"addPrize": "Aggiungi premio",
"addWinner": "Aggiungi vincitore",
"formEditTitle": "Modifica evento",
"formDetailsTitle": "Dettagli evento",
"formTitle": "Titolo",
"formEventType": "Tipo evento",
"formSelectType": "Seleziona tipo",
"formDescription": "Descrizione",
"formStartsAt": "Inizio",
"formEndsAt": "Fine",
"formSelectStart": "Seleziona data di inizio",
"formSelectEnd": "Seleziona data di fine",
"formMaxPlayers": "Max giocatori",
"formUnlimited": "Illimitato",
"formRoomId": "ID stanza",
"formOptional": "Opzionale",
"formImageUrl": "URL immagine",
"formSaving": "Salvataggio…",
"formUpdate": "Aggiorna evento",
"formCreate": "Crea evento",
"toastUpdated": "Evento aggiornato!",
"toastCreated": "Evento creato!"
}, },
"polls": { "polls": {
"newPoll": "+ Nuovo sondaggio", "newPoll": "+ Nuovo sondaggio",
@@ -830,7 +865,29 @@
"statusDraft": "Bozza", "statusDraft": "Bozza",
"statusClosed": "Chiuso", "statusClosed": "Chiuso",
"typeMultiple": "Scelta multipla", "typeMultiple": "Scelta multipla",
"typeSingle": "Scelta singola" "typeSingle": "Scelta singola",
"statVoters": "Votanti totali",
"statQuestions": "Domande",
"statVotes": "Voti totali",
"questionsTitle": "Domande ({count})",
"addQuestion": "Aggiungi domanda",
"noQuestions": "Nessuna domanda ancora. Aggiungi la prima sopra.",
"resultsTitle": "Risultati",
"formEditTitle": "Modifica sondaggio",
"formDetailsTitle": "Dettagli sondaggio",
"formTitle": "Titolo",
"formDescription": "Descrizione",
"formStartsAt": "Inizio",
"formEndsAt": "Fine",
"formSelectStart": "Seleziona data di inizio",
"formSelectEnd": "Seleziona data di fine",
"formShowResults": "Mostra risultati ai votanti",
"formAllowMultiple": "Consenti risposte multiple",
"formSaving": "Salvataggio…",
"formUpdate": "Aggiorna sondaggio",
"formCreate": "Crea sondaggio",
"toastUpdated": "Sondaggio aggiornato!",
"toastCreated": "Sondaggio creato!"
}, },
"multiAccounts": { "multiAccounts": {
"minAccounts": "Min. account per cluster", "minAccounts": "Min. account per cluster",
+59 -2
View File
@@ -849,7 +849,42 @@
"statusPublished": "Gepubliceerd", "statusPublished": "Gepubliceerd",
"statusDraft": "Concept", "statusDraft": "Concept",
"statusCancelled": "Geannuleerd", "statusCancelled": "Geannuleerd",
"statusCompleted": "Voltooid" "statusCompleted": "Voltooid",
"statRegistrations": "Inschrijvingen",
"statPrizes": "Prijzen",
"statWinners": "Winnaars",
"statTime": "Tijd",
"maxPlayers": "Max: {count}",
"timeUpcoming": "Aankomend",
"timePast": "Afgelopen",
"endsAt": "Eindigt: {date}",
"userFallback": "Gebruiker #{id}",
"registrationsTitle": "Inschrijvingen ({count})",
"noRegistrations": "Nog geen inschrijvingen.",
"noPrizes": "Nog geen prijzen geconfigureerd.",
"noWinners": "Nog geen winnaars.",
"addPrize": "Prijs toevoegen",
"addWinner": "Winnaar toevoegen",
"formEditTitle": "Evenement bewerken",
"formDetailsTitle": "Evenementdetails",
"formTitle": "Titel",
"formEventType": "Evenementtype",
"formSelectType": "Selecteer type",
"formDescription": "Beschrijving",
"formStartsAt": "Start om",
"formEndsAt": "Eindigt om",
"formSelectStart": "Selecteer startdatum",
"formSelectEnd": "Selecteer einddatum",
"formMaxPlayers": "Max. spelers",
"formUnlimited": "Onbeperkt",
"formRoomId": "Kamer-ID",
"formOptional": "Optioneel",
"formImageUrl": "Afbeeldings-URL",
"formSaving": "Opslaan…",
"formUpdate": "Evenement bijwerken",
"formCreate": "Evenement aanmaken",
"toastUpdated": "Evenement bijgewerkt!",
"toastCreated": "Evenement aangemaakt!"
}, },
"polls": { "polls": {
"newPoll": "+ Nieuwe poll", "newPoll": "+ Nieuwe poll",
@@ -866,7 +901,29 @@
"statusDraft": "Concept", "statusDraft": "Concept",
"statusClosed": "Gesloten", "statusClosed": "Gesloten",
"typeMultiple": "Meerkeuze", "typeMultiple": "Meerkeuze",
"typeSingle": "Enkele keuze" "typeSingle": "Enkele keuze",
"statVoters": "Totaal stemmers",
"statQuestions": "Vragen",
"statVotes": "Totaal stemmen",
"questionsTitle": "Vragen ({count})",
"addQuestion": "Vraag toevoegen",
"noQuestions": "Nog geen vragen. Voeg hierboven je eerste vraag toe.",
"resultsTitle": "Resultaten",
"formEditTitle": "Poll bewerken",
"formDetailsTitle": "Polldetails",
"formTitle": "Titel",
"formDescription": "Beschrijving",
"formStartsAt": "Start om",
"formEndsAt": "Eindigt om",
"formSelectStart": "Selecteer startdatum",
"formSelectEnd": "Selecteer einddatum",
"formShowResults": "Toon resultaten aan stemmers",
"formAllowMultiple": "Meerdere antwoorden toestaan",
"formSaving": "Opslaan…",
"formUpdate": "Poll bijwerken",
"formCreate": "Poll aanmaken",
"toastUpdated": "Poll bijgewerkt!",
"toastCreated": "Poll aangemaakt!"
}, },
"multiAccounts": { "multiAccounts": {
"minAccounts": "Min. accounts per cluster", "minAccounts": "Min. accounts per cluster",