Skip to content

Commit

Permalink
feat: add root route
Browse files Browse the repository at this point in the history
  • Loading branch information
euharrison committed Oct 1, 2024
1 parent c8001aa commit 0490678
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion apps/namadillo/src/App/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export const MainRoutes = (): JSX.Element => {
return (
<>
<Routes location={state?.backgroundLocation || location}>
<Route path="/" element={<App />} errorElement={<RouteErrorBoundary />}>
<Route
path={routes.root}
element={<App />}
errorElement={<RouteErrorBoundary />}
>
{/* Home */}
<Route index element={<AccountOverview />} />

Expand Down
3 changes: 2 additions & 1 deletion apps/namadillo/src/App/Layout/AppHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { routes } from "App/routes";
import { ReactNode } from "react";
import { Link } from "react-router-dom";
import { twMerge } from "tailwind-merge";
Expand All @@ -17,7 +18,7 @@ export const AppHeader = ({ burger }: { burger: ReactNode }): JSX.Element => {
<div className="flex items-center gap-4">
<span className="sm:px-0 lg:hidden">{burger}</span>
<Link
to={"/"}
to={routes.root}
className={twMerge(
"flex items-center gap-3",
"text-yellow text-xl font-medium uppercase"
Expand Down
2 changes: 1 addition & 1 deletion apps/namadillo/src/App/Layout/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Navigation = (): JSX.Element => {
{
label: "Overview",
icon: <AiFillHome />,
url: "/",
url: routes.root,
},
{
label: "Staking",
Expand Down
3 changes: 2 additions & 1 deletion apps/namadillo/src/App/SignMessages/SignMessages.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ActionButton, Input, Modal, Stack } from "@namada/components";
import { ModalContainer } from "App/Common/ModalContainer";
import { routes } from "App/routes";
import { arbitraryMessagesAtom } from "atoms/arbitraryMessages";
import { signArbitraryEnabledAtom } from "atoms/settings";
import { useModalCloseEvent } from "hooks/useModalCloseEvent";
Expand All @@ -23,7 +24,7 @@ export const SignMessages = (): JSX.Element => {

useEffect(() => {
if (!signArbitraryEnabled) {
navigate("/", { replace: true });
navigate(routes.root, { replace: true });
}
}, [signArbitraryEnabled]);

Expand Down
2 changes: 2 additions & 0 deletions apps/namadillo/src/App/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const routes = {
root: "/",

// Staking
staking: "/staking",
stakingBondingIncrement: "/staking/bonding/increment",
Expand Down
3 changes: 2 additions & 1 deletion apps/namadillo/src/hooks/useModalCloseEvent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { routes } from "App/routes";
import { useLocation, useNavigate } from "react-router-dom";

type useModalCloseEventProps = {
Expand All @@ -14,7 +15,7 @@ export const useModalCloseEvent = (): useModalCloseEventProps => {
replace: true,
});
} else {
navigate("/", { replace: true });
navigate(routes.root, { replace: true });
}
};

Expand Down

0 comments on commit 0490678

Please sign in to comment.