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

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

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

  const schemas = [
    getTrainRouteSchema({
      fromStation: "Dhaka",
      toStation: "Jashore",
      banglaFrom: "ঢাকা",
      banglaTo: "যশোর",
      distance: "280 km",
      duration: "5-7 hours",
      availableTrains: availableTrains.length,
      url: `${SITE_INFO.url}/dhaka-to-jashore`,
    }),
    getRouteFAQSchema({
      fromStation: "Dhaka",
      toStation: "Jashore",
      availableTrains: availableTrains.length,
      duration: "5-7 hours",
      distance: "280 km",
    }),
  ];

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