import SouthKoreaClient from "./study-in-south-korea";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Study In South Korea | Consultants for Apply to Top Universities",
  description: "Study in South Korea 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 South Korea | Consultants for Apply to Top Universities",
    description: "Study in South Korea 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-south-korea`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Study In South Korea | Consultants for Apply to Top Universities",
    description: "Study in South Korea 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-south-korea`,
  },
  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 SouthKoreaServicesPage() {
  try {
    const country = 'South Korea';
    // Fetch all South Korea data on server side
    const southKoreaData = await fetchSingleCountry(country);
    
    if (!southKoreaData.success) {
      console.error('Failed to fetch South Korea data:', southKoreaData.error);
      return <SouthKoreaClient serverData={null} country={country} />;
    }

    return (
      <SouthKoreaClient serverData={southKoreaData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in SouthKoreaServicesPage:', error);
    return <SouthKoreaClient serverData={null} country="South Korea" />;
  }
}