const express = require('express');
const router = express.Router();
const contactController = require('../controllers/contactController');
const settingsController = require('../controllers/settingsController');
const { protect, adminOnly } = require('../middleware/authMiddleware');

// Public routes
router.post('/contact', contactController.createMessage);
router.get('/settings', settingsController.getSettingsAsObject);

// Admin routes - Contact Messages
router.get('/contact-messages', protect, adminOnly, contactController.getAllMessages);
router.get('/contact-messages/:id', protect, adminOnly, contactController.getMessageById);
router.put('/contact-messages/:id/status', protect, adminOnly, contactController.updateMessageStatus);
router.delete('/contact-messages/:id', protect, adminOnly, contactController.deleteMessage);
router.get('/contact-messages/stats/unread', protect, adminOnly, contactController.getUnreadCount);

// Admin routes - Settings
router.get('/admin/settings', protect, adminOnly, settingsController.getAllSettings);
router.put('/admin/settings', protect, adminOnly, settingsController.updateSettings);

module.exports = router;
