import SwedenClient from "./study-in-sweden";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Study In Sweden 2026 - Free Consultancy |  Universities Page",
  description: "Explore options to Study In Sweden 2026 to 2026 from Pakistan: Learn about admission, fees, scholarships, visa requirements, & more. Schedule a free consultation!",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Study In Sweden 2026 - Free Consultancy |  Universities Page",
    description: "Explore options to Study In Sweden 2026 to 2026 from Pakistan: Learn about admission, fees, scholarships, visa requirements, & more. Schedule a free consultation!",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-sweden`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Study In Sweden 2026 - Free Consultancy |  Universities Page",
    description: "Explore options to Study In Sweden 2026 to 2026 from Pakistan: Learn about admission, fees, scholarships, visa requirements, & more. Schedule a free consultation!",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-sweden`,
  },
  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 SwedenServicesPage() {
  try {
    const country = 'Sweden';
    // Fetch all Sweden data on server side
    const swedenData = await fetchSingleCountry(country);
    
    if (!swedenData.success) {
      console.error('Failed to fetch Sweden data:', swedenData.error);
      return <SwedenClient serverData={null} country={country} />;
    }

    return (
      <SwedenClient serverData={swedenData.data} country={country} />
    );
  } catch (error) {
    console.error('Error in SwedenServicesPage:', error);
    return <SwedenClient serverData={null} country="Sweden" />;
  }
}