import TurkeyClient from "./study-in-turkey";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Study in Turkey with Full Scholarship Info and Best Universities",
  description: "Study in Turkey with easy admission steps. Find fully-funded scholarship opportunities and get all the information you need to secure your seat abroad.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Study in Turkey with Full Scholarship Info and Best Universities",
    description: "Study in Turkey with easy admission steps. Find fully-funded scholarship opportunities and get all the information you need to secure your seat abroad.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-turkey`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Study in Turkey with Full Scholarship Info and Best Universities",
    description: "Study in Turkey with easy admission steps. Find fully-funded scholarship opportunities and get all the information you need to secure your seat abroad.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-turkey`,
  },
  robots: {
    index: true,
    follow: true,
    nocache: false,
    googleBot: {
      index: true,
      follow: true,
      noimageindex: false,
      "max-video-preview": -1,
      "max-image-preview": "large",
      "max-snippet": -1,
    },
  },
};

export default async function TurkeyServicesPage() {
  try {
    const country = 'Turkey';
    // Fetch all Turkey data on server side
    const turkeyData = await fetchSingleCountry(country);
    
    if (!turkeyData.success) {
      console.error('Failed to fetch Turkey data:', turkeyData.error);
      return <TurkeyClient serverData={null} country={country} />;
    }

    return (
      <TurkeyClient serverData={turkeyData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in TurkeyServicesPage:', error);
    return <TurkeyClient serverData={null} country="Turkey" />;
  }
}