From 329e3bd7d87f61c2d25b9bd407757121ca984db4 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:14:20 +0330 Subject: [PATCH] Import source: cshare-app/src/components/Toast Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- cshare-app/src/components/Toast.jsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 cshare-app/src/components/Toast.jsx diff --git a/cshare-app/src/components/Toast.jsx b/cshare-app/src/components/Toast.jsx new file mode 100644 index 0000000..f0c79c3 --- /dev/null +++ b/cshare-app/src/components/Toast.jsx @@ -0,0 +1,27 @@ +import { useState, useCallback } from 'react'; +import { ToastContext } from './ToastContext'; + +export function ToastProvider({ children }) { + const [toasts, setToasts] = useState([]); + + const addToast = useCallback((message, type = 'info') => { + const id = Date.now() + Math.random(); + setToasts((prev) => [...prev, { id, message, type }]); + setTimeout(() => { + setToasts((prev) => prev.filter((t) => t.id !== id)); + }, 3000); + }, []); + + return ( + + {children} +
+ {toasts.map((toast) => ( +
+ {toast.message} +
+ ))} +
+
+ ); +}