import { createFileRoute, redirect } from "@tanstack/react-router";
import { AnalysisPage } from "@/features/analysis/AnalysisPage";

const VALID_CURRENCIES = ["BELO", "BLUE", "BNA"];

export const Route = createFileRoute(
  "/_authenticated/quotes/analysis/$currency",
)({
  component: RouteComponent,
  loader: ({ params }) => {
    if (!VALID_CURRENCIES.includes(params.currency)) {
      throw redirect({ to: "/quotes" });
    }
  },
});

function RouteComponent() {
  const { currency } = Route.useParams();
  return <AnalysisPage currency={currency} />;
}
