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:
1 parent
dd9c5e70c2
commit
a25008deb5
12 files changed
+325
-91
No files matched your search
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { Plus, Trash2 } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import { addEventPrize, deleteEventPrize } from "@/actions/events";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -38,6 +39,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export function EventPrizesManager({ eventId, prizes }: Props) {
|
||||
const t = useTranslations("pages.admin.events");
|
||||
const { run, isPending } = useServerAction();
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [form, setForm] = useState<EventPrizeInput>({
|
||||
@@ -70,9 +72,9 @@ export function EventPrizesManager({ eventId, prizes }: Props) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between">
|
||||
<CardTitle>Prizes</CardTitle>
|
||||
<CardTitle>{t("statPrizes")}</CardTitle>
|
||||
<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>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
@@ -159,9 +161,7 @@ export function EventPrizesManager({ eventId, prizes }: Props) {
|
||||
)}
|
||||
|
||||
{prizes.length === 0 && !showForm && (
|
||||
<p className="text-sm text-muted-foreground text-center py-4">
|
||||
No prizes configured yet.
|
||||
</p>
|
||||
<div className="admin-empty">{t("noPrizes")}</div>
|
||||
)}
|
||||
|
||||
{prizes.map((prize) => (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
||||
interface Registration {
|
||||
@@ -14,16 +15,18 @@ interface Props {
|
||||
}
|
||||
|
||||
export function EventRegistrations({ registrations }: Props) {
|
||||
const t = useTranslations("pages.admin.events");
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Registrations ({registrations.length})</CardTitle>
|
||||
<CardTitle>
|
||||
{t("registrationsTitle", { count: registrations.length })}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{registrations.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground text-center py-4">
|
||||
No registrations yet.
|
||||
</p>
|
||||
<div className="admin-empty">{t("noRegistrations")}</div>
|
||||
) : (
|
||||
<div className="divide-y max-h-[400px] overflow-y-auto">
|
||||
{registrations.map((r) => (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { Plus } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import { addEventWinner } from "@/actions/events";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -23,6 +24,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export function EventWinnersManager({ eventId, winners }: Props) {
|
||||
const t = useTranslations("pages.admin.events");
|
||||
const { run, isPending } = useServerAction();
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [userId, setUserId] = useState("");
|
||||
@@ -43,9 +45,9 @@ export function EventWinnersManager({ eventId, winners }: Props) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between">
|
||||
<CardTitle>Winners</CardTitle>
|
||||
<CardTitle>{t("statWinners")}</CardTitle>
|
||||
<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>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
@@ -80,9 +82,7 @@ export function EventWinnersManager({ eventId, winners }: Props) {
|
||||
)}
|
||||
|
||||
{winners.length === 0 && !showForm && (
|
||||
<p className="text-sm text-muted-foreground text-center py-4">
|
||||
No winners yet.
|
||||
</p>
|
||||
<div className="admin-empty">{t("noWinners")}</div>
|
||||
)}
|
||||
|
||||
<div className="divide-y">
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,3 +1,4 @@
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
import { AdminBreadcrumb } from "@/components/admin/admin-breadcrumb";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -22,6 +23,9 @@ export default async function PollDetailPage({
|
||||
const pollId = parseInt(id, 10);
|
||||
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({
|
||||
where: { id: pollId },
|
||||
include: {
|
||||
@@ -40,17 +44,25 @@ export default async function PollDetailPage({
|
||||
poll.questions.flatMap((q) => q.votes.map((v) => v.userId)),
|
||||
).size;
|
||||
|
||||
const statusLabel: Record<string, string> = {
|
||||
active: t("statusActive"),
|
||||
draft: t("statusDraft"),
|
||||
closed: t("statusClosed"),
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<AdminBreadcrumb
|
||||
items={[
|
||||
{ label: "Polls", href: "/admin/polls" },
|
||||
{ label: tHubs("tabs.polls"), href: "/admin/polls" },
|
||||
{ label: poll.title },
|
||||
]}
|
||||
/>
|
||||
<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
|
||||
variant={
|
||||
poll.status === "active"
|
||||
@@ -60,11 +72,13 @@ export default async function PollDetailPage({
|
||||
: "secondary"
|
||||
}
|
||||
>
|
||||
{poll.status}
|
||||
{statusLabel[poll.status] ?? poll.status}
|
||||
</Badge>
|
||||
</div>
|
||||
{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>
|
||||
|
||||
@@ -72,7 +86,9 @@ export default async function PollDetailPage({
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium">Total Voters</CardTitle>
|
||||
<CardTitle className="text-sm font-medium">
|
||||
{t("statVoters")}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">{totalVoters}</div>
|
||||
@@ -80,7 +96,9 @@ export default async function PollDetailPage({
|
||||
</Card>
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium">Questions</CardTitle>
|
||||
<CardTitle className="text-sm font-medium">
|
||||
{t("statQuestions")}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">{poll.questions.length}</div>
|
||||
@@ -88,7 +106,9 @@ export default async function PollDetailPage({
|
||||
</Card>
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium">Total Votes</CardTitle>
|
||||
<CardTitle className="text-sm font-medium">
|
||||
{t("statVotes")}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { GripVertical, Pencil, Plus, Trash2 } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
addPollQuestion,
|
||||
@@ -37,6 +38,7 @@ interface Props {
|
||||
type PollQuestionUpdateInput = PollQuestionInput & { id: number };
|
||||
|
||||
export function PollQuestionsManager({ pollId, questions }: Props) {
|
||||
const t = useTranslations("pages.admin.polls");
|
||||
const { run, isPending } = useServerAction();
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [editingId, setEditingId] = useState<number | null>(null);
|
||||
@@ -96,7 +98,9 @@ export function PollQuestionsManager({ pollId, questions }: Props) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between">
|
||||
<CardTitle>Questions ({questions.length})</CardTitle>
|
||||
<CardTitle>
|
||||
{t("questionsTitle", { count: questions.length })}
|
||||
</CardTitle>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
@@ -104,7 +108,7 @@ export function PollQuestionsManager({ pollId, questions }: Props) {
|
||||
setShowForm(!showForm);
|
||||
}}
|
||||
>
|
||||
<Plus className="h-4 w-4 mr-1" /> Add Question
|
||||
<Plus className="h-4 w-4 mr-1" /> {t("addQuestion")}
|
||||
</Button>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
@@ -177,9 +181,7 @@ export function PollQuestionsManager({ pollId, questions }: Props) {
|
||||
)}
|
||||
|
||||
{questions.length === 0 && !showForm && (
|
||||
<p className="text-sm text-muted-foreground text-center py-4">
|
||||
No questions yet. Add your first question above.
|
||||
</p>
|
||||
<div className="admin-empty">{t("noQuestions")}</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
||||
interface QuestionResult {
|
||||
@@ -14,10 +15,12 @@ interface Props {
|
||||
}
|
||||
|
||||
export function PollResultsView({ questions }: Props) {
|
||||
const t = useTranslations("pages.admin.polls");
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Results</CardTitle>
|
||||
<CardTitle>{t("resultsTitle")}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{questions.map((q) => {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+59
-2
@@ -849,7 +849,42 @@
|
||||
"statusPublished": "Published",
|
||||
"statusDraft": "Draft",
|
||||
"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": {
|
||||
"newPoll": "+ New poll",
|
||||
@@ -866,7 +901,29 @@
|
||||
"statusDraft": "Draft",
|
||||
"statusClosed": "Closed",
|
||||
"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": {
|
||||
"minAccounts": "Min accounts per cluster",
|
||||
|
||||
+59
-2
@@ -813,7 +813,42 @@
|
||||
"statusPublished": "Pubblicato",
|
||||
"statusDraft": "Bozza",
|
||||
"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": {
|
||||
"newPoll": "+ Nuovo sondaggio",
|
||||
@@ -830,7 +865,29 @@
|
||||
"statusDraft": "Bozza",
|
||||
"statusClosed": "Chiuso",
|
||||
"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": {
|
||||
"minAccounts": "Min. account per cluster",
|
||||
|
||||
+59
-2
@@ -849,7 +849,42 @@
|
||||
"statusPublished": "Gepubliceerd",
|
||||
"statusDraft": "Concept",
|
||||
"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": {
|
||||
"newPoll": "+ Nieuwe poll",
|
||||
@@ -866,7 +901,29 @@
|
||||
"statusDraft": "Concept",
|
||||
"statusClosed": "Gesloten",
|
||||
"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": {
|
||||
"minAccounts": "Min. accounts per cluster",
|
||||
|
||||
Reference in new issue
Block a user