import clientPromise from "@/lib/mongodb"; import dynamic from "next/dynamic"; import { useTranslations } from "next-intl"; import { dateOrderingFrance } from "@/utils/dbDateOrdering"; import { errorLog } from "@/utils/logger"; import TournamentTable from "./TournamentTable"; export const revalidate = 3600; // revalidate cache every 6 hours; const LoadingMap = () => { const t = useTranslations("Tournaments"); return (

{t("loading")}

); }; /** * Imports the tournament map component, ensuring CSR only. * @remarks SSR is not supported by react-leaflet */ const TournamentMap = dynamic(() => import("./TournamentMap"), { ssr: false, loading: LoadingMap, }); const getTournaments = async () => { try { const client = await clientPromise; const db = client.db("tournamentsFranceDB"); const data = await dateOrderingFrance(db); return JSON.stringify(data); } catch (error) { errorLog(error); throw new Error("Error fetching tournament data"); } }; export default async function Tournaments() { const tournamentData = await getTournaments(); return (
); }