const express = require('express');
const SocialMediaRepository = require('../repositories/SocialMediaRepository');
const dbManager = require('../database/DatabaseManager');

const router = express.Router();

/**
 * Public endpoint: list active social media platforms for consent selection
 */
router.get('/social-media/platforms', async (req, res) => {
    /*
        #swagger.tags = ['Consent Management']
        #swagger.summary = 'List active social media platforms'
        #swagger.description = 'Public endpoint that exposes the available platforms for consent selection on the upload form.'
    */
    try {
        const socialMediaRepo = new SocialMediaRepository(dbManager);
        const platforms = await socialMediaRepo.getActivePlatforms();
        res.json(platforms);
    } catch (error) {
        console.error('[SOCIAL_MEDIA] Failed to fetch platforms:', error);
        res.status(500).json({
            error: 'Failed to fetch social media platforms',
            message: error.message
        });
    }
});

module.exports = router;
