/**
 * Task Routes
 *
 * 공정(work-types) + 작업(tasks) 라우팅
 */

const express = require('express');
const router = express.Router();
const taskController = require('../controllers/taskController');
const { requireAuth, requireAdminOrPermission } = require('../middleware/auth');

const taskPerm = requireAdminOrPermission('tkuser.tasks');

// Work Types (공정)
router.get('/work-types', requireAuth, taskController.getWorkTypes);
router.post('/work-types', taskPerm, taskController.createWorkType);
router.put('/work-types/:id', taskPerm, taskController.updateWorkType);
router.delete('/work-types/:id', taskPerm, taskController.deleteWorkType);

// Tasks (작업)
router.get('/', requireAuth, taskController.getTasks);
router.get('/active', requireAuth, taskController.getActiveTasks);
router.get('/:id', requireAuth, taskController.getTaskById);
router.post('/', taskPerm, taskController.createTask);
router.put('/:id', taskPerm, taskController.updateTask);
router.delete('/:id', taskPerm, taskController.deleteTask);

module.exports = router;
