import Layout from "@/components/layout/StLayout";
import SpecialtiesPage from "@/components/specialties";
import { getStateInfo } from "@/lib/getStateInfo";

export async function generateMetadata() {
  const { matchedCity } = await getStateInfo();
  const siteName = matchedCity?.site_name || "نوبت 724";
  const cityName = matchedCity?.name || "";
  const title = cityName
    ? `تخصص‌های پزشکی در ${cityName} | ${siteName}`
    : `تخصص‌های پزشکی | ${siteName}`;
  const description = `لیست کامل تخصص‌های پزشکی${cityName ? " در " + cityName : ""}. رزرو نوبت از متخصصین مختلف به صورت آنلاین.`;
  const image = "/assets/images/og-image.png";
  return {
    title,
    description,
    openGraph: { title, description, images: [image] },
    twitter: { card: "summary_large_image", title, description, images: [image] },
  };
}

async function Specialties() {
  const { matchedCity, matchedState, isRoot } = await getStateInfo();
  return (
    <Layout name="/specialties">
      <SpecialtiesPage
        cityId={isRoot ? null : (matchedCity?.id ?? null)}
        cityName={isRoot ? null : (matchedCity?.name ?? null)}
        stateName={isRoot ? null : (matchedState?.name ?? null)}
      />
    </Layout>
  );
}

export default Specialties;
