From f4f4bc40439a70f9fd264f4030e46b592b3dd3f8 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 5 Dec 2023 12:38:19 +0100 Subject: [PATCH] fix: Fix landing page route --- src/libraries/hooks/useLandingPageRoute.ts | 18 ++++++++---------- src/mockServer/routes/users.js | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/libraries/hooks/useLandingPageRoute.ts b/src/libraries/hooks/useLandingPageRoute.ts index 2bed1385e..28ab08dc3 100644 --- a/src/libraries/hooks/useLandingPageRoute.ts +++ b/src/libraries/hooks/useLandingPageRoute.ts @@ -15,16 +15,14 @@ export const useLandingPageRoute = () => { // Calculate the landing page route based on the user's permissions. const landingPageRoute = useMemo(() => { - const route = - settings.find((e) => e.configName === "landing")?.configValue ?? "/"; - const matched = landingPagePriority - .filter((e) => permissions.includes(e.permission)) - .map((e) => e.route); - return matched.length > 0 - ? matched.includes(route ?? "") - ? route - : matched[0] - : defaultRoute; + const route = settings.find((e) => e.configName === "landing")?.configValue; + return ( + landingPagePriority.find((e) => + route + ? e.route === route && permissions.includes(e.permission) + : permissions.includes(e.permission) + )?.route ?? defaultRoute + ); }, [permissions, settings]); // Return the landing page route. diff --git a/src/mockServer/routes/users.js b/src/mockServer/routes/users.js index aa71fa10d..4eea4ac0a 100644 --- a/src/mockServer/routes/users.js +++ b/src/mockServer/routes/users.js @@ -13,7 +13,7 @@ export const userRoutes = (server) => { server.get("/settings").intercept((req, res) => { res .status(200) - .json([{ id: 1, configName: "landing", configValue: "/dashboard" }]); + .json([{ id: 1, configName: "landing", configValue: "/laboratory" }]); }); }); };