import { Router } from 'express';
import { mailTemplateFileController } from '../controllers/mailTemplateFileController';
import { authenticateToken } from '../middleware/authMiddleware';

const router = Router();

// 모든 메일 템플릿 라우트에 인증 미들웨어 적용
router.use(authenticateToken);

// 템플릿 CRUD
router.get('/', (req, res) => mailTemplateFileController.getAllTemplates(req, res));
router.get('/:id', (req, res) => mailTemplateFileController.getTemplateById(req, res));
router.post('/', (req, res) => mailTemplateFileController.createTemplate(req, res));
router.put('/:id', (req, res) => mailTemplateFileController.updateTemplate(req, res));
router.delete('/:id', (req, res) => mailTemplateFileController.deleteTemplate(req, res));

// 미리보기
router.post('/:id/preview', (req, res) => mailTemplateFileController.previewTemplate(req, res));
router.post('/:id/preview-with-query', (req, res) => mailTemplateFileController.previewWithQuery(req, res));

export default router;

