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

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

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

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