const express = require('express');
const router = express.Router();

// Mock bursary data
const bursaries = [
    {
        id: 1,
        title: 'STEM Excellence Bursary',
        description: 'Funding for students pursuing degrees in Science, Technology, Engineering, and Mathematics.',
        amount: 'R10,000',
        deadline: 'Dec 31, 2025'
    },
    {
        id: 2,
        title: 'Arts & Humanities Grant',
        description: 'Support for students in creative arts and humanities programs.',
        amount: 'R8,000',
        deadline: 'Nov 15, 2025'
    },
    {
        id: 3,
        title: 'Community Leadership Award',
        description: 'For students demonstrating exceptional community service and leadership.',
        amount: 'R12,000',
        deadline: 'Jan 10, 2026'
    }
];

// Home route
router.get('/', (req, res) => {
    res.render('index', {
        title: 'EMTAF Bursary Portal',
        bursaries: bursaries.slice(0, 3), // Show only 3 featured bursaries
        nonce: res.locals.nonce // Pass the nonce to the template
    });
});

// Bursaries route
router.get('/bursaries', (req, res) => {
    res.render('bursaries', {
        title: 'Available Bursaries - EMTAF',
        bursaries,
        nonce: res.locals.nonce
    });
});

module.exports = router;