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

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

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

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