Skip to content

Commit

Permalink
Refactor: used routes from constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Aug 21, 2024
1 parent 9cb2eae commit 232f8de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/layout/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link } from "react-router-dom";
import { useLocation } from "react-router-dom";
import { twMerge } from "tailwind-merge";
import { portalURL } from "@/constants";
import { hallOfFame } from "@/constants/routes";
import { HALL_OF_FAME } from "@/constants/routes";
import { useBreakpoint } from "@/hooks";
import { BashawayLeaderboard } from "@/icons";
import { AnimatedSwitcher, Button } from "@sliit-foss/bashaway-ui/components";
Expand All @@ -19,9 +19,10 @@ const Header = ({ className }) => {
const [mobileNavOpen, setMobileNavOpen] = useState(false);

const breakpoints = useBreakpoint();

const { pathname } = useLocation();

const isHallOfFame = pathname === hallOfFame;
const isHallOfFame = pathname === HALL_OF_FAME;

return (
<header
Expand Down
1 change: 1 addition & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./hyperlinks";
export * from "./socials";
export * from "./routes";
3 changes: 2 additions & 1 deletion src/constants/routes.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const hallOfFame = "/hall-of-fame";
export const HOME = "/";
export const HALL_OF_FAME = "/hall-of-fame";
5 changes: 3 additions & 2 deletions src/routes/index.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Route, Routes, useLocation } from "react-router-dom";
import { AnimatePresence } from "framer-motion";
import { HALL_OF_FAME, HOME } from "@/constants";
import { HallOfFame, Home, NotFound } from "@/pages";

const AnimatedRoutes = () => {
const location = useLocation();
return (
<AnimatePresence>
<Routes location={location}>
<Route path="/" element={<Home />} />
<Route path="/hall-of-fame" element={<HallOfFame />} />
<Route path={HOME} element={<Home />} />
<Route path={HALL_OF_FAME} element={<HallOfFame />} />
<Route path="*" element={<NotFound />} />
</Routes>
</AnimatePresence>
Expand Down

0 comments on commit 232f8de

Please sign in to comment.