"use client"; import { useMemo, useState } from "react"; import { Search, Waves } from "lucide-react"; import { useHydroStations } from "@/hooks/use-hydro"; import { HydroStationCard } from "@/components/hydro/hydro-station-card"; import { Button } from "@/components/ui/button"; import { PageLoadingSkeleton } from "@/components/states/loading-skeleton"; import { ErrorState } from "@/components/states/error-state"; import { EmptyState } from "@/components/states/empty-state"; const PAGE_SIZE = 48; export function HydroPage() { const { data: stations, isPending, isError, refetch } = useHydroStations(); const [query, setQuery] = useState(""); const [visibleCount, setVisibleCount] = useState(PAGE_SIZE); const filteredStations = useMemo(() => (stations ?? []).filter((station) => { const haystack = `${station.name} ${station.river ?? ""} ${station.province ?? ""}`.toLocaleLowerCase("pl"); return haystack.includes(query.trim().toLocaleLowerCase("pl")); }), [query, stations]); if (isPending) return ; if (isError) return refetch()} description="Nie udało się pobrać stacji hydrologicznych IMGW." />; return (

Monitoring wód IMGW

Hydro

Najnowsze dostępne pomiary poziomu wody, temperatury i przepływu. Każdy parametr może mieć własny czas aktualizacji.

Znaleziono {filteredStations.length} stacji. Wyświetlono {Math.min(visibleCount, filteredStations.length)}.

{!filteredStations.length ? : ( <>
{filteredStations.slice(0, visibleCount).map((station, index) => )}
{visibleCount < filteredStations.length &&
} )}
); }