/**
 * Schedule start page route.
 *
 * Renders the search form landing page. No API calls on load.
 * URL: /{lang}/schedule
 */

import { lazy, Suspense } from "react";
import { useParams } from "@modern-js/runtime/router";
import { useTranslation } from "@/i18n/provider.js";
import { SeoHead } from "@/ui/seo/SeoHead.js";
import { buildScheduleStartSeo } from "@/features/schedule/seo.js";
import { getEnv } from "@/env/index.js";

const ScheduleStartPage = lazy(() =>
  import("@/features/schedule/components/ScheduleStartPage.js").then(
    (m) => ({ default: m.ScheduleStartPage }),
  ),
);

export default function SchedulePage(): JSX.Element {
  const { t } = useTranslation();
  const routeParams = useParams<{ lang: string }>();
  const locale = routeParams.lang ?? "ru-ru";
  const canonicalOrigin = getEnv().PROD_ORIGIN;

  const seoProps = buildScheduleStartSeo(t, locale, canonicalOrigin);

  return (
    <>
      <SeoHead {...seoProps} />
      <Suspense fallback={<div aria-busy="true">{t("SHARED.LOADING")}</div>}>
        <ScheduleStartPage />
      </Suspense>
    </>
  );
}
