import CyprusClient from "./study-in-cyprus";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Study in Cyprus: Expert Admission Consultants | Universities Page",
  description: "Start your Study in Cyprus journey! Get the Consultancy of leading universities, check fees, and get professional help for your student visa and course selection.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Study in Cyprus: Expert Admission Consultants | Universities Page",
    description: "Start your Study in Cyprus journey! Get the Consultancy of leading universities, check fees, and get professional help for your student visa and course selection.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-cyprus`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Study in Cyprus: Expert Admission Consultants | Universities Page",
    description: "Start your Study in Cyprus journey! Get the Consultancy of leading universities, check fees, and get professional help for your student visa and course selection.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-cyprus`,
  },
  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 CyprusServicesPage() {
  try {
    const country = 'Cyprus';
    // Fetch all Cyprus data on server side
    const cyprusData = await fetchSingleCountry(country);
    
    if (!cyprusData.success) {
      console.error('Failed to fetch Cyprus data:', cyprusData.error);
      return <CyprusClient serverData={null} country={country} />;
    }

    return (
      <CyprusClient serverData={cyprusData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in CyprusServicesPage:', error);
    return <CyprusClient serverData={null} country="Cyprus" />;
  }
}