import FinlandClient from "./study-in-finland";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Affordable Study In Finland: Apply to Leading Universities",
  description: "Study in Finland with expert guidance from Universities Page. Get admission to top Finnish universities with scholarship opportunities. Complete support for visa processing, course selection, and application assistance.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Affordable Study In Finland: Apply to Leading Universities",
    description: "Study in Finland with expert guidance from Universities Page. Get admission to top Finnish universities with scholarship opportunities. Complete support for visa processing, course selection, and application assistance.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-finland`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Affordable Study In Finland: Apply to Leading Universities",
    description: "Study in Finland with expert guidance from Universities Page. Get admission to top Finnish universities with scholarship opportunities. Complete support for visa processing, course selection, and application assistance.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-finland`,
  },
  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 FinlandServicesPage() {
  try {
    const country = 'Finland';
    // Fetch all Finland data on server side
    const finlandData = await fetchSingleCountry(country);
    
    if (!finlandData.success) {
      console.error('Failed to fetch Finland data:', finlandData.error);
      return <FinlandClient serverData={null} country={country} />;
    }

    return (
      <FinlandClient serverData={finlandData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in FinlandServicesPage:', error);
    return <FinlandClient serverData={null} country="Finland" />;
  }
}