"use client"; /** * NotificationToast — FASE-07 UX & Microinteractions * * Global toast notification component. Renders notifications from the * notificationStore as stacked toasts in the top-right corner. * * Usage: Add to your root layout. */ import { useNotificationStore } from "@/store/notificationStore"; import { useEffect, useState } from "react"; const ICONS = { success: "✓", error: "✕", warning: "⚠", info: "ℹ", }; const COLORS = { success: { bg: "rgba(16, 185, 129, 0.15)", border: "rgba(16, 185, 129, 0.4)", icon: "#10b981", }, error: { bg: "rgba(239, 68, 68, 0.15)", border: "rgba(239, 68, 68, 0.4)", icon: "#ef4444", }, warning: { bg: "rgba(245, 158, 11, 0.15)", border: "rgba(245, 158, 11, 0.4)", icon: "#f59e0b", }, info: { bg: "rgba(59, 130, 246, 0.15)", border: "rgba(59, 130, 246, 0.4)", icon: "#3b82f6", }, }; function Toast({ notification, onDismiss }) { const [isExiting, setIsExiting] = useState(false); const handleDismiss = () => { setIsExiting(true); setTimeout(() => onDismiss(notification.id), 200); }; const color = COLORS[notification.type] || COLORS.info; return (
{ICONS[notification.type]}
{notification.title && (
{notification.title}
)}
{notification.message}
{notification.dismissible && ( )}
); } export default function NotificationToast() { const { notifications, removeNotification } = useNotificationStore(); if (notifications.length === 0) return null; return ( <>
{notifications.map((n) => (
))}
); }