const express = require('express');
const router = express.Router();
const settingsController = require('../controllers/settingsController');

// Debug endpoint to check configuration
router.get('/config-debug', (req, res) => {
    const config = require('../config');
    res.json({
        success: true,
        config: {
            nocodb: {
                apiUrl: config.nocodb.apiUrl,
                hasToken: !!config.nocodb.apiToken,
                projectId: config.nocodb.projectId,
                tableId: config.nocodb.tableId,
                loginSheetId: config.nocodb.loginSheetId,
                settingsSheetId: config.nocodb.settingsSheetId,
                shiftsSheetId: config.nocodb.shiftsSheetId,
                shiftSignupsSheetId: config.nocodb.shiftSignupsSheetId
            }
        }
    });
});

// Start location management
router.get('/start-location', settingsController.getStartLocation);
router.post('/start-location', settingsController.updateStartLocation);

// Walk sheet configuration
router.get('/walk-sheet-config', settingsController.getWalkSheetConfig);
router.post('/walk-sheet-config', settingsController.updateWalkSheetConfig);

module.exports = router;