Skip to content

Commit

Permalink
fix(useGuild): add EXCLUDED_ROUTES
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Sep 4, 2024
1 parent 3f89742 commit b04ff8a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/[guild]/hooks/useGuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@ import { mutate as swrMutate, unstable_serialize, useSWRConfig } from "swr"
import useSWRImmutable from "swr/immutable"
import { Guild, SimpleGuild } from "types"

// TODO: once we migrate every page to the app router, we should remove this array & use the `useParams` hook instead of `usePathname`
const EXCLUDED_ROUTES = [
"explorer",
"create-guild",
"privacy-policy",
"terms-of-use",
"leaderboard",
"profile",
"superadmin",
]

const useGuildUrlNameFromPathname = (guildId?: string | number) => {
const pathname = usePathname()
const guildFromPathname = pathname?.split("/").at(1)

const idToReturn = guildId ?? guildFromPathname

if (EXCLUDED_ROUTES.includes(idToReturn?.toString() ?? "")) return undefined

return guildId ?? guildFromPathname
}

Expand Down

0 comments on commit b04ff8a

Please sign in to comment.