import UKClient from "./study-in-united-kingdom";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Expert Guide Study in United Kingdom: Easy Application Process",
  description: "Start your global career and Study in United Kingdom. Get Consultancy with our experts for scholarships and admissions to top UK colleges and universities from Pakistan.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Expert Guide Study in United Kingdom: Easy Application Process",
    description: "Start your global career and Study in United Kingdom. Get Consultancy with our experts for scholarships and admissions to top UK colleges and universities from Pakistan.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-united-kingdom`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Expert Guide Study in United Kingdom: Easy Application Process",
    description: "Start your global career and Study in United Kingdom. Get Consultancy with our experts for scholarships and admissions to top UK colleges and universities from Pakistan.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-united-kingdom`,
  },
  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 UnitedKingdomServicesPage() {
  try {
    const country = 'United Kingdom';
    // Fetch all UK data on server side
    const ukData = await fetchSingleCountry(country);
    
    if (!ukData.success) {
      console.error('Failed to fetch UK data:', ukData.error);
      return <UKClient serverData={null} country={country} />;
    }

    return (
      <UKClient serverData={ukData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in UnitedKingdomServicesPage:', error);
    return <UKClient serverData={null} country="United Kingdom" />;
  }
}