From 464c954f1c2279373c671dc8858b8b05b06ce456 Mon Sep 17 00:00:00 2001 From: prachishelke1312 Date: Fri, 17 Jul 2026 19:43:54 +0530 Subject: [PATCH 1/2] fix(frontend): replace local notifications with global toast --- frontend/package-lock.json | 2 +- frontend/package.json | 2 +- frontend/src/app/App.tsx | 4 +++- frontend/src/app/components/ui/sonner.tsx | 8 ++++---- frontend/src/app/pages/dashboard.tsx | 21 ++++++--------------- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e14e84a..6997961 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -60,7 +60,7 @@ "react-router-dom": "^7.13.1", "react-slick": "0.31.0", "recharts": "^2.15.2", - "sonner": "2.0.3", + "sonner": "^2.0.3", "tailwind-merge": "3.2.0", "tw-animate-css": "1.3.8", "vaul": "1.1.2" diff --git a/frontend/package.json b/frontend/package.json index 9c83c20..3366f94 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -61,7 +61,7 @@ "react-router-dom": "^7.13.1", "react-slick": "0.31.0", "recharts": "^2.15.2", - "sonner": "2.0.3", + "sonner": "^2.0.3", "tailwind-merge": "3.2.0", "tw-animate-css": "1.3.8", "vaul": "1.1.2" diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx index 779cd0d..54dd317 100644 --- a/frontend/src/app/App.tsx +++ b/frontend/src/app/App.tsx @@ -1,11 +1,13 @@ import { RouterProvider } from "react-router"; import { ThemeProvider } from "./components/theme-provider"; +import { Toaster } from "./components/ui/sonner"; import { router } from "./routes"; export default function App() { return ( + ); -} +} \ No newline at end of file diff --git a/frontend/src/app/components/ui/sonner.tsx b/frontend/src/app/components/ui/sonner.tsx index f125983..4969ce6 100644 --- a/frontend/src/app/components/ui/sonner.tsx +++ b/frontend/src/app/components/ui/sonner.tsx @@ -1,14 +1,14 @@ "use client"; import { useTheme } from "next-themes"; -import { Toaster as Sonner, ToasterProps } from "sonner"; +import { Toaster as Sonner } from "sonner"; -const Toaster = ({ ...props }: ToasterProps) => { +const Toaster = (props: React.ComponentProps) => { const { theme = "system" } = useTheme(); return ( { ); }; -export { Toaster }; +export { Toaster }; \ No newline at end of file diff --git a/frontend/src/app/pages/dashboard.tsx b/frontend/src/app/pages/dashboard.tsx index f9b54bb..a5ed896 100644 --- a/frontend/src/app/pages/dashboard.tsx +++ b/frontend/src/app/pages/dashboard.tsx @@ -7,6 +7,7 @@ import { Button } from "../components/ui/button"; import { TrendChart } from "../components/trend-chart"; import { CweChart } from "../components/cwe-chart" import { DependencyDiff } from "../components/dependency-diff"; +import { toast } from "sonner"; import { Card, CardContent, @@ -25,7 +26,6 @@ import { import { StatusPill } from "../components/status-pill"; import { Input } from "../components/ui/input"; import { cn } from "../components/ui/utils"; - type UiJobStatus = "completed" | "running" | "failed" | "pending"; type UiJob = { @@ -66,7 +66,6 @@ export function Dashboard() { const [dragActive, setDragActive] = useState(false); const [scanLoading, setScanLoading] = useState(false); - const [scanError, setScanError] = useState(null); const [recentJobs, setRecentJobs] = useState(() => getLocalRecentJobs(), @@ -104,24 +103,22 @@ export function Dashboard() { saveLocalRecentJob(job); setRecentJobs(getLocalRecentJobs()); - + toast.success("Scan completed successfully!"); navigate("/findings"); }; const handleZipFile = async (file: File) => { if (!file.name.toLowerCase().endsWith(".zip")) { - setScanError("Please upload a .zip file."); + toast.error("Please upload a .zip file."); return; } - - setScanError(null); setScanLoading(true); try { const scan = await scanZip(file, file.name.replace(/\.zip$/i, "")); handleScanSuccess(scan); } catch (e: any) { - setScanError(e?.message ?? "Scan failed"); + toast.error(e?.message ?? "Scan failed"); } finally { setScanLoading(false); } @@ -130,13 +127,11 @@ export function Dashboard() { const handleImportFromUrl = async () => { const url = repoUrl.trim(); if (!url) { - setScanError( + toast.error( "Please paste a GitHub repo URL (example: https://github.com/owner/repo).", ); return; } - - setScanError(null); setScanLoading(true); try { @@ -147,7 +142,7 @@ export function Dashboard() { setRepoUrl(""); setRepoRef("main"); } catch (e: any) { - setScanError(e?.message ?? "Import from URL failed"); + toast.error(e?.message ?? "Import from URL failed"); } finally { setScanLoading(false); } @@ -235,10 +230,6 @@ export function Dashboard() { Supported formats: .zip (max 500MB)

- {scanError && ( -

{scanError}

- )} -
-