import RomaniaClient from "./study-in-romania";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Study in Romania: Easy Admission & Visa Guide. Apply Now | Universities Page",
  description: "Study in Romania at affordable universities. We provide a simple guide for admission, course selection, and visa support to help you get your degree in Europe.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Study in Romania: Easy Admission & Visa Guide. Apply Now | Universities Page",
    description: "Study in Romania at affordable universities. We provide a simple guide for admission, course selection, and visa support to help you get your degree in Europe.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-romania`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Study in Romania: Easy Admission & Visa Guide. Apply Now | Universities Page",
    description: "Study in Romania at affordable universities. We provide a simple guide for admission, course selection, and visa support to help you get your degree in Europe.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-romania`,
  },
  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 RomaniaServicesPage() {
  try {
    const country = 'Romania';
    // Fetch all Romania data on server side
    const romaniaData = await fetchSingleCountry(country);
    
    if (!romaniaData.success) {
      console.error('Failed to fetch Romania data:', romaniaData.error);
      return <RomaniaClient serverData={null} country={country} />;
    }

    return (
      <RomaniaClient serverData={romaniaData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in RomaniaServicesPage:', error);
    return <RomaniaClient serverData={null} country="Romania" />;
  }
}