import express from 'express';
import { wrapAsync } from '@/api/http/request';
import permissions from '@/middlewares/check-permissions';
import { FEATURE_PERMISSIONS } from '@/shared/constants/product-permissions';
import * as staff_attendance from '@/api/controllers/staff_attendance.controller';

const router = express.Router();

/**
 * @openapi
 * /api/staff_attendance/records:
 *   get:
 *     tags: [Staff Attendance]
 *     summary: List staff attendance records (report)
 *     description: Requires `READ_ATTENDANCE`; the service limits the payload to report-eligible roles.
 *     responses:
 *       200: { description: Records. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 * /api/staff_attendance/summary:
 *   get:
 *     tags: [Staff Attendance]
 *     summary: Staff attendance summary (report)
 *     description: Requires `READ_ATTENDANCE`.
 *     responses:
 *       200: { description: Summary. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 */
router.get(
  '/records',
  permissions.checkPermissions(FEATURE_PERMISSIONS.READ_ATTENDANCE),
  wrapAsync(staff_attendance.listRecords),
);
router.get(
  '/summary',
  permissions.checkPermissions(FEATURE_PERMISSIONS.READ_ATTENDANCE),
  wrapAsync(staff_attendance.summary),
);

export default router;
