import express from 'express';
import { getSettings, updateSettings, uploadLogo, serveLogo } from '../controllers/systemSettingsController.js';
import { requireDeveloper } from '../middleware/authMiddleware.js';
import { uploadLogoDetails } from '../middleware/uploadMiddleware.js';

const router = express.Router();

// Public/Auth access to read settings
router.get('/', getSettings);

// Protected update
router.put('/', updateSettings);

// Protected upload
router.post('/logo', uploadLogoDetails.single('logo'), uploadLogo);

// Public access to view logo (noauth needed for login screen etc)
router.get('/logo-image/:filename', (req, res) => {
    // Use static import to ensure bundler compatibility
    serveLogo(req, res);
});

// Global Admin Routes
import { getGlobalUsers, getGlobalOrganizations, toggleOrganizationBan } from '../controllers/systemSettingsController.js';

router.get('/users', getGlobalUsers);
router.get('/organizations', getGlobalOrganizations);
router.post('/organizations/ban', toggleOrganizationBan);

export default router;
