import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { generateProjects  } from './data';


export async function GET(request: Request) {
  let projects = generateProjects();
  let data = projects

  const cookieStore = await cookies();
    const lang = (await cookieStore).get('lang')?.value || 'fa';

  if (lang === 'fa') {
    data = projects.map(
      ({
        id,
        title,
        fa_title,
        imageSrc,
      }) => {
        if (lang === 'fa') {
          return {
            id,
            title: fa_title || title,
            imageSrc,
          };
        }
        return {
          id,
          title,
          imageSrc,
         
        };
      },
    );
  }

  return NextResponse.json({ data: projects });
}
