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,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">
|
||||
|
||||
Reference in New Issue
Block a user