From 6e113b3f80566ff6ae1f33aaf8b94e1e1fe92370 Mon Sep 17 00:00:00 2001 From: mavis Date: Thu, 30 Jul 2026 11:13:59 +0000 Subject: [PATCH] fix: replaced alert calls with toast notifications in ShareRoutine page --- frontend/src/pages/ShareRoutine.jsx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/ShareRoutine.jsx b/frontend/src/pages/ShareRoutine.jsx index 3dca54e0..05c0cc31 100644 --- a/frontend/src/pages/ShareRoutine.jsx +++ b/frontend/src/pages/ShareRoutine.jsx @@ -13,6 +13,8 @@ export default function ShareRoutine() { const [error, setError] = useState(null); const [isExporting, setIsExporting] = useState(false); const [showCopyToast, setShowCopyToast] = useState(false); + const [showErrorToast, setShowErrorToast] = useState(false); + const [errorToastMessage, setErrorToastMessage] = useState(""); useEffect(() => { const fetchPublicRoutine = async () => { @@ -44,7 +46,9 @@ export default function ShareRoutine() { setTimeout(() => setShowCopyToast(false), 3000); } catch (err) { console.error("Failed to copy summary:", err); - alert("Failed to copy routine summary."); + setErrorToastMessage("Failed to copy routine summary."); + setShowErrorToast(true); + setTimeout(() => setShowErrorToast(false), 3000); } }; @@ -55,7 +59,9 @@ export default function ShareRoutine() { await exportRoutineToPDF(routine, []); } catch (err) { console.error("PDF export failed:", err); - alert("Failed to export routine as PDF."); + setErrorToastMessage("Failed to export routine as PDF."); + setShowErrorToast(true); + setTimeout(() => setShowErrorToast(false), 3000); } finally { setIsExporting(false); } @@ -102,6 +108,20 @@ export default function ShareRoutine() { return (
+ {/* Error Toast Notification */} + {showErrorToast && ( +
+
+
+
+
+

{errorToastMessage}

+
+
+
+
+ )} + {/* Toast Notification */} {showCopyToast && (