diff --git a/src/app/admin/events/[id]/event-prizes.tsx b/src/app/admin/events/[id]/event-prizes.tsx index 836e5d7b..a67c5cb1 100644 --- a/src/app/admin/events/[id]/event-prizes.tsx +++ b/src/app/admin/events/[id]/event-prizes.tsx @@ -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({ @@ -70,9 +72,9 @@ export function EventPrizesManager({ eventId, prizes }: Props) { return ( - Prizes + {t("statPrizes")} @@ -159,9 +161,7 @@ export function EventPrizesManager({ eventId, prizes }: Props) { )} {prizes.length === 0 && !showForm && ( -

- No prizes configured yet. -

+
{t("noPrizes")}
)} {prizes.map((prize) => ( diff --git a/src/app/admin/events/[id]/event-registrations.tsx b/src/app/admin/events/[id]/event-registrations.tsx index faa93dd0..63b419a8 100644 --- a/src/app/admin/events/[id]/event-registrations.tsx +++ b/src/app/admin/events/[id]/event-registrations.tsx @@ -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 ( - Registrations ({registrations.length}) + + {t("registrationsTitle", { count: registrations.length })} + {registrations.length === 0 ? ( -

- No registrations yet. -

+
{t("noRegistrations")}
) : (
{registrations.map((r) => ( diff --git a/src/app/admin/events/[id]/event-winners.tsx b/src/app/admin/events/[id]/event-winners.tsx index 222bf441..7843b814 100644 --- a/src/app/admin/events/[id]/event-winners.tsx +++ b/src/app/admin/events/[id]/event-winners.tsx @@ -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 ( - Winners + {t("statWinners")} @@ -80,9 +82,7 @@ export function EventWinnersManager({ eventId, winners }: Props) { )} {winners.length === 0 && !showForm && ( -

- No winners yet. -

+
{t("noWinners")}
)}
diff --git a/src/app/admin/events/[id]/page.tsx b/src/app/admin/events/[id]/page.tsx index af67020e..6bfe928f 100644 --- a/src/app/admin/events/[id]/page.tsx +++ b/src/app/admin/events/[id]/page.tsx @@ -1,4 +1,5 @@ import { CalendarDays, Gift, Trophy, Users } from "lucide-react"; +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"; @@ -24,6 +25,9 @@ export default async function EventDetailPage({ const eventId = parseInt(id, 10); if (Number.isNaN(eventId)) notFound(); + const t = await getTranslations("pages.admin.events"); + const tHubs = await getTranslations("pages.admin.hubs"); + const event = await prisma.websiteEvent.findUnique({ where: { id: eventId }, include: { @@ -55,17 +59,26 @@ export default async function EventDetailPage({ : []; const userMap = new Map(users.map((u) => [u.id, u.username])); + const statusLabel: Record = { + published: t("statusPublished"), + draft: t("statusDraft"), + cancelled: t("statusCancelled"), + completed: t("statusCompleted"), + }; + return (
-

{event.title}

+

+ {event.title} +

- {event.status} + {statusLabel[event.status] ?? event.status}
-

+

{event.type.name} · {new Date(event.startsAt).toLocaleString()}

@@ -87,7 +100,9 @@ export default async function EventDetailPage({
- Registrations + + {t("statRegistrations")} + @@ -96,14 +111,14 @@ export default async function EventDetailPage({
{event.maxPlayers && (

- Max: {event.maxPlayers} + {t("maxPlayers", { count: event.maxPlayers })}

)} - Prizes + {t("statPrizes")} @@ -112,7 +127,9 @@ export default async function EventDetailPage({ - Winners + + {t("statWinners")} + @@ -121,16 +138,20 @@ export default async function EventDetailPage({ - Time + {t("statTime")}
- {new Date(event.startsAt) > new Date() ? "Upcoming" : "Past"} + {new Date(event.startsAt) > new Date() + ? t("timeUpcoming") + : t("timePast")}
{event.endsAt && (

- Ends: {new Date(event.endsAt).toLocaleString()} + {t("endsAt", { + date: new Date(event.endsAt).toLocaleString(), + })}

)}
@@ -168,7 +189,7 @@ export default async function EventDetailPage({ eventId={event.id} winners={event.winners.map((w) => ({ ...w, - username: userMap.get(w.userId) ?? `User #${w.userId}`, + username: userMap.get(w.userId) ?? t("userFallback", { id: w.userId }), }))} /> @@ -176,7 +197,7 @@ export default async function EventDetailPage({ ({ ...r, - username: userMap.get(r.userId) ?? `User #${r.userId}`, + username: userMap.get(r.userId) ?? t("userFallback", { id: r.userId }), }))} />
diff --git a/src/app/admin/events/event-form.tsx b/src/app/admin/events/event-form.tsx index 73097992..3887ae31 100644 --- a/src/app/admin/events/event-form.tsx +++ b/src/app/admin/events/event-form.tsx @@ -1,5 +1,6 @@ "use client"; +import { useTranslations } from "next-intl"; import { useForm } from "react-hook-form"; import { createEvent, updateEvent } from "@/actions/events"; import { Button } from "@/components/ui/button"; @@ -47,6 +48,7 @@ interface EventFormValues { } export function EventForm({ eventTypes, defaultValues }: EventFormProps) { + const t = useTranslations("pages.admin.events"); const { run, isPending } = useServerAction(); const isEditing = !!defaultValues?.id; @@ -69,12 +71,12 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) { id: number; }), { - successMessage: "Event updated!", + successMessage: t("toastUpdated"), }, ); } else { run(() => createEvent(data as CreateEventInput), { - successMessage: "Event created!", + successMessage: t("toastCreated"), onSuccess: (result) => { const data = result.data as Record | undefined; if (data?.id) { @@ -89,12 +91,14 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
- {isEditing ? "Edit Event" : "Event Details"} + + {isEditing ? t("formEditTitle") : t("formDetailsTitle")} +
- + {form.formState.errors.title && (

@@ -104,18 +108,18 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {

- +