import { useLocation } from "wouter"; import { floatingLanguageMenuStructure, main } from "../configure"; import { DevControlPanelProps } from "../types/devControlPanelTypes"; import { RoutingTree } from "../types/routesTypes"; import inDev from "../utils/inDev"; import ThemeButton from "./ThemeButton"; import { clearMultiplePathSlashes } from "../utils/StringTransformationUtils"; import { useTranslation } from "react-i18next"; import FloatingMenu from "./FloatingMenu"; /** * Development Control Panel Component * * This component renders a development control panel for navigation and debugging. * It includes a dynamic list of routes and a theme toggle button. * * @param {DevControlPanelProps} props - Properties passed to the DevControlPanel component. * @returns {JSX.Element} A React component that renders the development control panel. */ const DevControlPanel = ({ routesTree }: DevControlPanelProps) => { const [, setLocation] = useLocation(); const { t, i18n } = useTranslation(); // Function to update the current location, with debug logging const _setLocation = (targetLocation: string) => { inDev(() => console.log("DevControlPanel_setLocation", targetLocation)); setLocation(targetLocation); }; // Function to generate a list of buttons for navigation based on the routing tree const routesCrawler = ( routesTree: RoutingTree, parentPath?: string, ): JSX.Element[] => { return routesTree.map((route): JSX.Element => { // Constructing path for the route button const _path = clearMultiplePathSlashes( parentPath ? "/" + parentPath + "/" + route.path : "/" + route.path, ); // Debug logging for route information inDev(() => console.log( "%croutesCrawler_routes %s %s", "color: lightblue", route.name, _path, ), ); // Generating nested routes or single route buttons if (route.nest) { return (
{route.name}
{routesCrawler(route.nest, _path)}
); } else { return ( ); } }); }; // Render the development control panel with navigation buttons and theme toggle return (
{/* Displaying the program name and version */}
{main.program_name} v{main.program_version}

Base path is: {main.base_path}

{/* Embedding the ThemeButton component for theme toggling */}
{/* Rendering the dynamically generated route navigation buttons */}
{routesCrawler(routesTree)}

{t("welcome")}

Lang: {i18n.language}

); }; export default DevControlPanel;