import express from 'express';
import { requireAuth, requireRole } from '../middleware/auth.js';
import {
  getDashboardVisibility,
  updateDashboardVisibility,
  getAvailableDashboardItems,
  initializeDashboardVisibility
} from '../controllers/dashboardVisibilityController.js';

const router = express.Router();

// Get dashboard visibility settings for a project (accessible by project users and admins)
router.get('/project/:treelogy_id', requireAuth, getDashboardVisibility);

// Get all available dashboard items (for super admin configuration)
router.get('/available-items', requireAuth, requireRole('SUPER_ADMIN'), getAvailableDashboardItems);

// Initialize dashboard visibility for a new project (super admin only)
router.post('/project/:treelogy_id/initialize', requireAuth, requireRole('SUPER_ADMIN'), initializeDashboardVisibility);

// Update dashboard visibility settings (super admin only)
router.put('/project/:treelogy_id', requireAuth, requireRole('SUPER_ADMIN'), updateDashboardVisibility);

export default router;
