This commit is contained in:
2025-12-18 19:23:05 +01:00
parent baa18484ca
commit f6d40b8f2e
10 changed files with 1322 additions and 1111 deletions
+45
View File
@@ -0,0 +1,45 @@
import React, { useEffect } from "react";
export type ToastType = "success" | "error" | "info";
interface ToastProps {
message: string;
type: ToastType;
onClose: () => void;
duration?: number;
}
export const Toast: React.FC<ToastProps> = ({
message,
type,
onClose,
duration = 3000,
}) => {
useEffect(() => {
const timer = setTimeout(() => {
onClose();
}, duration);
return () => clearTimeout(timer);
}, [onClose, duration]);
const getIcon = () => {
switch (type) {
case "success":
return "✓";
case "error":
return "✕";
default:
return "";
}
};
return (
<div className={`toast toast-${type}`}>
<span className="toast-icon">{getIcon()}</span>
<span className="toast-message">{message}</span>
<button className="toast-close" onClick={onClose}>
&times;
</button>
</div>
);
};