Replace zustand state management with URL-based routing (#640)
* feat: added router * feat: added params to messages page * fixing tests, added translation labels * Update src/i18n/locales/en/ui.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/components/Dialog/NodeDetailsDialog/NodeDetailsDialog.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/components/PageComponents/Map/NodeDetail.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/pages/Messages.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * updated dev tools * fixing tests --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { createRoute, redirect } from "@tanstack/react-router";
|
||||
import { Dashboard } from "@pages/Dashboard/index.tsx";
|
||||
import MessagesPage from "@pages/Messages.tsx";
|
||||
import MapPage from "@pages/Map/index.tsx";
|
||||
import ConfigPage from "@pages/Config/index.tsx";
|
||||
import ChannelsPage from "@pages/Channels.tsx";
|
||||
import NodesPage from "@pages/Nodes.tsx";
|
||||
import { createRootRoute } from "@tanstack/react-router";
|
||||
import { App } from "./App.tsx";
|
||||
import { DialogManager } from "@components/Dialog/DialogManager.tsx";
|
||||
|
||||
const rootRoute = createRootRoute({
|
||||
component: App,
|
||||
});
|
||||
|
||||
const indexRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/",
|
||||
component: Dashboard,
|
||||
loader: () => {
|
||||
// Redirect to the broadcast messages page on initial load
|
||||
return redirect({ to: `/messages/broadcast/0`, replace: true });
|
||||
},
|
||||
});
|
||||
|
||||
const messagesRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/messages",
|
||||
component: MessagesPage,
|
||||
});
|
||||
|
||||
const messagesWithParamsRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/messages/$type/$chatId",
|
||||
component: MessagesPage,
|
||||
});
|
||||
|
||||
const mapRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/map",
|
||||
component: MapPage,
|
||||
});
|
||||
|
||||
const configRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/config",
|
||||
component: ConfigPage,
|
||||
});
|
||||
|
||||
const channelsRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/channels",
|
||||
component: ChannelsPage,
|
||||
});
|
||||
|
||||
const nodesRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/nodes",
|
||||
component: NodesPage,
|
||||
});
|
||||
|
||||
const dialogWithParamsRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/dialog/$dialogId",
|
||||
component: DialogManager,
|
||||
});
|
||||
|
||||
export const routeTree = rootRoute.addChildren([
|
||||
indexRoute,
|
||||
messagesRoute,
|
||||
messagesWithParamsRoute,
|
||||
mapRoute,
|
||||
configRoute,
|
||||
channelsRoute,
|
||||
nodesRoute,
|
||||
dialogWithParamsRoute,
|
||||
]);
|
||||
|
||||
export { rootRoute };
|
||||
Reference in New Issue
Block a user