- Remove .prettierrc (dead config, Biome replaces Prettier) - Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat - Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit - Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts - Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars - Replace barrel export src/types/index.ts with direct @/types/common imports - Make trustHost conditional (development only) in auth.ts - Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations - Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
140 lines
3.6 KiB
TypeScript
140 lines
3.6 KiB
TypeScript
import Image from "next/image";
|
|
import Link from "next/link";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { ContentCard, EmptyState } from "@/components/public/ui";
|
|
import { excerpt, slugify } from "@/lib/format";
|
|
import { formatDate } from "@/lib/format-date";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export const revalidate = 60;
|
|
|
|
export const metadata = { title: "Events" };
|
|
|
|
export default async function EventsPage() {
|
|
const t = await getTranslations("pages.events");
|
|
|
|
const events = await prisma.websiteEvent
|
|
.findMany({
|
|
where: { status: { in: ["published", "completed"] } },
|
|
orderBy: { startsAt: "desc" },
|
|
take: 50,
|
|
include: {
|
|
type: { select: { name: true, color: true, slug: true } },
|
|
_count: { select: { registrations: true } },
|
|
},
|
|
})
|
|
.catch(() => []);
|
|
|
|
return (
|
|
<main style={{ display: "grid", gap: "1.5rem" }}>
|
|
<ContentCard icon="📅" title={t("title")} subtitle={t("subtitle")} />
|
|
|
|
<ContentCard padded={events.length === 0}>
|
|
{events.length === 0 ? (
|
|
<EmptyState icon="📅">{t("empty")}</EmptyState>
|
|
) : (
|
|
<div className="card-grid sm-2 lg-3" style={{ padding: "1rem" }}>
|
|
{events.map((event) => {
|
|
const href = `/events/${slugify(event.title)}-${event.id}`;
|
|
const spots =
|
|
event.maxPlayers != null
|
|
? t("spots", {
|
|
count: event._count.registrations,
|
|
max: event.maxPlayers,
|
|
})
|
|
: t("registered", { count: event._count.registrations });
|
|
|
|
return (
|
|
<Link
|
|
key={event.id}
|
|
href={href}
|
|
className="card hover"
|
|
style={{
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
textDecoration: "none",
|
|
padding: 0,
|
|
overflow: "hidden",
|
|
color: "inherit",
|
|
}}
|
|
>
|
|
{event.image ? (
|
|
<div
|
|
style={{
|
|
position: "relative",
|
|
width: "100%",
|
|
aspectRatio: "16/9",
|
|
}}
|
|
>
|
|
<Image
|
|
src={event.image}
|
|
alt=""
|
|
fill
|
|
style={{ objectFit: "cover" }}
|
|
unoptimized
|
|
/>
|
|
</div>
|
|
) : (
|
|
<div
|
|
style={{
|
|
width: "100%",
|
|
aspectRatio: "16/9",
|
|
backgroundColor:
|
|
event.type.color ||
|
|
"color-mix(in srgb, var(--color-primary) 10%, var(--color-navbar))",
|
|
}}
|
|
/>
|
|
)}
|
|
<div
|
|
style={{
|
|
padding: "1rem 1.1rem",
|
|
flex: 1,
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
gap: "0.35rem",
|
|
}}
|
|
>
|
|
<p
|
|
className="muted"
|
|
style={{ margin: 0, fontSize: "0.75rem" }}
|
|
>
|
|
{event.type.name}
|
|
{event.status === "completed"
|
|
? ` · ${t("statusCompleted")}`
|
|
: ""}
|
|
</p>
|
|
<h3 style={{ margin: 0, fontSize: "1.05rem" }}>
|
|
{event.title}
|
|
</h3>
|
|
<p
|
|
className="muted"
|
|
style={{ margin: 0, fontSize: "0.85rem" }}
|
|
>
|
|
{formatDate(event.startsAt, "datetime", "")}
|
|
</p>
|
|
<p
|
|
style={{
|
|
margin: 0,
|
|
fontSize: "0.88rem",
|
|
lineHeight: 1.5,
|
|
}}
|
|
>
|
|
{excerpt(event.description, 120)}
|
|
</p>
|
|
<p
|
|
className="muted"
|
|
style={{ margin: "auto 0 0", fontSize: "0.8rem" }}
|
|
>
|
|
{spots}
|
|
</p>
|
|
</div>
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</ContentCard>
|
|
</main>
|
|
);
|
|
}
|