import type { Metadata } from "next"; import { asc, desc, inArray } from "drizzle-orm"; import { JsonLd } from "@/components/JsonLd"; import { PastMeetingGallery } from "@/components/PastMeetingGallery"; import { SiteFooter } from "@/components/SiteFooter"; import { SiteHeader } from "@/components/SiteHeader"; import { db } from "@/db"; import { meetingRegistrations, pastMeetingPhotos, pastMeetings } from "@/db/schema"; import { splitLines } from "@/lib/site-settings"; import { breadcrumbJsonLd, pageMetadata } from "@/lib/seo"; import { publicBaseUrl } from "@/lib/seo-server"; export const dynamic = "force-dynamic"; export const metadata: Metadata = pageMetadata({ title: "Rencontres passées de l'association", description: "Retour en images sur les rencontres Plein R : soirées réseau, visites d'entreprises et moments " + "partagés entre entrepreneurs du Bassin de Pompey.", path: "/rencontres-passees", }); function formatDate(date: Date) { return new Intl.DateTimeFormat("fr-FR", { day: "numeric", month: "long", year: "numeric" }).format(date); } export default async function PastMeetingsPage() { const [archives, photos, baseUrl] = await Promise.all([ db.select().from(pastMeetings).orderBy(desc(pastMeetings.eventDate)), db.select().from(pastMeetingPhotos).orderBy(asc(pastMeetingPhotos.position), asc(pastMeetingPhotos.id)), publicBaseUrl(), ]); const linkedIds = archives.map((archive) => archive.meetingId).filter((id): id is number => id !== null); const linkedRegistrations = linkedIds.length > 0 ? await db .select({ meetingId: meetingRegistrations.meetingId, id: meetingRegistrations.id }) .from(meetingRegistrations) .where(inArray(meetingRegistrations.meetingId, linkedIds)) : []; const photosByPast = new Map(); for (const photo of photos) { photosByPast.set(photo.pastMeetingId, [...(photosByPast.get(photo.pastMeetingId) ?? []), photo]); } const registrationCounts = new Map(); for (const registration of linkedRegistrations) { registrationCounts.set(registration.meetingId, (registrationCounts.get(registration.meetingId) ?? 0) + 1); } return (
Ils y étaient

Toutes nos rencontres passées

Revivez en images les temps forts de Plein R et les moments partagés par les acteurs économiques du Bassin de Pompey.

{archives.length === 0 ? (
Aucune rencontre passée publiée pour le moment.
) : (
{archives.map((archive) => { const archivePhotos = photosByPast.get(archive.id) ?? []; const participantCount = archive.meetingId ? registrationCounts.get(archive.meetingId) ?? 0 : splitLines(archive.participants ?? "").length; return (
{formatDate(archive.eventDate)}

{archive.title}

{archive.location &&
{archive.location}
} {archive.description &&

{archive.description}

}
{participantCount} participant{participantCount > 1 ? "s" : ""} · {archivePhotos.length} photo{archivePhotos.length > 1 ? "s" : ""}
); })}
)}
); }