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

// Главная страница сравнения admin bundles
router.get('/admin-comparison', async (req, res) => {
    try {
        res.render('admin-bundle-comparison', {
            layout: false // Не используем layout для этой страницы
        });
    } catch (error) {
        console.error('Admin Comparison Error:', error);
        res.status(500).send('Server Error');
    }
});

// Демо-роут для AdminLTE админки
router.get('/demo-adminlte', async (req, res) => {
    try {
        // Мок-данные для демонстрации
        const stats = {
            portfolioCount: 12,
            servicesCount: 6,
            contactsCount: 24,
            usersCount: 3
        };

        const recentPortfolio = [
            {
                title: '삼성 모바일 앱 개발',
                category: 'mobile-app',
                status: 'completed',
                createdAt: new Date('2024-10-20')
            },
            {
                title: 'LG 웹사이트 리뉴얼',
                category: 'web-development',
                status: 'in-progress', 
                createdAt: new Date('2024-10-18')
            },
            {
                title: '현대차 UI/UX 디자인',
                category: 'ui-ux-design',
                status: 'planning',
                createdAt: new Date('2024-10-15')
            }
        ];

        const recentContacts = [
            {
                name: '김철수',
                email: 'kim@example.com',
                status: 'pending',
                createdAt: new Date('2024-10-25')
            },
            {
                name: '이영희',
                email: 'lee@company.kr',
                status: 'replied',
                createdAt: new Date('2024-10-24')
            },
            {
                name: '박민수',
                email: 'park@startup.co.kr',
                status: 'new',
                createdAt: new Date('2024-10-23')
            }
        ];

        const user = {
            name: '관리자'
        };

        res.render('admin/dashboard-adminlte', {
            layout: 'admin/layout-adminlte',
            title: '대시보드',
            currentPage: 'dashboard',
            currentLanguage: 'ko',
            stats,
            recentPortfolio,
            recentContacts,
            user
        });
    } catch (error) {
        console.error('AdminLTE Demo Error:', error);
        res.status(500).send('Server Error');
    }
});

// Демо-роут для Tabler админки
router.get('/demo-tabler', async (req, res) => {
    try {
        // Мок-данные для демонстрации
        const stats = {
            portfolioCount: 12,
            servicesCount: 6,
            contactsCount: 24,
            usersCount: 3
        };

        const recentPortfolio = [
            {
                title: '삼성 모바일 앱 개발',
                category: 'mobile-app',
                status: 'completed',
                createdAt: new Date('2024-10-20')
            },
            {
                title: 'LG 웹사이트 리뉴얼',
                category: 'web-development',
                status: 'in-progress', 
                createdAt: new Date('2024-10-18')
            },
            {
                title: '현대차 UI/UX 디자인',
                category: 'ui-ux-design',
                status: 'planning',
                createdAt: new Date('2024-10-15')
            }
        ];

        const recentContacts = [
            {
                name: '김철수',
                email: 'kim@example.com',
                status: 'pending',
                createdAt: new Date('2024-10-25')
            },
            {
                name: '이영희',
                email: 'lee@company.kr',
                status: 'replied',
                createdAt: new Date('2024-10-24')
            },
            {
                name: '박민수',
                email: 'park@startup.co.kr',
                status: 'new',
                createdAt: new Date('2024-10-23')
            }
        ];

        const user = {
            name: '관리자'
        };

        res.render('admin/dashboard-tabler', {
            layout: 'admin/layout-tabler',
            title: '대시보드',
            currentPage: 'dashboard',
            currentLanguage: 'ko',
            stats,
            recentPortfolio,
            recentContacts,
            user
        });
    } catch (error) {
        console.error('Tabler Demo Error:', error);
        res.status(500).send('Server Error');
    }
});

module.exports = router;