// src/app/dashboard/page.tsx
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/api/auth';
import { redirect } from 'next/navigation';
import SkinGrid from '@/components/skins/SkinGrid';

export default async function Dashboard() {
    const session = await getServerSession(authOptions);

    if (!session) {
        redirect('/login');
    }

    // 安全地获取用户ID
    const userId = session.user?.id || 'unknown';

    // 实际应用中这里会从API获取用户皮肤数据
    const mockSkins = [
        { id: '1', name: 'Steve皮肤', createdAt: '2023-05-01' },
        { id: '2', name: 'Alex皮肤', createdAt: '2023-05-15' },
    ];

    return (
        <div>
            <h1 className="text-3xl font-bold mb-6">我的皮肤库</h1>
            <div className="mb-6">
                <a
                    href="/skins/upload"
                    className="bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded"
                >
                    上传新皮肤
                </a>
            </div>
            <SkinGrid skins={mockSkins} />
        </div>
    );
}