Files
UTMS-NG-FE/components/layout/AppToasts.tsx
2026-04-21 06:30:48 +07:00

36 lines
992 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { useApiStore } from "@/store/uiStore";
export default function AppToasts() {
const { toasts, removeToast } = useApiStore((s) => ({
toasts: s.toasts,
removeToast: s.removeToast
}));
return (
<div className="toast-stack">
{toasts.map((toast) => (
<div key={toast.id} className={`toast show align-items-center border-0 ${toastClass(toast.type)}`}>
<div className="d-flex">
<div className="toast-body text-white">{toast.message}</div>
<button
className="btn btn-sm btn-link text-white"
onClick={() => removeToast(toast.id)}
aria-label="dismiss"
>
×
</button>
</div>
</div>
))}
</div>
);
}
function toastClass(type: "success" | "error" | "info") {
if (type === "success") return "bg-success text-white";
if (type === "error") return "bg-danger text-white";
return "bg-info text-white";
}