// Rôle : choisit la page à rendre selon la route active.
import React from "react";
import { GameRoute } from "../features/games/GameRoute.jsx";
import { GamesPage } from "../features/games/GamesPage.jsx";
import { ToolboxesPage, ToolboxPage } from "../features/toolboxes/ToolboxPages.jsx";
import { AboutPage } from "../pages/AboutPage.jsx";
import { HomePage } from "../pages/HomePage.jsx";
import { LibraryPage } from "../pages/LibraryPage.jsx";
import { navigate } from "./hashRouter.js";

export function RouteContent(props) {
  const { route } = props;
  if (route === "/") return <HomePage {...props} />;
  if (route === "/library") return <LibraryPage {...props} />;
  if (route === "/about") return <AboutPage siteContent={props.siteContent} />;
  if (route === "/toolboxes") return <ToolboxesPage {...props} />;
  if (route.startsWith("/toolbox/")) return <ToolboxPage {...props} toolboxId={route.split("/")[2]} />;
  if (route === "/games") return <GamesPage {...props} />;
  if (route.startsWith("/games/")) return <GameRoute {...props} gameId={route.split("/")[2]} category={route.split("/")[3] || ""} />;
  navigate("/");
  return null;
}
