feat: build production-ready wtr weather PWA
This commit is contained in:
28
components/dashboard/dashboard-page.tsx
Normal file
28
components/dashboard/dashboard-page.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { DEFAULT_STATION_NAME } from "@/lib/constants";
|
||||
import { useWeatherStore } from "@/lib/store";
|
||||
import { useWeatherStations } from "@/hooks/use-weather-stations";
|
||||
import { WeatherHero } from "@/components/weather/weather-hero";
|
||||
import { FavoritesSection } from "@/components/weather/favorites-section";
|
||||
import { StationsExplorer } from "@/components/weather/stations-explorer";
|
||||
import { PageLoadingSkeleton } from "@/components/states/loading-skeleton";
|
||||
import { ErrorState } from "@/components/states/error-state";
|
||||
|
||||
export function DashboardPage() {
|
||||
const { data: stations, isPending, isError, refetch } = useWeatherStations();
|
||||
const selectedStationId = useWeatherStore((state) => state.selectedStationId);
|
||||
if (isPending) return <PageLoadingSkeleton />;
|
||||
if (isError || !stations?.length) return <ErrorState onRetry={() => refetch()} description="Nie udało się pobrać listy stacji synoptycznych IMGW." />;
|
||||
const selectedStation = stations.find((station) => station.id === selectedStationId)
|
||||
?? stations.find((station) => station.name === DEFAULT_STATION_NAME)
|
||||
?? stations[0];
|
||||
|
||||
return (
|
||||
<div className="space-y-10">
|
||||
<WeatherHero station={selectedStation} />
|
||||
<FavoritesSection stations={stations} />
|
||||
<StationsExplorer stations={stations} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user