only show categorys wich have scripts in it

This commit is contained in:
Michel Roegl-Brunner 2025-05-14 11:10:22 +02:00
parent ad0607361a
commit 3f3d967a2c

View File

@ -12,7 +12,9 @@ const Sidebar = ({
selectedScript: string | null;
setSelectedScript: (script: string | null) => void;
}) => {
const uniqueScripts = items.reduce((acc, category) => {
const filteredItems = items.filter(category => category.scripts && category.scripts.length > 0);
const uniqueScripts = filteredItems.reduce((acc, category) => {
for (const script of category.scripts) {
if (!acc.some((s) => s.name === script.name)) {
acc.push(script);
@ -31,7 +33,7 @@ const Sidebar = ({
</div>
<div className="rounded-lg">
<ScriptAccordion
items={items}
items={filteredItems}
selectedScript={selectedScript}
setSelectedScript={setSelectedScript}
/>