Skip to content

Commit

Permalink
Fix: link to the accounts page from the logo (#3577)
Browse files Browse the repository at this point in the history
* Fix: link to the accounts page from the logo

* Link to home from other Safe pages
  • Loading branch information
katspaugh authored Apr 23, 2024
1 parent 97b2da9 commit a2d5ebb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/common/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Dispatch, SetStateAction } from 'react'
import { type ReactElement } from 'react'
import { useRouter } from 'next/router'
import type { Url } from 'next/dist/shared/lib/router/router'
import { IconButton, Paper } from '@mui/material'
import MenuIcon from '@mui/icons-material/Menu'
import classnames from 'classnames'
Expand All @@ -26,15 +27,23 @@ type HeaderProps = {
onBatchToggle?: Dispatch<SetStateAction<boolean>>
}

function getLogoLink(router: ReturnType<typeof useRouter>): Url {
return router.pathname === AppRoutes.home || !router.query.safe
? router.pathname === AppRoutes.welcome.accounts
? AppRoutes.welcome.index
: AppRoutes.welcome.accounts
: { pathname: AppRoutes.home, query: { safe: router.query.safe } }
}

const Header = ({ onMenuToggle, onBatchToggle }: HeaderProps): ReactElement => {
const chainId = useChainId()
const safeAddress = useSafeAddress()
const showSafeToken = safeAddress && !!getSafeTokenAddress(chainId)
const router = useRouter()
const enableWc = useHasFeature(FEATURES.NATIVE_WALLETCONNECT)

// Logo link: if on Dashboard, link to Welcome, otherwise to the root (which redirects to either Dashboard or Welcome)
const logoHref = router.pathname === AppRoutes.home ? AppRoutes.welcome.index : AppRoutes.index
// If on the home page, the logo should link to the Accounts or Welcome page, otherwise to the home page
const logoHref = getLogoLink(router)

const handleMenuToggle = () => {
if (onMenuToggle) {
Expand Down

0 comments on commit a2d5ebb

Please sign in to comment.