"use client"; import { useEffect } from "react"; import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { useTranslations } from "next-intl"; import { FaExternalLinkAlt } from "react-icons/fa"; import { twMerge } from "tailwind-merge"; import { debouncedHoveredListIdAtom, debouncedHoveredMapIdAtom, filteredClubsListAtom, hoveredMapIdAtom, syncVisibleAtom, } from "@/app/atoms"; import ScrollToTopButton from "@/components/ScrollToTopButton"; import SearchBar from "@/components/SearchBar"; import { useBreakpoint } from "@/hooks/tailwind"; const ClubTable = () => { const t = useTranslations("Clubs"); const at = useTranslations("App"); const filteredClubs = useAtomValue(filteredClubsListAtom); const [syncVisible, setSyncVisible] = useAtom(syncVisibleAtom); const hoveredMapId = useAtomValue(hoveredMapIdAtom); const debouncedHoveredMapId = useAtomValue(debouncedHoveredMapIdAtom); const setHoveredListId = useSetAtom(debouncedHoveredListIdAtom); const isLg = useBreakpoint("lg"); useEffect(() => { if (!isLg || debouncedHoveredMapId === null) return; const clubRow = document.querySelector( `[data-group-id="${debouncedHoveredMapId}"]`, ); clubRow?.scrollIntoView({ behavior: "smooth" }); }, [debouncedHoveredMapId, isLg]); return (
{filteredClubs.length === 0 ? ( ) : ( filteredClubs.map((club) => ( setHoveredListId(club.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 === club.id && "bg-gray-200 dark:bg-gray-900", )} > )) )}
{t("name")} {t("contact")} {t("ffe")}
{t("noneFound")}
{club.name} {club.address &&
{club.address}
} {club.website && ( )} {club.email && ( )}
); }; export default ClubTable;