Files
EpicNext-Cms/src/app/photos/page.tsx
T
Simo 4dfe698009 Close remaining web gaps: rich profile, login history, lightbox/slider, flash client, admin chatlog/DJ/chart/WYSIWYG, niche API
- Rich profile (/u/[username]): wallet (credits/duckets/diamonds), friends
  grid (messenger_friendships), and owned rooms sections.
- Login history: new website_login_logs table (model + migration 0007),
  recorded on every successful sign-in (ip + user-agent), surfaced on a new
  /settings/sessions page (with failed-attempt list from failed_logins).
- Photos lightbox + home article slider (client components, no Swiper dep).
- /client/flash launcher (SSO ticket like the Nitro page).
- Admin: private chatlogs section in /admin/logs, /admin/radio/moderation
  (shout moderation), a "users by rank" inline bar chart on the dashboard,
  and a TinyMCE rich-text editor on the article admin forms.
- Niche API: /api/values/[id], /api/guilds(+/[id]), /api/radio/auto-play.

Verified live (prod, amx_test): login recorded → /settings/sessions shows
it with device; profile renders wallet/friends/rooms; dashboard chart +
private-chat logs + /client/flash + /api/guilds all OK. Reverted test data.
tsc 0, vitest 49/49, next build 0.
2026-06-29 18:26:34 +02:00

66 lines
1.6 KiB
TypeScript

import { getTranslations } from "next-intl/server";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { PhotoLightbox, type LightboxPhoto } from "@/components/public/photo-lightbox";
import { prisma } from "@/lib/prisma";
export const dynamic = "force-dynamic";
export const metadata = { title: "Photos" };
type Photo = {
id: number;
userId: number;
roomId: number;
timestamp: number;
url: string;
};
function formatDate(timestamp: number): string {
return new Date(timestamp * 1000)
.toISOString()
.slice(0, 16)
.replace("T", " ");
}
export default async function PhotosPage() {
const t = await getTranslations("pages.photos");
let photos: Photo[] = [];
try {
photos = await prisma.cameraWeb.findMany({
orderBy: { timestamp: "desc" },
take: 48,
});
} catch {
photos = [];
}
// Pre-shape for the client lightbox: translate captions server-side so the
// client component stays free of i18n/prisma dependencies.
const items: LightboxPhoto[] = photos.map((p) => ({
id: String(p.id),
url: p.url,
alt: t("photoAlt", { id: p.userId }),
date: formatDate(p.timestamp),
user: t("byUser", { id: p.userId }),
}));
return (
<main style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard
icon="📸"
title={t("title")}
subtitle={t("subtitle")}
/>
<ContentCard padded={items.length === 0}>
{items.length === 0 ? (
<EmptyState icon="📸">{t("noPhotos")}</EmptyState>
) : (
<PhotoLightbox photos={items} />
)}
</ContentCard>
</main>
);
}