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

+37 -27
View File
@@ -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<string, unknown> | undefined;
if (data?.id) {
@@ -89,12 +91,14 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
<form onSubmit={form.handleSubmit(onSubmit)}>
<Card>
<CardHeader>
<CardTitle>{isEditing ? "Edit Event" : "Event Details"}</CardTitle>
<CardTitle>
{isEditing ? t("formEditTitle") : t("formDetailsTitle")}
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-2">
<Label htmlFor="title">Title</Label>
<Label htmlFor="title">{t("formTitle")}</Label>
<Input id="title" {...form.register("title")} />
{form.formState.errors.title && (
<p className="text-sm text-destructive">
@@ -104,18 +108,18 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="typeId">Event Type</Label>
<Label htmlFor="typeId">{t("formEventType")}</Label>
<Select
value={String(form.watch("typeId"))}
onValueChange={(v) => form.setValue("typeId", Number(v))}
>
<SelectTrigger>
<SelectValue placeholder="Select type" />
<SelectValue placeholder={t("formSelectType")} />
</SelectTrigger>
<SelectContent>
{eventTypes.map((t) => (
<SelectItem key={t.id} value={String(t.id)}>
{t.name}
{eventTypes.map((et) => (
<SelectItem key={et.id} value={String(et.id)}>
{et.name}
</SelectItem>
))}
</SelectContent>
@@ -124,7 +128,7 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Label htmlFor="description">{t("formDescription")}</Label>
<Textarea
id="description"
rows={4}
@@ -134,48 +138,48 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="space-y-2">
<Label>Starts At</Label>
<Label>{t("formStartsAt")}</Label>
<DateTimePicker
value={form.watch("startsAt")}
onChange={(d) =>
form.setValue("startsAt", d, { shouldDirty: true })
}
placeholder="Select start date"
placeholder={t("formSelectStart")}
/>
</div>
<div className="space-y-2">
<Label>Ends At</Label>
<Label>{t("formEndsAt")}</Label>
<DateTimePicker
value={form.watch("endsAt")}
onChange={(d) =>
form.setValue("endsAt", d, { shouldDirty: true })
}
placeholder="Select end date"
placeholder={t("formSelectEnd")}
/>
</div>
<div className="space-y-2">
<Label htmlFor="maxPlayers">Max Players</Label>
<Label htmlFor="maxPlayers">{t("formMaxPlayers")}</Label>
<Input
id="maxPlayers"
type="number"
{...form.register("maxPlayers")}
placeholder="Unlimited"
placeholder={t("formUnlimited")}
/>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-2">
<Label htmlFor="roomId">Room ID</Label>
<Label htmlFor="roomId">{t("formRoomId")}</Label>
<Input
id="roomId"
type="number"
{...form.register("roomId")}
placeholder="Optional"
placeholder={t("formOptional")}
/>
</div>
<div className="space-y-2">
<Label htmlFor="status">Status</Label>
<Label htmlFor="status">{t("colStatus")}</Label>
<Select
value={form.watch("status")}
onValueChange={(v) =>
@@ -186,17 +190,23 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="draft">Draft</SelectItem>
<SelectItem value="published">Published</SelectItem>
<SelectItem value="cancelled">Cancelled</SelectItem>
<SelectItem value="completed">Completed</SelectItem>
<SelectItem value="draft">{t("statusDraft")}</SelectItem>
<SelectItem value="published">
{t("statusPublished")}
</SelectItem>
<SelectItem value="cancelled">
{t("statusCancelled")}
</SelectItem>
<SelectItem value="completed">
{t("statusCompleted")}
</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="image">Image URL</Label>
<Label htmlFor="image">{t("formImageUrl")}</Label>
<Input
id="image"
{...form.register("image")}
@@ -207,10 +217,10 @@ export function EventForm({ eventTypes, defaultValues }: EventFormProps) {
<div className="flex justify-end">
<Button type="submit" disabled={isPending}>
{isPending
? "Saving..."
? t("formSaving")
: isEditing
? "Update Event"
: "Create Event"}
? t("formUpdate")
: t("formCreate")}
</Button>
</div>
</CardContent>