"use client"; import { useEffect } from "react"; import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { useTranslations } from "next-intl"; import { FaExternalLinkAlt } from "react-icons/fa"; import { FaTrophy } from "react-icons/fa"; import { Tooltip } from "react-tooltip"; import { twMerge } from "tailwind-merge"; import { debouncedHoveredListIdAtom, debouncedHoveredMapIdAtom, filteredTournamentsListAtom, hoveredMapIdAtom, normsOnlyAtom, syncVisibleAtom, } from "@/app/atoms"; import ScrollToTopButton from "@/components/ScrollToTopButton"; import SearchBar from "@/components/SearchBar"; import { useBreakpoint } from "@/hooks/tailwind"; import TimeControlFilters from "./TimeControlFilters"; const TournamentTable = () => { const t = useTranslations("Tournaments"); const at = useTranslations("App"); const filteredTournaments = useAtomValue(filteredTournamentsListAtom); const [syncVisible, setSyncVisible] = useAtom(syncVisibleAtom); const [normsOnly, setNormsOnly] = useAtom(normsOnlyAtom); const hoveredMapId = useAtomValue(hoveredMapIdAtom); const debouncedHoveredMapId = useAtomValue(debouncedHoveredMapIdAtom); const setHoveredListId = useSetAtom(debouncedHoveredListIdAtom); const isLg = useBreakpoint("lg"); useEffect(() => { if (!isLg || debouncedHoveredMapId === null) return; const tournamentRow = document.querySelector( `[data-group-id="${debouncedHoveredMapId}"]`, ); tournamentRow?.scrollIntoView({ behavior: "smooth" }); }, [debouncedHoveredMapId, isLg]); return (
{filteredTournaments.length === 0 ? ( ) : ( filteredTournaments.map((tournament) => ( setHoveredListId(tournament.id)} onMouseLeave={() => setHoveredListId(null)} className={twMerge( "scroll-m-20 bg-white text-gray-900 hover:bg-gray-200 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-900", hoveredMapId === tournament.groupId && "bg-gray-200 dark:bg-gray-900", )} > )) )}
{t("date")} {t("town")} {t("tournament")} {t("timeControl")} {t("ffe")}
{t("noneFound")}
{tournament.date} {tournament.town} {tournament.norm && ( )} {tournament.tournament} {at("timeControlEnum", { tc: tournament.timeControl })}
{t("norm")}
); }; export default TournamentTable;