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 (
Base path is: {main.base_path}
{t("welcome")}
Lang: {i18n.language}