From 6df91f3adcb27fd60292cde55ae1d7276102e579 Mon Sep 17 00:00:00 2001 From: sianida26 Date: Sun, 5 May 2024 13:53:24 +0700 Subject: [PATCH] Added redirection on homepage --- apps/backend/src/data/sidebarMenus.ts | 2 +- apps/frontend/src/routes/index.lazy.tsx | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/backend/src/data/sidebarMenus.ts b/apps/backend/src/data/sidebarMenus.ts index 8201480..2de9dd6 100644 --- a/apps/backend/src/data/sidebarMenus.ts +++ b/apps/backend/src/data/sidebarMenus.ts @@ -5,7 +5,7 @@ const sidebarMenus: SidebarMenu[] = [ label: "Dashboard", icon: { tb: "TbLayoutDashboard" }, allowedPermissions: ["*"], - link: "/", + link: "/dashboard", }, { label: "Users", diff --git a/apps/frontend/src/routes/index.lazy.tsx b/apps/frontend/src/routes/index.lazy.tsx index 71343ca..34a0a55 100644 --- a/apps/frontend/src/routes/index.lazy.tsx +++ b/apps/frontend/src/routes/index.lazy.tsx @@ -1,5 +1,19 @@ -import { createLazyFileRoute } from "@tanstack/react-router"; +import { createLazyFileRoute, useNavigate } from "@tanstack/react-router"; +import { useEffect } from "react"; export const Route = createLazyFileRoute("/")({ - component: () =>
Hello !
, + component: HomePage, }); + +export default function HomePage() { + const navigate = useNavigate(); + + useEffect(() => { + navigate({ + to: "/dashboard", + replace: true, + }); + }, [navigate]); + + return
index.lazy
; +}