import { trainData } from "@/data";
import { getTrainRouteSchema, getRouteFAQSchema, SITE_INFO } from "@/lib/schemas";
import DhakaToRajshahiClient from "./DhakaToRajshahiClient";

export const metadata = {
  title: "Dhaka to Rajshahi Train Schedule 2026 | ঢাকা থেকে রাজশাহী ট্রেনের সময়সূচী | Ticket Price & Booking",
  description:
    "Dhaka to Rajshahi train schedule, ticket price, and time table 2026. Trains including Madhumati Express via Padma Bridge & Ishwardi. Book tickets online. ঢাকা থেকে রাজশাহী ট্রেনের সময়সূচী ও ভাড়া।",
  keywords: [
    "dhaka to rajshahi train",
    "dhaka to rajshahi train schedule",
    "dhaka to rajshahi ticket price",
    "dhaka to rajshahi train time",
    "ঢাকা থেকে রাজশাহী ট্রেন",
    "dhaka rajshahi train",
    "rajshahi train from dhaka",
    "madhumati express dhaka to rajshahi",
    "dhaka rajshahi train schedule 2026",
  ],
  openGraph: {
    title: "Dhaka to Rajshahi Train Schedule 2026 | Trains of Rajbari",
    description:
      "Complete Dhaka to Rajshahi train schedule with ticket prices, booking info, and route details.",
    url: `${SITE_INFO.url}/dhaka-to-rajshahi`,
    images: [{ url: "/logo.png" }],
  },
  alternates: {
    canonical: `${SITE_INFO.url}/dhaka-to-rajshahi`,
  },
};

export default function DhakaToRajshahiPage() {
  const availableTrains = trainData.filter((t) => {
    const routes = t.data.routes;
    const sourceIndex = routes.findIndex(
      (r) => r.city.toLowerCase().replace(/_/g, "") === "dhaka"
    );
    const destIndex = routes.findIndex(
      (r) => r.city.toLowerCase().replace(/_/g, "") === "rajshahi"
    );
    return sourceIndex !== -1 && destIndex !== -1 && destIndex > sourceIndex;
  });

  const schemas = [
    getTrainRouteSchema({
      fromStation: "Dhaka",
      toStation: "Rajshahi",
      banglaFrom: "ঢাকা",
      banglaTo: "রাজশাহী",
      distance: "250 km",
      duration: "5-6 hours",
      availableTrains: availableTrains.length,
      url: `${SITE_INFO.url}/dhaka-to-rajshahi`,
    }),
    getRouteFAQSchema({
      fromStation: "Dhaka",
      toStation: "Rajshahi",
      availableTrains: availableTrains.length,
      duration: "5-6 hours",
      distance: "250 km",
    }),
  ];

  return (
    <>
      {schemas.map((schema, i) => (
        <script
          key={i}
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
        />
      ))}
      <DhakaToRajshahiClient />
    </>
  );
}
