import ItalyClient from "./study-in-italy";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Top Italian Universities: Easy Application Steps 2025 - 2026",
  description: "Study in Italy with Universities Page. We provide full scholarship info and top-rated guidance for visa processing and university admissions for students.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Top Italian Universities: Easy Application Steps 2025 - 2026",
    description: "Study in Italy with Universities Page. We provide full scholarship info and top-rated guidance for visa processing and university admissions for students.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-italy`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Top Italian Universities: Easy Application Steps 2025 - 2026",
    description: "Study in Italy with Universities Page. We provide full scholarship info and top-rated guidance for visa processing and university admissions for students.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-italy`,
  },
  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 ItalyServicesPage() {
  try {
    const country = 'Italy';
    // Fetch all Italy data on server side
    const italyData = await fetchSingleCountry(country);
    
    if (!italyData.success) {
      console.error('Failed to fetch Italy data:', italyData.error);
      return <ItalyClient serverData={null} country={country} />;
    }

    return (
      <ItalyClient serverData={italyData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in ItalyServicesPage:', error);
    return <ItalyClient serverData={null} country="Italy" />;
  }
}