import FranceClient from "./study-in-france";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Study in France? List of Top-Rated Universities",
  description: "Planning to Study in France? Access complete information on top universities, affordable courses, and proven tips to get your student visa quickly.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Study in France? List of Top-Rated Universities",
    description: "Planning to Study in France? Access complete information on top universities, affordable courses, and proven tips to get your student visa quickly.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-france`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Study in France? List of Top-Rated Universities",
    description: "Planning to Study in France? Access complete information on top universities, affordable courses, and proven tips to get your student visa quickly.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-france`,
  },
  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 FranceServicesPage() {
  try {
    const country = 'France';
    // Fetch all France data on server side
    const franceData = await fetchSingleCountry(country);
    
    if (!franceData.success) {
      console.error('Failed to fetch France data:', franceData.error);
      return <FranceClient serverData={null} country={country} />;
    }

    return (
      <FranceClient serverData={franceData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in FranceServicesPage:', error);
    return <FranceClient serverData={null} country="France" />;
  }
}