diff --git a/frontend/src/app/scripts/_components/Sidebar.tsx b/frontend/src/app/scripts/_components/Sidebar.tsx index 24f9dce2..3680210f 100644 --- a/frontend/src/app/scripts/_components/Sidebar.tsx +++ b/frontend/src/app/scripts/_components/Sidebar.tsx @@ -1,35 +1,43 @@ "use client"; -import { Category } from "@/lib/types"; +import type { Category, Script } from "@/lib/types"; import ScriptAccordion from "./ScriptAccordion"; const Sidebar = ({ - items, - selectedScript, - setSelectedScript, + items, + selectedScript, + setSelectedScript, }: { - items: Category[]; - selectedScript: string | null; - setSelectedScript: (script: string | null) => void; + items: Category[]; + selectedScript: string | null; + setSelectedScript: (script: string | null) => void; }) => { - return ( -
-
-

Categories

-

- {items.reduce((acc, category) => acc + category.scripts.length, 0)}{" "} - Total scripts -

-
-
- -
-
- ); + const uniqueScripts = items.reduce((acc, category) => { + for (const script of category.scripts) { + if (!acc.some((s) => s.name === script.name)) { + acc.push(script); + } + } + return acc; + }, [] as Script[]); + + return ( +
+
+

Categories

+

+ {uniqueScripts.length} Total scripts +

+
+
+ +
+
+ ); }; -export default Sidebar; +export default Sidebar; \ No newline at end of file