import { AnimatePresence, motion } from "framer-motion" import { CheckCircle, Warning, X, XCircle } from "./ui/icons" import { useAppStore } from "../state/store" import { useReducedMotion } from "./ui" import type { Toast } from "../state/slices/ui" const TONE_CONFIG = { success: { icon: CheckCircle, className: "bg-success-muted border-success text-success" }, danger: { icon: XCircle, className: "bg-destructive-muted border-destructive text-destructive" }, warn: { icon: Warning, className: "bg-warning-muted border-warning text-warning" }, } as const export default function ToastContainer() { const toasts = useAppStore((s) => s.toasts) const dismiss = useAppStore((s) => s.dismissToast) const reduced = useReducedMotion() if (toasts.length === 0) return null return (
{toasts.map((toast) => { const cfg = TONE_CONFIG[toast.tone] const Icon = cfg.icon return ( ) })}
) } function ToastMessage({ message }: { message: Toast["message"] }) { if (typeof message === "string") { return ( {message} ) } return (
{message.code} {message.actionHint}
{message.message}
) }