fix(phase2): Fix API routes and filter logic (Issues 6 & 7)
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)
This commit is contained in:
parent
e8ba1e73a0
commit
58a5c95d42
|
|
@ -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 = {};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user