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

export const metadata = {
  title: "Dhaka to Kushtia Train Schedule 2026 | ঢাকা থেকে কুষ্টিয়া ট্রেনের সময়সূচী | Ticket Price & Booking",
  description:
    "Dhaka to Kushtia train schedule, ticket price, and time table 2026. Trains stopping at Kushtia Court station via Padma Bridge. Book tickets online. ঢাকা থেকে কুষ্টিয়া ট্রেনের সময়সূচী ও ভাড়া।",
  keywords: [
    "dhaka to kushtia train",
    "dhaka to kushtia train schedule",
    "dhaka to kushtia ticket price",
    "dhaka to kushtia train time",
    "ঢাকা থেকে কুষ্টিয়া ট্রেন",
    "dhaka kushtia train",
    "kushtia court station train",
    "dhaka kushtia train schedule 2026",
  ],
  openGraph: {
    title: "Dhaka to Kushtia Train Schedule 2026 | Trains of Rajbari",
    description: "Complete Dhaka to Kushtia Court train schedule with ticket prices, booking info, and route details.",
    url: `${SITE_INFO.url}/dhaka-to-kushtia`,
    images: [{ url: "/logo.png" }],
  },
  alternates: { canonical: `${SITE_INFO.url}/dhaka-to-kushtia` },
};

export default function DhakaToKushtiaPage() {
  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, "") === "kushtiacourt"
    );
    return sourceIndex !== -1 && destIndex !== -1 && destIndex > sourceIndex;
  });

  const schemas = [
    getTrainRouteSchema({
      fromStation: "Dhaka",
      toStation: "Kushtia Court",
      banglaFrom: "ঢাকা",
      banglaTo: "কুষ্টিয়া কোর্ট",
      distance: "200 km",
      duration: "4-5 hours",
      availableTrains: availableTrains.length,
      url: `${SITE_INFO.url}/dhaka-to-kushtia`,
    }),
    getRouteFAQSchema({
      fromStation: "Dhaka",
      toStation: "Kushtia Court",
      availableTrains: availableTrains.length,
      duration: "4-5 hours",
      distance: "200 km",
    }),
  ];

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