import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db';

export async function GET(request: NextRequest) {
  try {
    const socialMediaLinks = await prisma.socialMediaLink.findMany({
      where: { isEnabled: true },
      orderBy: { order: 'asc' },
      select: {
        id: true,
        platform: true,
        name: true,
        url: true,
        icon: true,
        order: true
      }
    });

    return NextResponse.json({
      success: true,
      data: socialMediaLinks
    });
  } catch (error) {
    console.error('Error fetching social media links:', error);
    return NextResponse.json(
      { success: false, error: 'Failed to fetch social media links' },
      { status: 500 }
    );
  }
}