import express from 'express';
const router = express.Router();
import * as commController from './communication.controller.js';
import { authenticate } from '../../common/middleware/auth.js';
import { checkRole } from '../../common/middleware/roleCheck.js';
import { ROLES } from '../../common/config/constants.js';

router.use(authenticate as any);

// Templates
router.get('/templates', checkRole([ROLES.SUPER_ADMIN, ROLES.DD_ADMIN]) as any, commController.getTemplates);
router.post('/templates', checkRole([ROLES.SUPER_ADMIN]) as any, commController.createTemplate);

// Notifications
router.get('/notifications', commController.getNotifications);
router.patch('/notifications/:id/read', commController.markAsRead);
router.patch('/notifications/read-all', commController.markAllAsRead);
router.post('/notifications/subscribe', commController.updatePushSubscription);

export default router;
