import ChinaServicesClient from "./study-in-china";
import { fetchSingleCountry } from "../../../lib/directQueries/allqueries";

export const metadata = {
  title: "Expert Counsaltancy: Study in China with Full Scholarships",
  description: "Want to Study in China? Get best scholarship deals and easy visa guides for top Chinese universities. Start your application with full support today.",
  siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
  openGraph: {
    title: "Expert Counsaltancy: Study in China with Full Scholarships",
    description: "Want to Study in China? Get best scholarship deals and easy visa guides for top Chinese universities. Start your application with full support today.",
    url: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-china`,
    siteName: process.env.NEXT_PUBLIC_APP_WEBSITE_NAME,
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Expert Counsaltancy: Study in China with Full Scholarships",
    description: "Want to Study in China? Get best scholarship deals and easy visa guides for top Chinese universities. Start your application with full support today.",
  },
  alternates: {
    canonical: `${process.env.NEXT_PUBLIC_APP_URL}/study-in-china`,
  },
  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 ChinaServicesPage() {
  try {
    const country = 'China'
    // Fetch all China data on server side
    const chinaData = await fetchSingleCountry(country);
    
    if (!chinaData.success) {
      console.error('Failed to fetch China data:', chinaData.error);
      return <ChinaServicesClient serverData={null} />;
    }

    return (
      <ChinaServicesClient serverData={chinaData.data} />
    );
  } catch (error) {
    console.error('Error in ChinaServicesPage:', error);
    return <ChinaServicesClient serverData={null} />;
  }
}