import { useState } from "react"; import ComponentCard from "../../../components/common/ComponentCard"; import Alert from "../../../components/ui/alert/Alert"; import PageMeta from "../../../components/common/PageMeta"; import Button from "../../../components/ui/button/Button"; export default function Alerts() { const [notifications, setNotifications] = useState< Array<{ id: number; variant: "success" | "error" | "warning" | "info"; title: string; message: string }> >([]); const addNotification = (variant: "success" | "error" | "warning" | "info") => { const titles = { success: "Success!", error: "Error Occurred", warning: "Warning", info: "Information", }; const messages = { success: "Operation completed successfully.", error: "Something went wrong. Please try again.", warning: "Please review this action carefully.", info: "Here's some useful information for you.", }; const newNotification = { id: Date.now(), variant, title: titles[variant], message: messages[variant], }; setNotifications((prev) => [...prev, newNotification]); // Auto-remove after 5 seconds setTimeout(() => { setNotifications((prev) => prev.filter((n) => n.id !== newNotification.id)); }, 5000); }; const removeNotification = (id: number) => { setNotifications((prev) => prev.filter((n) => n.id !== id)); }; return ( <>
{/* Interactive Notifications */}
{notifications.length > 0 && ( )}
{/* Notification Stack */}
{notifications.map((notification) => (
))}
{/* Static Alert Examples */}
); }