import express from 'express';
import { SessionController } from '../controllers/session.controller';
import { validate } from '../middleware/validate';
import { authenticateToken } from '../middleware/auth';
import { sessionSchema, logSetSchema, updateSetSchema } from '../schemas/sessions';

const router = express.Router();

router.use(authenticateToken);

router.get('/', SessionController.getAllSessions);
router.post('/', validate(sessionSchema), SessionController.saveSession);
router.get('/active', SessionController.getActiveSession);
router.get('/active/last', SessionController.getLastSession);
router.put('/active', validate(sessionSchema), SessionController.updateActiveSession);
router.get('/quick-log', SessionController.getTodayQuickLog);
router.post('/quick-log/set', validate(logSetSchema), SessionController.logSetToQuickLog);
router.post('/active/log-set', validate(logSetSchema), SessionController.logSetToActiveSession);
router.put('/active/set/:setId', SessionController.updateSet);
router.patch('/active/set/:setId', validate(updateSetSchema), SessionController.patchSet);
router.delete('/active/set/:setId', SessionController.deleteSet);
router.delete('/active', SessionController.deleteActiveSession);
router.delete('/:id', SessionController.deleteSession);

export default router;
