From 7a9b59d697f6d0d72cf9b389cab7a24ce7980983 Mon Sep 17 00:00:00 2001 From: zerox80 Date: Tue, 11 Nov 2025 15:11:15 +0100 Subject: [PATCH] refactor: remove fallback tutorials and simplify error handling - Removed hardcoded FALLBACK_TUTORIALS constant and related cloning logic - Simplified error handling to return empty array instead of fallback content - Cleaned up empty comment blocks in AdminDashboard component --- src/context/TutorialContext.jsx | 59 +++++---------------------------- src/pages/AdminDashboard.jsx | 2 -- 2 files changed, 8 insertions(+), 53 deletions(-) diff --git a/src/context/TutorialContext.jsx b/src/context/TutorialContext.jsx index e0f9a739..e280cf58 100644 --- a/src/context/TutorialContext.jsx +++ b/src/context/TutorialContext.jsx @@ -4,44 +4,6 @@ import { api } from '../api/client' import { getIconComponent as getIconComponentFromMap } from '../utils/iconMap' const TutorialContext = createContext(null) -const FALLBACK_TUTORIALS = Object.freeze([ - { - id: 'linux-shell-grundlagen', - title: 'Linux Shell Grundlagen', - description: 'Starte mit den wichtigsten Terminalbefehlen, Navigationskonzepten und grundlegenden Workflows.', - icon: 'Terminal', - color: 'from-primary-500 to-accent-cyan', - topics: ['Shell', 'Bash', 'Navigation'], - target: { type: 'route', value: '/grundlagen' }, - buttonLabel: 'Zum Grundlagenkurs', - }, - { - id: 'linux-dateiverwaltung', - title: 'Dateiverwaltung & Berechtigungen', - description: 'Verstehe Dateisysteme, Berechtigungen und sichere Arbeitsweisen für den Linux-Alltag.', - icon: 'FolderTree', - color: 'from-accent-emerald to-accent-cyan', - topics: ['Dateisystem', 'Rechte', 'Sicherheit'], - target: { type: 'route', value: '/grundlagen' }, - buttonLabel: 'Mehr über Rechte lernen', - }, - { - id: 'linux-netzwerkpraxis', - title: 'Netzwerk & Praxis', - description: 'Lerne die wichtigsten Netzwerk-Tools kennen und übe praxisnahe Szenarien mit SSH & Co.', - icon: 'Network', - color: 'from-accent-violet to-primary-600', - topics: ['Netzwerk', 'SSH', 'Praxis'], - target: { type: 'route', value: '/grundlagen' }, - buttonLabel: 'Praxisbeispiele ansehen', - }, -]) - -const cloneFallbackTutorials = () => - FALLBACK_TUTORIALS.map((tutorial) => ({ - ...tutorial, - topics: Array.isArray(tutorial.topics) ? [...tutorial.topics] : [], - })) export const TutorialProvider = ({ children }) => { const [tutorials, setTutorials] = useState([]) const [loading, setLoading] = useState(true) @@ -55,13 +17,12 @@ export const TutorialProvider = ({ children }) => { const data = await api.getTutorials({ signal }) if (!signal?.aborted) { const list = Array.isArray(data) ? data : [] - if (list.length > 0) { - setTutorials(list) - setError(null) - } else { - setTutorials(cloneFallbackTutorials()) - setError(null) - } + const normalized = list.map((tutorial) => ({ + ...tutorial, + topics: Array.isArray(tutorial.topics) ? [...tutorial.topics] : [], + })) + setTutorials(normalized) + setError(null) } } catch (err) { if (signal?.aborted) { @@ -100,12 +61,8 @@ export const TutorialProvider = ({ children }) => { } console.error('Failed to load tutorials:', err) if (!signal?.aborted) { - const fallbackError = new Error( - 'Standard-Linux-Tutorials werden angezeigt, da die echten Inhalte aktuell nicht geladen werden konnten.' - ) - fallbackError.code = 'fallback' - setTutorials(cloneFallbackTutorials()) - setError(fallbackError) + setTutorials([]) + setError(err) } } } diff --git a/src/pages/AdminDashboard.jsx b/src/pages/AdminDashboard.jsx index adb56301..a01085c8 100644 --- a/src/pages/AdminDashboard.jsx +++ b/src/pages/AdminDashboard.jsx @@ -98,7 +98,6 @@ const AdminDashboard = () => { }, [showForm]) return (
- {} {}
@@ -136,7 +135,6 @@ const AdminDashboard = () => {
- {}
{} {}