import { Router } from 'express';
import * as contractHistoryController from '../controllers/contractHistory.controller.js';
import { authenticate, requirePermission } from '../middleware/auth.js';

const router = Router();

// Alle Einträge für einen Vertrag
router.get(
  '/contracts/:contractId/history',
  authenticate,
  requirePermission('contracts:read'),
  contractHistoryController.getHistoryEntries
);

// Neuen Eintrag erstellen
router.post(
  '/contracts/:contractId/history',
  authenticate,
  requirePermission('contracts:update'),
  contractHistoryController.createHistoryEntry
);

// Eintrag aktualisieren
router.put(
  '/contracts/:contractId/history/:entryId',
  authenticate,
  requirePermission('contracts:update'),
  contractHistoryController.updateHistoryEntry
);

// Eintrag löschen
router.delete(
  '/contracts/:contractId/history/:entryId',
  authenticate,
  requirePermission('contracts:update'),
  contractHistoryController.deleteHistoryEntry
);

export default router;
