const express = require('express');
const router = new express.Router();

const adminController = require('../controllers/admin');

/* GET home page. */

router.get('/users', (req, res) => {
  res.redirect('/admin/users/1');
});

router.get('/users/list', isLoggedIn, adminController.getUsersList);
// router.get('/users/list/print', isLoggedIn, adminController.getUsersListPrint);
router.get('/users/:id', isLoggedIn, adminController.getUsers);
// router.get('/users/linux', isLoggedIn, adminController.getUsersLinux);
router.get('/users/new/:id', isLoggedIn, adminController.new);
// router.get('/users/new/add/:id/:uid', isLoggedIn, adminController.addUser);
// router.get('/users/newUser/:id', isLoggedIn, adminController.newUser);
// router.get('/users/newPass/:id', isLoggedIn, adminController.linuxPass);
router.get('/users/active/:id', isLoggedIn, adminController.activeUser);
router.get('/users/inactive/:id', isLoggedIn, adminController.inactiveUser);
router.get('/users/active', isLoggedIn, adminController.getActiveUsers);
router.get('/users/inactive', isLoggedIn, adminController.getInactiveUsers);
router.get('/users/pending', isLoggedIn, adminController.getPendingUsers);
// router.get('/attendance', isLoggedIn, adminController.Attendance);
// router.get('/attendance/new', isLoggedIn, adminController.getAttendance);
router.get('/add/:id', isLoggedIn, adminController.add);
router.get('/remove/:id', isLoggedIn, adminController.remove);

// router.post('/attendance/new', adminController.newAttendance);
router.post('/contact', adminController.emailContact);
// router.get('/quizes', quizController.index);
// router.get('/quizes/:quizId(\\d+)', quizController.show);
// router.get('/quizes/:quizId(\\d+)/answer', quizController.answer);

function isLoggedIn(req, res, next) {
  if (req.isAuthenticated()) return next();
  res.redirect('/login');
}

module.exports = router;
