import { useState } from "react"; import type { PriceAlert } from "@/lib/types"; import { getAlerts, saveAlerts } from "@/lib/storage"; function showToast(msg: string) { const t = document.getElementById("toast"); if (!t) return; t.textContent = msg; t.className = "toast success"; setTimeout(() => t.classList.add("show"), 10); setTimeout(() => t.classList.remove("show"), 2500); } export default function AlertsPanel() { const [alerts, setAlerts] = useState(() => getAlerts()); const remove = (idx: number) => { const next = alerts.filter((_, i) => i !== idx); setAlerts(next); saveAlerts(next); showToast("Alert removed"); }; if (alerts.length === 0) { return (
🔔

No price alerts set.
Set alerts on products to track price drops.

); } return (
{alerts.map((a, i) => (
{a.name}
Watching at ${a.price.toFixed(2)} ({a.store})
))}
); }