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 walkthrough from '@/api/controllers/walkthrough_checkins.controller';

const router = express.Router();

/**
 * @openapi
 * /api/walkthrough_checkins:
 *   get:
 *     tags: [Walkthrough]
 *     summary: List walkthrough check-ins (director surface)
 *     description: Requires the `READ_WALKTHROUGH` product-feature permission.
 *     responses:
 *       200:
 *         description: List of walkthrough check-ins.
 *         content:
 *           application/json:
 *             schema: { $ref: '#/components/schemas/ListResponse' }
 *       401: { $ref: '#/components/responses/UnauthorizedError' }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 *   post:
 *     tags: [Walkthrough]
 *     summary: Create a walkthrough check-in (manager-only; service-gated)
 *     responses:
 *       200: { description: Created. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 * /api/walkthrough_checkins/{id}:
 *   delete:
 *     tags: [Walkthrough]
 *     summary: Delete a walkthrough check-in (manager-only; service-gated)
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema: { type: string, format: uuid }
 *     responses:
 *       200: { description: Deleted. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 */
router.get(
  '/',
  permissions.checkPermissions(FEATURE_PERMISSIONS.READ_WALKTHROUGH),
  wrapAsync(walkthrough.list),
);
router.post('/', wrapAsync(walkthrough.create));
router.delete('/:id', wrapAsync(walkthrough.remove));

export default router;
