Skip to content

Commit

Permalink
fix: Fix landing page route
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Dec 5, 2023
1 parent 3728755 commit f4f4bc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/libraries/hooks/useLandingPageRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/mockServer/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]);
});
});
};

0 comments on commit f4f4bc4

Please sign in to comment.