From 58a5c95d423c28c4c9e83d225dfc67f395c71195 Mon Sep 17 00:00:00 2001 From: "matthias.lotz" Date: Thu, 13 Nov 2025 20:22:22 +0100 Subject: [PATCH] fix(phase2): Fix API routes and filter logic (Issues 6 & 7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue 6: ModerationGroupsPage - Filter "Alle Gruppen" not working - Problem: Backend filtered groups with display_in_workshop=1 even when no filter selected - Solution: Removed filter condition in else block - now shows ALL groups when filter='all' - File: backend/src/routes/groups.js - Test: GET /moderation/groups now returns 73 groups (all groups) Issue 7: Export button "Consent-Daten exportieren" not working - Problem: Routes had wrong path prefix (/admin/* instead of /api/admin/*) - Solution: Added /api prefix to consent admin routes for consistency - Files: backend/src/routes/consent.js * GET /api/admin/groups/by-consent (was /admin/groups/by-consent) * GET /api/admin/consents/export (was /admin/consents/export) - Test: curl http://localhost:5001/api/admin/consents/export?format=csv works - Export now includes dynamic Social Media platform columns (facebook, instagram, tiktok) Test Results: ✅ Filter "Alle Gruppen": 73 groups ✅ Filter "Nur Werkstatt": 1 group ✅ Filter "Facebook": 0 groups ✅ Export CSV with platform columns: facebook,instagram,tiktok ✅ Test upload with Social Media consents saved correctly ✅ Export shows consented platforms per group Files Changed: - backend/src/routes/groups.js (filter logic fixed) - backend/src/routes/consent.js (API paths corrected) --- backend/src/routes/consent.js | 4 ++-- backend/src/routes/groups.js | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/src/routes/consent.js b/backend/src/routes/consent.js index c7c95f6..9936254 100644 --- a/backend/src/routes/consent.js +++ b/backend/src/routes/consent.js @@ -156,7 +156,7 @@ router.get('/api/groups/:groupId/consents', async (req, res) => { * - platformId: number * - platformConsent: boolean */ -router.get('/admin/groups/by-consent', async (req, res) => { +router.get('/api/admin/groups/by-consent', async (req, res) => { try { const filters = {}; @@ -207,7 +207,7 @@ router.get('/admin/groups/by-consent', async (req, res) => { * - year: number (optional filter) * - approved: boolean (optional filter) */ -router.get('/admin/consents/export', async (req, res) => { +router.get('/api/admin/consents/export', async (req, res) => { try { const format = req.query.format || 'json'; const filters = {}; diff --git a/backend/src/routes/groups.js b/backend/src/routes/groups.js index 8b924db..cd3fae3 100644 --- a/backend/src/routes/groups.js +++ b/backend/src/routes/groups.js @@ -72,10 +72,8 @@ router.get('/moderation/groups', async (req, res) => { consent.platform_name === platform && (consent.consented === 1 || consent.consented === true) ) ); - } else { - // Kein Filter: Zeige nur Gruppen MIT Werkstatt-Consent (das ist die Mindestanforderung) - filteredGroups = groupsWithConsents.filter(group => group.display_in_workshop); } + // else: Kein Filter - zeige ALLE Gruppen (nicht filtern) res.json({ groups: filteredGroups,