const express = require('express');
const router = express.Router();
const { requireAuth, requirePage } = require('../middleware/auth');
const ctrl = require('../controllers/checkinController');

router.use(requireAuth);

router.get('/', ctrl.stats);  // dashboard stats
router.get('/schedule/:scheduleId', ctrl.list);
router.get('/my', ctrl.myCheckins); // partner portal
router.get('/my-history', ctrl.myHistory); // partner history
router.post('/', ctrl.checkIn); // partner can do this
router.put('/:id/checkout-with-report', ctrl.checkOutWithReport); // partner portal simplified
router.put('/:id/checkout', ctrl.checkOut);
router.put('/:id', requirePage('purchasing_schedule'), ctrl.update);
router.delete('/:id', requirePage('purchasing_schedule'), ctrl.deleteCheckin);

module.exports = router;
