import { Router } from 'express';
import { NotificationController } from '../controllers/notification.controller';
import { authenticateToken } from '../middlewares/auth.middleware';
import { asyncHandler } from '../middlewares/errorHandler.middleware';

const router = Router();
const notificationController = new NotificationController();

/**
 * Notification Routes
 * All routes require authentication
 */

// Get user's notifications (with pagination)
// Query params: page, limit, unreadOnly
router.get('/',
  authenticateToken,
  asyncHandler(notificationController.getUserNotifications.bind(notificationController))
);

// Get unread count
router.get('/unread-count',
  authenticateToken,
  asyncHandler(notificationController.getUnreadCount.bind(notificationController))
);

// Mark notification as read
router.patch('/:notificationId/read',
  authenticateToken,
  asyncHandler(notificationController.markAsRead.bind(notificationController))
);

// Mark all as read
router.post('/mark-all-read',
  authenticateToken,
  asyncHandler(notificationController.markAllAsRead.bind(notificationController))
);

// Delete notification
router.delete('/:notificationId',
  authenticateToken,
  asyncHandler(notificationController.deleteNotification.bind(notificationController))
);

// Get user's push subscriptions
router.get('/subscriptions',
  authenticateToken,
  asyncHandler(notificationController.getUserSubscriptions.bind(notificationController))
);

export default router;

