Skip to content

Commit

Permalink
Fix: remove detect-hof hook and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThulinaWickramasinghe committed Aug 19, 2024
1 parent e15278a commit 9da0022
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
13 changes: 10 additions & 3 deletions src/components/layout/header.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { RxCross1, RxHamburgerMenu } from "react-icons/rx";
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 { useBreakpoint } from "@/hooks";
import useDetectHallOfFame from "@/hooks/detect-hall-of-fame";
import { BashawayLeaderboard } from "@/icons";
import { AnimatedSwitcher, Button } from "@sliit-foss/bashaway-ui/components";
import { Bashaway, FOSS, Link as LinkIcon, Times } from "@sliit-foss/bashaway-ui/icons";
Expand All @@ -16,8 +17,14 @@ const buttonStyles = "mt-1.5 xl:mt-0 px-8 xl:px-[1.15rem] pb-2.5 xl:pb-[0.4rem]

const Header = ({ className }) => {
const [mobileNavOpen, setMobileNavOpen] = useState(false);
const [isHallOfFame, setIsHallOfFame] = useState();

const breakpoints = useBreakpoint();
const isHallOfFame = useDetectHallOfFame();
const { pathname } = useLocation();

useEffect(() => {
setIsHallOfFame(pathname === hallOfFame);
}, [pathname]);

return (
<header
Expand Down
1 change: 1 addition & 0 deletions src/constants/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const hallOfFame = "/hall-of-fame";
16 changes: 0 additions & 16 deletions src/hooks/detect-hall-of-fame.jsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/store/api/leaderboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export const leaderboardApi = createApi({
}),
fetchPastLeaderboards: builder.query({
queryFn: async ({ year = 2023, round, ghostLegion, page, filters, sorts }) => {
let path = round == 1 ? "round1" : ghostLegion == true ? "ghost-legion" : "final";
let path = round === 1 ? "round1" : ghostLegion === true ? "ghost-legion" : "final";

try {
const data = await import(`../../../constants/annual-leaderboard/${year}/${path}.json`);
const transformedData = transformLeaderboardData({ ...data.default }, undefined, { page, filters, sorts });
return { data: transformedData };
} catch (error) {
console.log("Failed to fetch data dynamically");
console.error("Failed to fetch data dynamically");
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/store/api/leaderboard/transformer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { orderBy } from "lodash";
import { default as orderBy } from "lodash";
import { isRegex } from "@/utils";

const transformLeaderboardData = (response, _, arg) => {
Expand Down

0 comments on commit 9da0022

Please sign in to comment.