feat: add tomorrow weather brief notifications
This commit is contained in:
@@ -12,7 +12,7 @@ import { DEFAULT_STATION_ID } from "@/lib/constants";
|
||||
import { useI18n } from "@/lib/i18n";
|
||||
import { getProvinceForSelection } from "@/lib/provinces";
|
||||
import { useWeatherStore } from "@/lib/store";
|
||||
import { buildWeatherBrief } from "@/lib/weather-brief";
|
||||
import { buildTomorrowWeatherBrief, buildWeatherBrief } from "@/lib/weather-brief";
|
||||
|
||||
export function WeatherBriefCard({ latitude, longitude, locationName }: { latitude?: number; longitude?: number; locationName: string }) {
|
||||
const { language, t } = useI18n();
|
||||
@@ -26,6 +26,10 @@ export function WeatherBriefCard({ latitude, longitude, locationName }: { latitu
|
||||
if (!forecast) return null;
|
||||
return buildWeatherBrief({ forecast, warnings, province, countyTeryt: selectedLocation?.countyTeryt, locationName, language });
|
||||
}, [forecast, language, locationName, province, selectedLocation?.countyTeryt, warnings]);
|
||||
const tomorrowBrief = useMemo(() => {
|
||||
if (!forecast) return null;
|
||||
return buildTomorrowWeatherBrief({ forecast, warnings, province, countyTeryt: selectedLocation?.countyTeryt, locationName, language });
|
||||
}, [forecast, language, locationName, province, selectedLocation?.countyTeryt, warnings]);
|
||||
|
||||
if (!Number.isFinite(latitude) || !Number.isFinite(longitude) || isPending) {
|
||||
return <LoadingSkeleton className="h-48" />;
|
||||
@@ -72,6 +76,20 @@ export function WeatherBriefCard({ latitude, longitude, locationName }: { latitu
|
||||
))}
|
||||
</ul>
|
||||
|
||||
{tomorrowBrief && (
|
||||
<div className="mt-5 border-t border-border/65 pt-4">
|
||||
<p className="section-kicker">{t("brief.tomorrowLabel")}</p>
|
||||
<h3 className="mt-1 text-sm font-semibold">{tomorrowBrief.headline}</h3>
|
||||
<ul className="mt-3 space-y-2">
|
||||
{tomorrowBrief.body.slice(0, 3).map((line) => (
|
||||
<li key={line} className="rounded-card border border-border/60 bg-surface-muted/45 px-3 py-2 text-sm leading-6">
|
||||
{line}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<p className="mt-4 flex items-center gap-2 text-xs leading-5 text-muted">
|
||||
<BellRing className="size-3.5 text-accent" aria-hidden="true" />
|
||||
{t("brief.pushHint")}
|
||||
|
||||
Reference in New Issue
Block a user