forked from humanprotocol/human-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(human-app/frontend/logo-icon): handle logo icon click
- Loading branch information
1 parent
4d2c963
commit 7ff8b17
Showing
4 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/apps/human-app/frontend/src/hooks/use-handle-main-nav-icon-click.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useWeb3Auth } from '@/auth-web3/use-web3-auth'; | ||
import { useAuth } from '@/auth/use-auth'; | ||
import { useHomePageState } from '@/contexts/homepage-state'; | ||
import { routerPaths } from '@/router/router-paths'; | ||
|
||
export const useHandleMainNavIconClick = () => { | ||
const navigate = useNavigate(); | ||
const { user: web3User } = useWeb3Auth(); | ||
const { user: web2Auth } = useAuth(); | ||
const { setPageView } = useHomePageState(); | ||
|
||
const handleIconClick = () => { | ||
if (web3User) { | ||
navigate(routerPaths.operator.profile); | ||
return; | ||
} | ||
|
||
if (web2Auth) { | ||
navigate(routerPaths.worker.profile); | ||
return; | ||
} | ||
setPageView('welcome'); | ||
navigate(routerPaths.homePage); | ||
}; | ||
|
||
return handleIconClick; | ||
}; |